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

reporegistry: add "Show Subrepos on Registry" toggle to the View menu

Changeset d3296bdae680

Parent ca099a1a8019

by Angel Ezquerra

Changes to 4 files · Browse files at d3296bdae680 Showing diff from parent ca099a1a8019 Diff from another changeset...

 
180
181
182
183
 
184
185
 
 
186
187
188
 
195
196
197
198
 
 
199
200
201
 
208
209
210
 
 
 
 
 
211
212
213
 
 
214
215
216
 
180
181
182
 
183
184
 
185
186
187
188
189
 
196
197
198
 
199
200
201
202
203
 
210
211
212
213
214
215
216
217
218
219
 
220
221
222
223
224
@@ -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
207
208
 
209
210
 
211
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
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
 
206
207
208
209
210
 
211
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
238
239
240
241
242
243
 
 
 
 
 
 
 
 
 
 
 
 
 
244
245
 
 
 
246
247
248
249
250
251
252
 
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
271
272
@@ -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
65
66
67
 
68
69
 
 
 
70
71
72
 
228
229
230
 
 
 
 
 
231
232
233
 
64
65
66
 
67
68
 
69
70
71
72
73
74
 
230
231
232
233
234
235
236
237
238
239
240
@@ -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
220
221
 
 
 
 
222
223
224
 
744
745
746
 
747
748
749
 
765
766
767
 
 
768
769
770
 
219
220
221
222
223
224
225
226
227
228
 
748
749
750
751
752
753
754
 
770
771
772
773
774
775
776
777
@@ -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):