subrepo: correct revision in svn checkout stable
authorEli Carter <eli.carter@tektronix.com>
Thu, 30 Jun 2011 13:22:12 -0500
branchstable
changeset 14820 7ef125fa9b35
parent 14819 b30c889584ef
child 14821 2017495bd552
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@REV instead.
mercurial/subrepo.py
tests/test-subrepo-svn.t
--- a/mercurial/subrepo.py	Thu Jun 30 12:55:19 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
--- a/tests/test-subrepo-svn.t	Thu Jun 30 12:55:19 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
+