66 |
63 |
67 @param name directory or file name (string) or list of directory |
64 @param name directory or file name (string) or list of directory |
68 or file names (list of string) |
65 or file names (list of string) |
69 @return flag indicating that the project should be reread (boolean) |
66 @return flag indicating that the project should be reread (boolean) |
70 """ |
67 """ |
71 if isinstance(name, list): |
|
72 dname = self.vcs.splitPathList(name)[0] |
|
73 else: |
|
74 dname = self.vcs.splitPath(name)[0] |
|
75 |
|
76 # find the root of the repo |
|
77 repodir = dname |
|
78 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
|
79 repodir = os.path.dirname(repodir) |
|
80 if os.path.splitdrive(repodir)[1] == os.sep: |
|
81 return False |
|
82 |
|
83 res = False |
68 res = False |
84 from .HgShelveDataDialog import HgShelveDataDialog |
69 from .HgShelveDataDialog import HgShelveDataDialog |
85 dlg = HgShelveDataDialog(self.vcs.version) |
70 dlg = HgShelveDataDialog(self.vcs.version) |
86 if dlg.exec() == QDialog.Accepted: |
71 if dlg.exec() == QDialog.Accepted: |
87 shelveName, dateTime, message, addRemove, keep = dlg.getData() |
72 shelveName, dateTime, message, addRemove, keep = dlg.getData() |
106 self.vcs.addArguments(args, name) |
91 self.vcs.addArguments(args, name) |
107 else: |
92 else: |
108 args.append(name) |
93 args.append(name) |
109 |
94 |
110 dia = HgDialog(self.tr('Shelve current changes'), self.vcs) |
95 dia = HgDialog(self.tr('Shelve current changes'), self.vcs) |
111 res = dia.startProcess(args, repodir) |
96 res = dia.startProcess(args) |
112 if res: |
97 if res: |
113 dia.exec() |
98 dia.exec() |
114 res = dia.hasAddOrDelete() |
99 res = dia.hasAddOrDelete() |
115 self.vcs.checkVCSStatus() |
100 self.vcs.checkVCSStatus() |
116 return res |
101 return res |
117 |
102 |
118 def hgShelveBrowser(self, projectDir): |
103 def hgShelveBrowser(self): |
119 """ |
104 """ |
120 Public method to show the shelve browser dialog. |
105 Public method to show the shelve browser dialog. |
121 |
|
122 @param projectDir name of the project directory (string) |
|
123 """ |
106 """ |
124 if self.__shelveBrowserDialog is None: |
107 if self.__shelveBrowserDialog is None: |
125 from .HgShelveBrowserDialog import HgShelveBrowserDialog |
108 from .HgShelveBrowserDialog import HgShelveBrowserDialog |
126 self.__shelveBrowserDialog = HgShelveBrowserDialog( |
109 self.__shelveBrowserDialog = HgShelveBrowserDialog( |
127 self.vcs) |
110 self.vcs) |
128 self.__shelveBrowserDialog.show() |
111 self.__shelveBrowserDialog.show() |
129 self.__shelveBrowserDialog.start(projectDir) |
112 self.__shelveBrowserDialog.start() |
130 |
113 |
131 def hgUnshelve(self, name, shelveName=""): |
114 def hgUnshelve(self, shelveName=""): |
132 """ |
115 """ |
133 Public method to restore shelved changes to the project directory. |
116 Public method to restore shelved changes to the project directory. |
134 |
117 |
135 @param name name of the project directory (string) |
118 @param shelveName name of the shelve to restore (string) |
136 @keyparam shelveName name of the shelve to restore (string) |
119 @return flag indicating that the project should be reread (boolean) |
137 @return flag indicating that the project should be reread (boolean) |
120 """ |
138 """ |
|
139 # find the root of the repo |
|
140 repodir = name |
|
141 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
|
142 repodir = os.path.dirname(repodir) |
|
143 if os.path.splitdrive(repodir)[1] == os.sep: |
|
144 return False |
|
145 |
|
146 res = False |
121 res = False |
147 from .HgUnshelveDataDialog import HgUnshelveDataDialog |
122 from .HgUnshelveDataDialog import HgUnshelveDataDialog |
148 dlg = HgUnshelveDataDialog(self.__hgGetShelveNamesList(repodir), |
123 dlg = HgUnshelveDataDialog(self.__hgGetShelveNamesList(), |
149 shelveName=shelveName) |
124 shelveName=shelveName) |
150 if dlg.exec() == QDialog.Accepted: |
125 if dlg.exec() == QDialog.Accepted: |
151 shelveName, keep = dlg.getData() |
126 shelveName, keep = dlg.getData() |
152 self.__unshelveKeep = keep # store for potential continue |
127 self.__unshelveKeep = keep # store for potential continue |
153 |
128 |
156 args.append("--keep") |
131 args.append("--keep") |
157 if shelveName: |
132 if shelveName: |
158 args.append(shelveName) |
133 args.append(shelveName) |
159 |
134 |
160 dia = HgDialog(self.tr('Restore shelved changes'), self.vcs) |
135 dia = HgDialog(self.tr('Restore shelved changes'), self.vcs) |
161 res = dia.startProcess(args, repodir) |
136 res = dia.startProcess(args) |
162 if res: |
137 if res: |
163 dia.exec() |
138 dia.exec() |
164 res = dia.hasAddOrDelete() |
139 res = dia.hasAddOrDelete() |
165 self.vcs.checkVCSStatus() |
140 self.vcs.checkVCSStatus() |
166 return res |
141 return res |
167 |
142 |
168 def hgUnshelveAbort(self, name): |
143 def hgUnshelveAbort(self): |
169 """ |
144 """ |
170 Public method to abort the ongoing restore operation. |
145 Public method to abort the ongoing restore operation. |
171 |
146 |
172 @param name name of the project directory (string) |
147 @return flag indicating that the project should be reread (boolean) |
173 @return flag indicating that the project should be reread (boolean) |
148 """ |
174 """ |
|
175 # find the root of the repo |
|
176 repodir = name |
|
177 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
|
178 repodir = os.path.dirname(repodir) |
|
179 if os.path.splitdrive(repodir)[1] == os.sep: |
|
180 return False |
|
181 |
|
182 args = self.vcs.initCommand("unshelve") |
149 args = self.vcs.initCommand("unshelve") |
183 args.append("--abort") |
150 args.append("--abort") |
184 |
151 |
185 dia = HgDialog(self.tr('Abort restore operation'), self.vcs) |
152 dia = HgDialog(self.tr('Abort restore operation'), self.vcs) |
186 res = dia.startProcess(args, repodir) |
153 res = dia.startProcess(args) |
187 if res: |
154 if res: |
188 dia.exec() |
155 dia.exec() |
189 res = dia.hasAddOrDelete() |
156 res = dia.hasAddOrDelete() |
190 self.vcs.checkVCSStatus() |
157 self.vcs.checkVCSStatus() |
191 return res |
158 return res |
192 |
159 |
193 def hgUnshelveContinue(self, name): |
160 def hgUnshelveContinue(self): |
194 """ |
161 """ |
195 Public method to continue the ongoing restore operation. |
162 Public method to continue the ongoing restore operation. |
196 |
163 |
197 @param name name of the project directory (string) |
164 @return flag indicating that the project should be reread (boolean) |
198 @return flag indicating that the project should be reread (boolean) |
165 """ |
199 """ |
|
200 # find the root of the repo |
|
201 repodir = name |
|
202 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
|
203 repodir = os.path.dirname(repodir) |
|
204 if os.path.splitdrive(repodir)[1] == os.sep: |
|
205 return False |
|
206 |
|
207 args = self.vcs.initCommand("unshelve") |
166 args = self.vcs.initCommand("unshelve") |
208 if self.__unshelveKeep: |
167 if self.__unshelveKeep: |
209 args.append("--keep") |
168 args.append("--keep") |
210 args.append("--continue") |
169 args.append("--continue") |
211 |
170 |
212 dia = HgDialog(self.tr('Continue restore operation'), self.vcs) |
171 dia = HgDialog(self.tr('Continue restore operation'), self.vcs) |
213 res = dia.startProcess(args, repodir) |
172 res = dia.startProcess(args) |
214 if res: |
173 if res: |
215 dia.exec() |
174 dia.exec() |
216 res = dia.hasAddOrDelete() |
175 res = dia.hasAddOrDelete() |
217 self.vcs.checkVCSStatus() |
176 self.vcs.checkVCSStatus() |
218 return res |
177 return res |
219 |
178 |
220 def hgDeleteShelves(self, name, shelveNames=None): |
179 def hgDeleteShelves(self, shelveNames=None): |
221 """ |
180 """ |
222 Public method to delete named shelves. |
181 Public method to delete named shelves. |
223 |
182 |
224 @param name name of the project directory (string) |
|
225 @param shelveNames name of shelves to delete (list of string) |
183 @param shelveNames name of shelves to delete (list of string) |
226 """ |
184 """ |
227 # find the root of the repo |
|
228 repodir = name |
|
229 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
|
230 repodir = os.path.dirname(repodir) |
|
231 if os.path.splitdrive(repodir)[1] == os.sep: |
|
232 return |
|
233 |
|
234 if not shelveNames: |
185 if not shelveNames: |
235 from .HgShelvesSelectionDialog import HgShelvesSelectionDialog |
186 from .HgShelvesSelectionDialog import HgShelvesSelectionDialog |
236 dlg = HgShelvesSelectionDialog( |
187 dlg = HgShelvesSelectionDialog( |
237 self.tr("Select the shelves to be deleted:"), |
188 self.tr("Select the shelves to be deleted:"), |
238 self.__hgGetShelveNamesList(repodir)) |
189 self.__hgGetShelveNamesList()) |
239 if dlg.exec() == QDialog.Accepted: |
190 if dlg.exec() == QDialog.Accepted: |
240 shelveNames = dlg.getSelectedShelves() |
191 shelveNames = dlg.getSelectedShelves() |
241 else: |
192 else: |
242 return |
193 return |
243 |
194 |
253 args = self.vcs.initCommand("shelve") |
204 args = self.vcs.initCommand("shelve") |
254 args.append("--delete") |
205 args.append("--delete") |
255 args.extend(shelveNames) |
206 args.extend(shelveNames) |
256 |
207 |
257 dia = HgDialog(self.tr('Delete shelves'), self.vcs) |
208 dia = HgDialog(self.tr('Delete shelves'), self.vcs) |
258 res = dia.startProcess(args, repodir) |
209 res = dia.startProcess(args) |
259 if res: |
210 if res: |
260 dia.exec() |
211 dia.exec() |
261 |
212 |
262 def hgCleanupShelves(self, name): |
213 def hgCleanupShelves(self): |
263 """ |
214 """ |
264 Public method to delete all shelves. |
215 Public method to delete all shelves. |
265 |
216 """ |
266 @param name name of the project directory (string) |
|
267 """ |
|
268 # find the root of the repo |
|
269 repodir = name |
|
270 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
|
271 repodir = os.path.dirname(repodir) |
|
272 if os.path.splitdrive(repodir)[1] == os.sep: |
|
273 return |
|
274 |
|
275 res = E5MessageBox.yesNo( |
217 res = E5MessageBox.yesNo( |
276 None, |
218 None, |
277 self.tr("Delete all shelves"), |
219 self.tr("Delete all shelves"), |
278 self.tr("""Do you really want to delete all shelved changes?""")) |
220 self.tr("""Do you really want to delete all shelved changes?""")) |
279 if res: |
221 if res: |
280 args = self.vcs.initCommand("shelve") |
222 args = self.vcs.initCommand("shelve") |
281 args.append("--cleanup") |
223 args.append("--cleanup") |
282 |
224 |
283 dia = HgDialog(self.tr('Delete all shelves'), self.vcs) |
225 dia = HgDialog(self.tr('Delete all shelves'), self.vcs) |
284 res = dia.startProcess(args, repodir) |
226 res = dia.startProcess(args) |
285 if res: |
227 if res: |
286 dia.exec() |
228 dia.exec() |