diff mercurial/cmdutil.py @ 12175:c0a8f9dea0f6

subrepos: handle modified but uncommitted .hgsub
author Martin Geisler <mg@lazybytes.net>
date Tue, 07 Sep 2010 16:23:55 +0200
parents d2c5b0927c28
children ecab10820983
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Tue Sep 07 15:31:56 2010 +0200
+++ b/mercurial/cmdutil.py	Tue Sep 07 16:23:55 2010 +0200
@@ -682,10 +682,17 @@
 
     if listsubrepos:
         ctx1 = repo[node1]
-        for subpath in ctx1.substate:
-            sub = ctx1.sub(subpath)
+        ctx2 = repo[node2]
+        # 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 subpaths.iteritems():
+            sub = ctx.sub(subpath)
             if node2 is not None:
-                node2 = bin(repo[node2].substate[subpath][1])
+                node2 = bin(ctx2.substate[subpath][1])
             submatch = matchmod.narrowmatcher(subpath, match)
             sub.diff(diffopts, node2, submatch, changes=changes,
                      stat=stat, fp=fp, prefix=prefix)