15 |
15 |
16 class Purge(HgExtension): |
16 class Purge(HgExtension): |
17 """ |
17 """ |
18 Class implementing the purge extension interface. |
18 Class implementing the purge extension interface. |
19 """ |
19 """ |
|
20 |
20 def __init__(self, vcs): |
21 def __init__(self, vcs): |
21 """ |
22 """ |
22 Constructor |
23 Constructor |
23 |
24 |
24 @param vcs reference to the Mercurial vcs object |
25 @param vcs reference to the Mercurial vcs object |
25 """ |
26 """ |
26 super().__init__(vcs) |
27 super().__init__(vcs) |
27 |
28 |
28 self.purgeListDialog = None |
29 self.purgeListDialog = None |
29 |
30 |
30 def shutdown(self): |
31 def shutdown(self): |
31 """ |
32 """ |
32 Public method used to shutdown the purge interface. |
33 Public method used to shutdown the purge interface. |
33 """ |
34 """ |
34 if self.purgeListDialog is not None: |
35 if self.purgeListDialog is not None: |
35 self.purgeListDialog.close() |
36 self.purgeListDialog.close() |
36 |
37 |
37 def __getEntries(self, deleteAll): |
38 def __getEntries(self, deleteAll): |
38 """ |
39 """ |
39 Private method to get a list of files/directories being purged. |
40 Private method to get a list of files/directories being purged. |
40 |
41 |
41 @param deleteAll flag indicating to delete all files including ignored |
42 @param deleteAll flag indicating to delete all files including ignored |
42 ones |
43 ones |
43 @type bool |
44 @type bool |
44 @return name of the current patch |
45 @return name of the current patch |
45 @rtype str |
46 @rtype str |
46 """ |
47 """ |
47 purgeEntries = [] |
48 purgeEntries = [] |
48 |
49 |
49 args = self.vcs.initCommand("purge") |
50 args = self.vcs.initCommand("purge") |
50 args.append("--print") |
51 args.append("--print") |
51 if deleteAll: |
52 if deleteAll: |
52 args.append("--all") |
53 args.append("--all") |
53 |
54 |
54 client = self.vcs.getClient() |
55 client = self.vcs.getClient() |
55 out, err = client.runcommand(args) |
56 out, err = client.runcommand(args) |
56 if out: |
57 if out: |
57 purgeEntries = out.strip().split() |
58 purgeEntries = out.strip().split() |
58 |
59 |
59 return purgeEntries |
60 return purgeEntries |
60 |
61 |
61 def hgPurge(self, deleteAll=False): |
62 def hgPurge(self, deleteAll=False): |
62 """ |
63 """ |
63 Public method to purge files and directories not tracked by Mercurial. |
64 Public method to purge files and directories not tracked by Mercurial. |
64 |
65 |
65 @param deleteAll flag indicating to delete all files including ignored |
66 @param deleteAll flag indicating to delete all files including ignored |
66 ones |
67 ones |
67 @type bool |
68 @type bool |
68 """ |
69 """ |
69 if deleteAll: |
70 if deleteAll: |
70 title = self.tr("Purge All Files") |
71 title = self.tr("Purge All Files") |
71 message = self.tr( |
72 message = self.tr( |
72 """Do really want to delete all files not tracked by""" |
73 """Do really want to delete all files not tracked by""" |
73 """ Mercurial (including ignored ones)?""") |
74 """ Mercurial (including ignored ones)?""" |
|
75 ) |
74 else: |
76 else: |
75 title = self.tr("Purge Files") |
77 title = self.tr("Purge Files") |
76 message = self.tr( |
78 message = self.tr( |
77 """Do really want to delete files not tracked by Mercurial?""") |
79 """Do really want to delete files not tracked by Mercurial?""" |
|
80 ) |
78 entries = self.__getEntries(deleteAll) |
81 entries = self.__getEntries(deleteAll) |
79 from UI.DeleteFilesConfirmationDialog import ( |
82 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
80 DeleteFilesConfirmationDialog |
83 |
81 ) |
|
82 dlg = DeleteFilesConfirmationDialog(None, title, message, entries) |
84 dlg = DeleteFilesConfirmationDialog(None, title, message, entries) |
83 if dlg.exec() == QDialog.DialogCode.Accepted: |
85 if dlg.exec() == QDialog.DialogCode.Accepted: |
84 args = self.vcs.initCommand("purge") |
86 args = self.vcs.initCommand("purge") |
85 if deleteAll: |
87 if deleteAll: |
86 args.append("--all") |
88 args.append("--all") |
87 args.append("-v") |
89 args.append("-v") |
88 |
90 |
89 dia = HgDialog(title, self.vcs) |
91 dia = HgDialog(title, self.vcs) |
90 res = dia.startProcess(args) |
92 res = dia.startProcess(args) |
91 if res: |
93 if res: |
92 dia.exec() |
94 dia.exec() |
93 |
95 |
94 def hgPurgeList(self, deleteAll=False): |
96 def hgPurgeList(self, deleteAll=False): |
95 """ |
97 """ |
96 Public method to list files and directories not tracked by Mercurial. |
98 Public method to list files and directories not tracked by Mercurial. |
97 |
99 |
98 @param deleteAll flag indicating to list all files including ignored |
100 @param deleteAll flag indicating to list all files including ignored |
99 ones (boolean) |
101 ones (boolean) |
100 """ |
102 """ |
101 entries = self.__getEntries(deleteAll) |
103 entries = self.__getEntries(deleteAll) |
102 from .HgPurgeListDialog import HgPurgeListDialog |
104 from .HgPurgeListDialog import HgPurgeListDialog |
|
105 |
103 self.purgeListDialog = HgPurgeListDialog(entries) |
106 self.purgeListDialog = HgPurgeListDialog(entries) |
104 self.purgeListDialog.show() |
107 self.purgeListDialog.show() |