12 from PyQt4.QtCore import QProcess |
12 from PyQt4.QtCore import QProcess |
13 from PyQt4.QtGui import QDialog |
13 from PyQt4.QtGui import QDialog |
14 |
14 |
15 from ..HgExtension import HgExtension |
15 from ..HgExtension import HgExtension |
16 from ..HgDialog import HgDialog |
16 from ..HgDialog import HgDialog |
17 |
|
18 import Preferences |
|
19 |
17 |
20 |
18 |
21 class Purge(HgExtension): |
19 class Purge(HgExtension): |
22 """ |
20 """ |
23 Class implementing the purge extension interface. |
21 Class implementing the purge extension interface. |
48 (boolean) |
46 (boolean) |
49 @return name of the current patch (string) |
47 @return name of the current patch (string) |
50 """ |
48 """ |
51 purgeEntries = [] |
49 purgeEntries = [] |
52 |
50 |
53 args = [] |
51 args = self.vcs.initCommand("purge") |
54 args.append("purge") |
|
55 args.append("--print") |
52 args.append("--print") |
56 if all: |
53 if all: |
57 args.append("--all") |
54 args.append("--all") |
58 |
55 |
59 client = self.vcs.getClient() |
56 client = self.vcs.getClient() |
60 if client: |
57 if client: |
61 out, err = client.runcommand(args) |
58 out, err = client.runcommand(args) |
62 if out: |
59 if out: |
63 purgeEntries = out.strip().split() |
60 purgeEntries = out.strip().split() |
64 else: |
61 else: |
65 ioEncoding = Preferences.getSystem("IOEncoding") |
|
66 process = QProcess() |
62 process = QProcess() |
67 process.setWorkingDirectory(repodir) |
63 process.setWorkingDirectory(repodir) |
68 process.start('hg', args) |
64 process.start('hg', args) |
69 procStarted = process.waitForStarted(5000) |
65 procStarted = process.waitForStarted(5000) |
70 if procStarted: |
66 if procStarted: |
71 finished = process.waitForFinished(30000) |
67 finished = process.waitForFinished(30000) |
72 if finished and process.exitCode() == 0: |
68 if finished and process.exitCode() == 0: |
73 purgeEntries = str( |
69 purgeEntries = str( |
74 process.readAllStandardOutput(), |
70 process.readAllStandardOutput(), |
75 ioEncoding, 'replace').strip().split() |
71 self.vcs.getEncoding(), 'replace').strip().split() |
76 |
72 |
77 return purgeEntries |
73 return purgeEntries |
78 |
74 |
79 def hgPurge(self, name, all=False): |
75 def hgPurge(self, name, all=False): |
80 """ |
76 """ |
103 entries = self.__getEntries(repodir, all) |
99 entries = self.__getEntries(repodir, all) |
104 from UI.DeleteFilesConfirmationDialog import \ |
100 from UI.DeleteFilesConfirmationDialog import \ |
105 DeleteFilesConfirmationDialog |
101 DeleteFilesConfirmationDialog |
106 dlg = DeleteFilesConfirmationDialog(None, title, message, entries) |
102 dlg = DeleteFilesConfirmationDialog(None, title, message, entries) |
107 if dlg.exec_() == QDialog.Accepted: |
103 if dlg.exec_() == QDialog.Accepted: |
108 args = [] |
104 args = self.vcs.initCommand("purge") |
109 args.append("purge") |
|
110 if all: |
105 if all: |
111 args.append("--all") |
106 args.append("--all") |
112 args.append("-v") |
107 args.append("-v") |
113 |
108 |
114 dia = HgDialog(title, self.vcs) |
109 dia = HgDialog(title, self.vcs) |