mercurial/scmutil.py
changeset 20392 d4f804caa0ed
parent 20364 a6cf48b2880d
child 20526 9ad6dae67845
--- a/mercurial/scmutil.py	Fri Feb 07 02:59:46 2014 +0100
+++ b/mercurial/scmutil.py	Mon Feb 03 18:36:00 2014 -0500
@@ -20,6 +20,16 @@
 systemrcpath = scmplatform.systemrcpath
 userrcpath = scmplatform.userrcpath
 
+def itersubrepos(ctx1, ctx2):
+    """find subrepos in ctx1 or ctx2"""
+    # Create a (subpath, ctx) mapping where we prefer subpaths from
+    # ctx1. The subpaths from ctx2 are important when the .hgsub file
+    # has been modified (in ctx2) but not yet committed (in ctx1).
+    subpaths = dict.fromkeys(ctx2.substate, ctx2)
+    subpaths.update(dict.fromkeys(ctx1.substate, ctx1))
+    for subpath, ctx in sorted(subpaths.iteritems()):
+        yield subpath, ctx.sub(subpath)
+
 def nochangesfound(ui, repo, excluded=None):
     '''Report no changes for push/pull, excluded is None or a list of
     nodes excluded from the push/pull.