[PATCH 1 of 1] subrepo: correct revision in svn checkout

Carter, Eli Eli.Carter at tektronix.com
Thu Jun 30 13:27:43 CDT 2011


subrepo: correct revision in svn checkout

A Subversion subrepo checkout uses a url and --revision which does not do the correct thing when specifying a revision of a branch that has since been deleted and recreated.  The checkout needs to specify the revision as URL at REV instead.

This patch contains both a testcase demonstrating the bug, and a fix for the bug.

# HG changeset patch
# User Eli Carter <eli.carter at tektronix.com>
# Date 1309458132 18000
# Branch stable
# Node ID 190c40e31796a103f03edfd0267e0af683429a78
# Parent  7ba7459875cb139ab996412b99d4a6c9dec0041f
subrepo: correct revision in svn checkout

A Subversion subrepo checkout uses a url and --revision which does not do the
correct thing when specifying a revision of a branch that has since been
deleted and recreated.  The checkout needs to specify the revision as URL at REV
instead.

diff -r 7ba7459875cb -r 190c40e31796 mercurial/subrepo.py
--- a/mercurial/subrepo.py	Wed Jun 29 16:05:41 2011 -0500
+++ b/mercurial/subrepo.py	Thu Jun 30 13:22:12 2011 -0500
@@ -663,7 +663,9 @@
         args = ['checkout']
         if self._svnversion >= (1, 5):
             args.append('--force')
-        args.extend([state[0], '--revision', state[1]])
+        # The revision must be specified at the end of the URL to properly
+        # update to a directory which has since been deleted and recreated.
+        args.append('%s@%s' % (state[0], state[1]))
         status, err = self._svncommand(args, failok=True)
         if not re.search('Checked out revision [0-9]+.', status):
             if ('is already a working copy for a different URL' in err
diff -r 7ba7459875cb -r 190c40e31796 tests/test-subrepo-svn.t
--- a/tests/test-subrepo-svn.t	Wed Jun 29 16:05:41 2011 -0500
+++ b/tests/test-subrepo-svn.t	Thu Jun 30 13:22:12 2011 -0500
@@ -519,3 +519,67 @@
   $ hg co tip
   abort: crosses branches (merge branches or use --clean to discard changes)
   [255]
+
+Point to a Subversion branch which has since been deleted and recreated
+First, create that condition in the repository.
+
+  $ hg ci -m cleanup
+  committing subrepository obstruct
+  Sending        obstruct/other
+  Transmitting file data .
+  Committed revision 7.
+  At revision 7.
+  $ svn mkdir -m "baseline" $SVNREPO/trunk
+  
+  Committed revision 8.
+  $ svn copy -m "initial branch" $SVNREPO/trunk $SVNREPO/branch
+  
+  Committed revision 9.
+  $ svn co --quiet "$SVNREPO"/branch tempwc
+  $ cd tempwc
+  $ echo "something old" > somethingold
+  $ svn add somethingold
+  A         somethingold
+  $ svn ci -m 'Something old'
+  Adding         somethingold
+  Transmitting file data .
+  Committed revision 10.
+  $ svn rm -m "remove branch" $SVNREPO/branch
+  
+  Committed revision 11.
+  $ svn copy -m "recreate branch" $SVNREPO/trunk $SVNREPO/branch
+  
+  Committed revision 12.
+  $ svn up
+  D    somethingold
+  Updated to revision 12.
+  $ echo "something new" > somethingnew
+  $ svn add somethingnew
+  A         somethingnew
+  $ svn ci -m 'Something new'
+  Adding         somethingnew
+  Transmitting file data .
+  Committed revision 13.
+  $ cd ..
+  $ rm -rf tempwc
+  $ svn co "$SVNREPO/branch"@10 recreated
+  A    recreated/somethingold
+  Checked out revision 10.
+  $ echo "recreated =        [svn]       $SVNREPO/branch" >> .hgsub
+  $ hg ci -m addsub
+  committing subrepository recreated
+  $ cd recreated
+  $ svn up
+  D    somethingold
+  A    somethingnew
+  Updated to revision 13.
+  $ cd ..
+  $ hg ci -m updatesub
+  committing subrepository recreated
+  $ hg up -r-2
+  D    $TESTTMP/rebaserepo/recreated/somethingnew
+  A    $TESTTMP/rebaserepo/recreated/somethingold
+  Checked out revision 10.
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ test -e recreated/somethingold
+
exporting patch:
<fdopen>






More information about the Mercurial-devel mailing list