Changeset a7da21fb820c…
Parent 12da60da0b10…
by
Changes to 2 files · Browse files at a7da21fb820c Showing diff from parent 12da60da0b10 Diff from another changeset...
@@ -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,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()
|
Loading...