Commits

Yuya Nishihara committed 8516a2c

manifestmodel: tidy up code to look up hg subrepo recursively

As it knows subrepo kind, isinstance() is not necessary.

Comments (0)

Files changed (1)

tortoisehg/hgqt/manifestmodel.py

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
-from mercurial import subrepo, util
+from mercurial import util
 
 from tortoisehg.util import hglib
 from tortoisehg.hgqt import qtlib, status, visdiff
             e.status = 'S'
             e.subkind = substate[2]
 
-            # If the subrepo exists in the working directory
-            # and it is a mercurial subrepo,
-            # add the files that it contains to the tree as well, according
-            # to the status filter
             abspath = os.path.join(ctx._repo.root, path)
-            if os.path.isdir(abspath):
-                srev = substate[1]
-                sub = ctx.sub(path)
-                if srev and isinstance(sub, subrepo.hgsubrepo):
-                    srepo = sub._repo
-                    if srev in srepo:
-                        e.ctx = srepo[srev]
-                        # Add the subrepo contents to the tree
-                        addrepocontentstotree(e)
+            if e.subkind != 'hg' or not os.path.isdir(abspath):
+                continue
+            srev = substate[1]
+            srepo = ctx.sub(path)._repo
+            if srev in srepo:
+                e.ctx = srepo[srev]
+                addrepocontentstotree(e)
 
     def addrepocontentstotree(roote):
         if 'S' in statusfilter:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.