subrepos: handle diff nodeids in subrepos, not before
authorPatrick Mezard <pmezard@gmail.com>
Fri, 10 Sep 2010 22:52:00 +0200
changeset 12209 affec9fb56ef
parent 12208 482443557cad
child 12210 21eb85e9ea94
subrepos: handle diff nodeids in subrepos, not before Subversion nodeids are integer revisions.
mercurial/cmdutil.py
mercurial/subrepo.py
tests/test-subrepo-svn.t
--- a/mercurial/cmdutil.py	Fri Sep 10 22:36:04 2010 +0200
+++ b/mercurial/cmdutil.py	Fri Sep 10 22:52:00 2010 +0200
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-from node import hex, bin, nullid, nullrev, short
+from node import hex, nullid, nullrev, short
 from i18n import _
 import os, sys, errno, re, glob, tempfile
 import util, templater, patch, error, encoding, templatekw
@@ -685,7 +685,7 @@
         ctx2 = repo[node2]
         for subpath, sub in subrepo.itersubrepos(ctx1, ctx2):
             if node2 is not None:
-                node2 = bin(ctx2.substate[subpath][1])
+                node2 = ctx2.substate[subpath][1]
             submatch = matchmod.narrowmatcher(subpath, match)
             sub.diff(diffopts, node2, submatch, changes=changes,
                      stat=stat, fp=fp, prefix=prefix)
--- a/mercurial/subrepo.py	Fri Sep 10 22:36:04 2010 +0200
+++ b/mercurial/subrepo.py	Fri Sep 10 22:52:00 2010 +0200
@@ -305,6 +305,9 @@
     def diff(self, diffopts, node2, match, prefix, **opts):
         try:
             node1 = node.bin(self._state[1])
+            # We currently expect node2 to come from substate and be
+            # in hex format
+            node2 = node.bin(node2)
             cmdutil.diffordiffstat(self._repo.ui, self._repo, diffopts,
                                    node1, node2, match,
                                    prefix=os.path.join(prefix, self._path),
--- a/tests/test-subrepo-svn.t	Fri Sep 10 22:36:04 2010 +0200
+++ b/tests/test-subrepo-svn.t	Fri Sep 10 22:52:00 2010 +0200
@@ -153,6 +153,17 @@
   $ hg ci -m 'amend externals from hg'
   committing subrepository s
   abort: cannot commit svn externals
+  $ hg diff --subrepos -r 1:2 | grep -v diff
+  --- a/.hgsubstate	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/.hgsubstate	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -2 s
+  +3 s
+  --- a/a	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,2 @@
+   a
+  +a
   $ svn revert -q s/externals/other
 
 this commit fails because of externals meta changes