1. André Sintzoff
  2. thg-sintzoff

Commits

Yuya Nishihara  committed 041b344

repotreemodel: detect subrepo from known items when adding repo

Now the model caches the list of subrepo items even if 'showSubrepos' is off,
it's better to not scan the filesystem implicitly.

  • Participants
  • Parent commits 9ee9227
  • Branches default

Comments (0)

Files changed (1)

File tortoisehg/hgqt/repotreemodel.py

View file
         root = os.path.normpath(root)
 
         # Check whether the repo that we are adding is a subrepo
-        # This check could be expensive, particularly for network repositories
-        # Thus, only perform this check on network repos if the showNetworkSubrepos
-        # flag is set
-        itemIsSubrepo = False
-        if self.showNetworkSubrepos \
-                or not paths.netdrive_status(root):
-            outerrepopath = paths.find_root(os.path.dirname(root))
-            if outerrepopath:
-                # Check whether repo we are adding is a subrepo of
-                # its containing (outer) repo
-                # This check is currently quite imperfect, since it
-                # only checks the current repo revision
-                outerrepo = hg.repository(ui.ui(), path=outerrepopath)
-                relroot = util.normpath(root[len(outerrepopath)+1:])
-                if relroot in outerrepo['.'].substate:
-                    itemIsSubrepo = True
+        knownitem = self.getRepoItem(root, lookForSubrepos=True)
+        itemIsSubrepo = isinstance(knownitem,
+                                   (repotreeitem.StandaloneSubrepoItem,
+                                    repotreeitem.SubrepoItem))
 
         self.beginInsertRows(parent, row, row)
         if itemIsSubrepo: