Plugins/VcsPlugins/vcsMercurial/PurgeExtension/purge.py

changeset 5588
6ba512d9f46a
parent 5587
ea526b78ee6c
child 5624
cdd346d8858b
equal deleted inserted replaced
5587:ea526b78ee6c 5588:6ba512d9f46a
41 Public method used to shutdown the purge interface. 41 Public method used to shutdown the purge interface.
42 """ 42 """
43 if self.purgeListDialog is not None: 43 if self.purgeListDialog is not None:
44 self.purgeListDialog.close() 44 self.purgeListDialog.close()
45 45
46 def __getEntries(self, repodir, all): 46 def __getEntries(self, repodir, deleteAll):
47 """ 47 """
48 Private method to get a list of files/directories being purged. 48 Private method to get a list of files/directories being purged.
49 49
50 @param repodir directory name of the repository (string) 50 @param repodir directory name of the repository (string)
51 @param all flag indicating to delete all files including ignored ones 51 @param deleteAll flag indicating to delete all files including ignored
52 (boolean) 52 ones (boolean)
53 @return name of the current patch (string) 53 @return name of the current patch (string)
54 """ 54 """
55 purgeEntries = [] 55 purgeEntries = []
56 56
57 args = self.vcs.initCommand("purge") 57 args = self.vcs.initCommand("purge")
58 args.append("--print") 58 args.append("--print")
59 if all: 59 if deleteAll:
60 args.append("--all") 60 args.append("--all")
61 61
62 client = self.vcs.getClient() 62 client = self.vcs.getClient()
63 if client: 63 if client:
64 out, err = client.runcommand(args) 64 out, err = client.runcommand(args)
76 process.readAllStandardOutput(), 76 process.readAllStandardOutput(),
77 self.vcs.getEncoding(), 'replace').strip().split() 77 self.vcs.getEncoding(), 'replace').strip().split()
78 78
79 return purgeEntries 79 return purgeEntries
80 80
81 def hgPurge(self, name, all=False): 81 def hgPurge(self, name, deleteAll=False):
82 """ 82 """
83 Public method to purge files and directories not tracked by Mercurial. 83 Public method to purge files and directories not tracked by Mercurial.
84 84
85 @param name file/directory name (string) 85 @param name file/directory name (string)
86 @param all flag indicating to delete all files including ignored ones 86 @param deleteAll flag indicating to delete all files including ignored
87 (boolean) 87 ones (boolean)
88 """ 88 """
89 # find the root of the repo 89 # find the root of the repo
90 repodir = self.vcs.splitPath(name)[0] 90 repodir = self.vcs.splitPath(name)[0]
91 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 91 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
92 repodir = os.path.dirname(repodir) 92 repodir = os.path.dirname(repodir)
93 if os.path.splitdrive(repodir)[1] == os.sep: 93 if os.path.splitdrive(repodir)[1] == os.sep:
94 return 94 return
95 95
96 if all: 96 if deleteAll:
97 title = self.tr("Purge All Files") 97 title = self.tr("Purge All Files")
98 message = self.tr( 98 message = self.tr(
99 """Do really want to delete all files not tracked by""" 99 """Do really want to delete all files not tracked by"""
100 """ Mercurial (including ignored ones)?""") 100 """ Mercurial (including ignored ones)?""")
101 else: 101 else:
102 title = self.tr("Purge Files") 102 title = self.tr("Purge Files")
103 message = self.tr( 103 message = self.tr(
104 """Do really want to delete files not tracked by Mercurial?""") 104 """Do really want to delete files not tracked by Mercurial?""")
105 entries = self.__getEntries(repodir, all) 105 entries = self.__getEntries(repodir, deleteAll)
106 from UI.DeleteFilesConfirmationDialog import \ 106 from UI.DeleteFilesConfirmationDialog import \
107 DeleteFilesConfirmationDialog 107 DeleteFilesConfirmationDialog
108 dlg = DeleteFilesConfirmationDialog(None, title, message, entries) 108 dlg = DeleteFilesConfirmationDialog(None, title, message, entries)
109 if dlg.exec_() == QDialog.Accepted: 109 if dlg.exec_() == QDialog.Accepted:
110 args = self.vcs.initCommand("purge") 110 args = self.vcs.initCommand("purge")
111 if all: 111 if deleteAll:
112 args.append("--all") 112 args.append("--all")
113 args.append("-v") 113 args.append("-v")
114 114
115 dia = HgDialog(title, self.vcs) 115 dia = HgDialog(title, self.vcs)
116 res = dia.startProcess(args, repodir) 116 res = dia.startProcess(args, repodir)
117 if res: 117 if res:
118 dia.exec_() 118 dia.exec_()
119 119
120 def hgPurgeList(self, name, all=False): 120 def hgPurgeList(self, name, deleteAll=False):
121 """ 121 """
122 Public method to list files and directories not tracked by Mercurial. 122 Public method to list files and directories not tracked by Mercurial.
123 123
124 @param name file/directory name (string) 124 @param name file/directory name (string)
125 @param all flag indicating to list all files including ignored ones 125 @param deleteAll flag indicating to list all files including ignored
126 (boolean) 126 ones (boolean)
127 """ 127 """
128 # find the root of the repo 128 # find the root of the repo
129 repodir = self.vcs.splitPath(name)[0] 129 repodir = self.vcs.splitPath(name)[0]
130 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 130 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
131 repodir = os.path.dirname(repodir) 131 repodir = os.path.dirname(repodir)
132 if os.path.splitdrive(repodir)[1] == os.sep: 132 if os.path.splitdrive(repodir)[1] == os.sep:
133 return 133 return
134 134
135 entries = self.__getEntries(repodir, all) 135 entries = self.__getEntries(repodir, deleteAll)
136 from .HgPurgeListDialog import HgPurgeListDialog 136 from .HgPurgeListDialog import HgPurgeListDialog
137 self.purgeListDialog = HgPurgeListDialog(entries) 137 self.purgeListDialog = HgPurgeListDialog(entries)
138 self.purgeListDialog.show() 138 self.purgeListDialog.show()

eric ide

mercurial