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

reporegistry: catch errors when loading the subrepository list

Changeset 80de2e54f749

Parent 1e69cbcfa08e

by Angel Ezquerra

Changes to 2 files · Browse files at 80de2e54f749 Showing diff from parent 1e69cbcfa08e Diff from another changeset...

 
205
206
207
208
209
210
211
212
213
214
215
216
217
218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
222
223
 
205
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
@@ -205,19 +205,44 @@
  RepoTreeItem.undump(self, xr)     def addSubrepos(ri, repo): - 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(): - addSubrepos(ri.child(ri.childCount()-1), sctx._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   - addSubrepos(self, hg.repository(ui.ui(), self.rootpath())) + root = self.rootpath() + invalidRepoList = \ + addSubrepos(self, hg.repository(ui.ui(), root)) + + 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)))     def details(self):   return _('Local Repository %s') % hglib.tounicode(self._root)
 
5
6
7
 
 
8
9
 
10
11
12
 
226
227
228
229
230
231
232
233
234
235
236
237
238
239
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
241
 
 
242
243
 
 
244
 
 
 
 
 
 
 
 
 
 
 
 
 
245
246
247
 
5
6
7
8
9
10
11
12
13
14
15
 
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
273
@@ -5,8 +5,11 @@
 # This software may be used and distributed according to the terms of the  # GNU General Public License version 2 or any later version.   +from mercurial import ui, hg, util, error +  from tortoisehg.util import hglib  from tortoisehg.hgqt.i18n import _ +from tortoisehg.hgqt import qtlib  from tortoisehg.hgqt import thgrepo    from repotreeitem import undumpObject, AllRepoGroupItem, RepoGroupItem @@ -226,22 +229,45 @@
  self.beginInsertRows(grp, row, row)   rgi.insertChild(row, RepoItem(self, root))   def addSubrepos(ri, repo): - 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.insertChild(row, - SubrepoItem(self, sctx._repo.root, subtype=subtype)) - if subtype == 'hg': - # Only recurse into mercurial subrepos - if ri.childCount(): - addSubrepos(ri.child(ri.childCount()-1), sctx._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.insertChild(row, + SubrepoItem(self, 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)   - from mercurial import ui, hg + return invalidRepoList +   repo = hg.repository(ui.ui(), root) - addSubrepos(rgi.child(rgi.childCount()-1), repo) + invalidRepoList = \ + addSubrepos(rgi.child(rgi.childCount()-1), repo)   self.endInsertRows() + + 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)))     def getRepoItem(self, reporoot):   return self.rootItem.getRepoItem(reporoot)