[PATCH] Try updating to the actual changeset specified in options

Brett Carter brett at rdnzl.net
Tue May 12 17:22:04 CDT 2009


# HG changeset patch
# User Brett Carter <brett at rdnzl.net>
# Date 1242166770 25200
# Node ID 9711f2ba30035ae43c3ee181856bc016ff7a38e9
# Parent  94e91205d9b6f7272d6a1b61c39de4c2555df240
Try updating to the actual changeset specified in options
When cloning with the -r option or # url format from a tag the destination
repo most likely won't have the tag.  Currently we try and update the
workingdir based on what was literally passed in to -r, which will fail if we
don't have the tag specified, causing the workingdir to be updated to default
or tip, even though we specified a tag.  This patch saves the cset id from
the remote repo and tries to update based on that first.
Similar to issue1306, but for tags not branches

diff -r 94e91205d9b6 -r 9711f2ba3003 mercurial/hg.py
--- a/mercurial/hg.py	Tue May 12 10:03:36 2009 -0400
+++ b/mercurial/hg.py	Tue May 12 15:19:30 2009 -0700
@@ -219,7 +219,7 @@
                                        "lookup and so doesn't support clone by "
                                        "revision"))
                 revs = [src_repo.lookup(r) for r in rev]
-
+                checkout = revs[0]
             if dest_repo.local():
                 dest_repo.clone(src_repo, heads=revs, stream=stream)
             elif src_repo.local():
diff -r 94e91205d9b6 -r 9711f2ba3003 tests/test-localtag-clone
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-localtag-clone	Tue May 12 15:19:30 2009 -0700
@@ -0,0 +1,23 @@
+echo % initialize remote repo with local tag
+hg init remote
+cd remote
+echo a > a
+hg ci -Ama
+hg tag -l t1
+hg ci -Amt1
+echo c > c
+hg ci -Amc
+hg log
+
+cd ..
+echo % try cloning -r localtag
+hg clone -rt1 remote local1
+hg -R local1 parents
+
+echo % try cloning -r0 clone#localtag
+hg clone -r0 remote#t1 local2
+hg -R local2 parents
+
+echo % try cloning -r1 clone#localtag
+hg clone -r1 remote#t1 local3
+hg -R local3 parents
\ No newline at end of file
diff -r 94e91205d9b6 -r 9711f2ba3003 tests/test-localtag-clone.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-localtag-clone.out	Tue May 12 15:19:30 2009 -0700
@@ -0,0 +1,58 @@
+% initialize remote repo with local tag
+adding a
+nothing changed
+adding c
+changeset:   1:d36c0562f908
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     c
+
+changeset:   0:cb9a9f314b8b
+tag:         t1
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     a
+
+% try cloning -r localtag
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+updating working directory
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+changeset:   0:cb9a9f314b8b
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     a
+
+% try cloning -r0 clone#localtag
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+updating working directory
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+changeset:   0:cb9a9f314b8b
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     a
+
+% try cloning -r1 clone#localtag
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 2 changesets with 2 changes to 2 files
+updating working directory
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+changeset:   1:d36c0562f908
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     c
+


More information about the Mercurial-devel mailing list