Changeset d3296bdae680…
Parent ca099a1a8019…
by
Changes to 4 files · Browse files at d3296bdae680 Showing diff from parent ca099a1a8019 Diff from another changeset...
@@ -180,9 +180,10 @@ showMessage = pyqtSignal(QString)
openRepo = pyqtSignal(QString, bool)
- def __init__(self, parent):
+ def __init__(self, parent, showSubrepos=True):
QDockWidget.__init__(self, parent)
-
+
+ self.showSubrepos = showSubrepos
self.setFeatures(QDockWidget.DockWidgetClosable |
QDockWidget.DockWidgetMovable |
QDockWidget.DockWidgetFloatable)
@@ -195,7 +196,8 @@
self.contextmenu = QMenu(self)
self.tview = tv = RepoTreeView(self)
- tv.setModel(repotreemodel.RepoTreeModel(settingsfilename(), self))
+ tv.setModel(repotreemodel.RepoTreeModel(settingsfilename(), self,
+ showSubrepos=self.showSubrepos))
mainframe.layout().addWidget(tv)
tv.setIndentation(10)
@@ -208,9 +210,15 @@
self.createActions()
QTimer.singleShot(0, self.expand)
+
+ def setShowSubrepos(self, show):
+ self.showSubrepos = show
+ self.reloadModel()
+
def reloadModel(self):
self.tview.setModel(
- repotreemodel.RepoTreeModel(settingsfilename(), self))
+ repotreemodel.RepoTreeModel(settingsfilename(), self,
+ self.showSubrepos))
self.expand()
def expand(self):
|
@@ -206,64 +206,67 @@ xw.writeAttribute('root', hglib.tounicode(self._root))
xw.writeAttribute('shortname', self.shortname())
xw.writeAttribute('basenode', node.hex(self.basenode()))
+
def undump(self, xr):
- self._valid = False # Will be set to True if everything goes fine
+ self._valid = True
a = xr.attributes()
self._root = hglib.fromunicode(a.value('', 'root').toString())
self._shortname = unicode(a.value('', 'shortname').toString())
self._basenode = node.bin(str(a.value('', 'basenode').toString()))
RepoTreeItem.undump(self, xr)
- def addSubrepos(ri, repo):
- invalidRepoList = []
+ if self.model.showSubrepos:
+ def addSubrepos(ri, repo):
+ invalidRepoList = []
+ try:
+ wctx = repo['.']
+ for subpath in wctx.substate:
+ # For now we only support showing mercurial subrepos
+ subtype = wctx.substate[subpath][2]
+ sctx = wctx.sub(subpath)
+ ri.appendChild(
+ SubrepoItem(self.model, sctx._repo.root, subtype=subtype))
+ if subtype == 'hg':
+ # Only recurse into mercurial subrepos
+ if ri.childCount():
+ invalidRepoList += \
+ addSubrepos(
+ ri.child(ri.childCount()-1), sctx._repo)
+ except (EnvironmentError, error.RepoError, util.Abort), e:
+ # Add the repo to the list of repos/subrepos
+ # that could not be open
+ invalidRepoList.append(repo.root)
+
+ return invalidRepoList
+
+ root = self.rootpath()
try:
- wctx = repo['.']
- for subpath in wctx.substate:
- # For now we only support showing mercurial subrepos
- subtype = wctx.substate[subpath][2]
- sctx = wctx.sub(subpath)
- ri.appendChild(
- SubrepoItem(self.model, sctx._repo.root, subtype=subtype))
- if subtype == 'hg':
- # Only recurse into mercurial subrepos
- if ri.childCount():
- invalidRepoList += \
- addSubrepos(
- ri.child(ri.childCount()-1), sctx._repo)
+ repo = hg.repository(ui.ui(), root)
except (EnvironmentError, error.RepoError, util.Abort), e:
- # Add the repo to the list of repos/subrepos
- # that could not be open
- invalidRepoList.append(repo.root)
+ # Do not try to show the list of subrepos when the top repository
+ # could not be open
+ # TODO: Mark the repo with a "warning" icon or similar to indicate
+ # that the repository cannot be open
+ self._valid = False
+ return
- return invalidRepoList
+ invalidRepoList = \
+ addSubrepos(self, repo)
+
+ if invalidRepoList:
+ self._valid = False
+ if invalidRepoList[0] == root:
+ qtlib.WarningMsgBox(_('Could not get subrepository list'),
+ _('It was not possible to get the subrepository list for '
+ 'the repository in:<br><br><i>%s</i>') % root)
+ else:
+ qtlib.WarningMsgBox(_('Could not open some subrepositories'),
+ _('It was not possible to fully load the subrepository list '
+ 'for the repository in:<br><br><i>%s</i><br><br>'
+ 'The following subrepositories could not be accessed:'
+ '<br><br><i>%s</i>') %
+ (root, "<br>".join(invalidRepoList)))
- root = self.rootpath()
- try:
- repo = hg.repository(ui.ui(), root)
- except (EnvironmentError, error.RepoError, util.Abort), e:
- # Do not try to show the list of subrepos when the top repository
- # could not be open
- # TODO: Mark the repo with a "warning" icon or similar to indicate
- # that the repository cannot be open
- return
-
- invalidRepoList = \
- addSubrepos(self, repo)
-
- if invalidRepoList:
- if invalidRepoList[0] == root:
- qtlib.WarningMsgBox(_('Could not get subrepository list'),
- _('It was not possible to get the subrepository list for '
- 'the repository in:<br><br><i>%s</i>') % root)
- else:
- qtlib.WarningMsgBox(_('Could not open some subrepositories'),
- _('It was not possible to fully load the subrepository list '
- 'for the repository in:<br><br><i>%s</i><br><br>'
- 'The following subrepositories could not be accessed:'
- '<br><br><i>%s</i>') %
- (root, "<br>".join(invalidRepoList)))
- else:
- self._valid = True
def details(self):
return _('Local Repository %s') % hglib.tounicode(self._root)
|
@@ -64,9 +64,11 @@
class RepoTreeModel(QAbstractItemModel):
- def __init__(self, filename, parent):
+ def __init__(self, filename, parent, showSubrepos=True):
QAbstractItemModel.__init__(self, parent)
-
+
+ self.showSubrepos=showSubrepos
+
root = None
all = None
@@ -228,6 +230,11 @@ row = rgi.childCount()
self.beginInsertRows(grp, row, row)
rgi.insertChild(row, RepoItem(self, root))
+
+ if not self.showSubrepos:
+ self.endInsertRows()
+ return
+
def addSubrepos(ri, repo):
invalidRepoList = []
try:
|
@@ -219,6 +219,10 @@ newaction(_("Show Paths"), self.reporegistry.showPaths,
checkable=True, menu='view')
+ self.actionShowSubrepos = \
+ newaction(_("Show Subrepos on Registry"), self.reporegistry.setShowSubrepos,
+ checkable=True, menu='view')
+
a = self.log.toggleViewAction()
a.setText(_('Show Output &Log'))
a.setShortcut('Ctrl+L')
@@ -744,6 +748,7 @@ s.setValue(wb + 'geometry', self.saveGeometry())
s.setValue(wb + 'windowState', self.saveState())
s.setValue(wb + 'showPaths', self.actionShowPaths.isChecked())
+ s.setValue(wb + 'showSubrepos', self.actionShowSubrepos.isChecked())
s.setValue(wb + 'saveRepos', self.actionSaveRepos.isChecked())
repostosave = []
if self.actionSaveRepos.isChecked():
@@ -765,6 +770,8 @@ # Allow repo registry to assemble itself before toggling path state
sp = s.value(wb + 'showPaths').toBool()
QTimer.singleShot(0, lambda: self.actionShowPaths.setChecked(sp))
+ ssr = s.value(wb + 'showSubrepos', defaultValue=QVariant(True)).toBool()
+ QTimer.singleShot(0, lambda: self.actionShowSubrepos.setChecked(ssr))
def goto(self, root, rev):
for rw in self._findrepowidget(root):
|
Loading...