Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1, 2.1.1, and 2.1.2

reporegistry: hoist repository add logic up into reporegistry.py

Changeset a7da21fb820c

Parent 12da60da0b10

by Steve Borho

Changes to 2 files · Browse files at a7da21fb820c Showing diff from parent 12da60da0b10 Diff from another changeset...

 
212
213
214
 
215
216
217
218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
220
221
 
258
259
260
 
261
262
263
264
265
 
266
267
268
 
212
213
214
215
216
217
 
 
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
 
274
275
276
277
278
279
280
281
282
283
284
285
286
@@ -212,10 +212,26 @@
  qtlib.openshell(root)     def addRepo(self): + 'menu action handler for adding a new repository'   if not self.selitem:   return - m = self.model() - m.addRepo(self.selitem, None) + caption = _('Select repository directory to add') + FD = QFileDialog + path = FD.getExistingDirectory(caption=caption, + options=FD.ShowDirsOnly | FD.ReadOnly) + if path: + try: + lpath = hglib.fromunicode(path) + repo = thgrepo.repository(None, path=lpath) + self.model().addRepo(self.selitem, repo) + except error.RepoError: + # NOTE: here we cannot pass parent=self because self + # isn't a QWidget. Codes under `if not repo:` should + # be handled by a widget, not by a model. + qtlib.WarningMsgBox( + _('Failed to add repository'), + _('%s is not a valid repository') % path) + return     def sizeHint(self):   size = super(RepoTreeView, self).sizeHint() @@ -258,11 +274,13 @@
  self.tview.expandToDepth(0)     def addRepo(self, repo): + 'workbench has opened a new repowidget, ensure its in the registry'   m = self.tmodel   it = m.getRepoItem(repo.root)   if it == None:   m.addRepo(None, repo)   else: + # ensure the registry item has a thgrepo instance   it.ensureRepoLoaded()     def openRepo(self, path, reuse=False):
 
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
 
204
205
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
208
209
@@ -204,25 +204,6 @@
  return self.createIndex(0, 0, self.allrepos)     def addRepo(self, group, repo): - if not repo: - caption = _('Select repository directory to add') - FD = QFileDialog - path = FD.getExistingDirectory(caption=caption, - options=FD.ShowDirsOnly | FD.ReadOnly) - if path: - try: - lpath = hglib.fromunicode(path) - repo = thgrepo.repository(None, path=lpath) - except error.RepoError: - # NOTE: here we cannot pass parent=self because self - # isn't a QWidget. Codes under `if not repo:` should - # be handled by a widget, not by a model. - qtlib.WarningMsgBox( - _('Failed to add repository'), - _('%s is not a valid repository') % path) - return - else: - return   grp = group   if grp == None:   grp = self.allreposIndex()