# HG changeset patch # User Dirkjan Ochtman # Date 2008-09-24 11:50:29 # Node ID 6788608627c49043f1d81066e05334e9004a1f1d # Parent 6489ee64b52245136b6690f1c292dc1c930ad4c9 # Parent f82938c87b92fb9165a194984737b393eee5e1e6 merge with crew-stable diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -20,10 +20,11 @@ def parseurl(url, revs=[]): '''parse url#branch, returning url, branch + revs''' if '#' not in url: - return url, (revs or None), None + return url, (revs or None), revs and revs[-1] or None - url, rev = url.split('#', 1) - return url, revs + [rev], rev + url, branch = url.split('#', 1) + checkout = revs and revs[-1] or branch + return url, revs + [branch], checkout schemes = { 'bundle': bundlerepo, @@ -120,7 +121,7 @@ def clone(ui, source, dest=None, pull=Fa else: src_repo = source origsource = source = src_repo.url() - checkout = None + checkout = rev and rev[-1] or None if dest is None: dest = defaultdest(source) @@ -231,12 +232,13 @@ def clone(ui, source, dest=None, pull=Fa dest_repo.ui.status(_("updating working directory\n")) if update is not True: checkout = update - elif not checkout: + for test in (checkout, 'default', 'tip'): try: - checkout = dest_repo.lookup("default") + uprev = dest_repo.lookup(test) + break except: - checkout = dest_repo.changelog.tip() - _update(dest_repo, checkout) + continue + _update(dest_repo, uprev) return src_repo, dest_repo finally: diff --git a/tests/test-issue1306 b/tests/test-issue1306 new file mode 100755 --- /dev/null +++ b/tests/test-issue1306 @@ -0,0 +1,23 @@ +echo % initialize remote repo with branches +hg init remote +cd remote +echo a > a +hg ci -Ama +hg branch br +hg ci -Amb +echo c > c +hg ci -Amc +hg log + +cd .. +echo % try cloning -r branch +hg clone -rbr remote local1 +hg -R local1 parents + +echo % try cloning -rother clone#branch +hg clone -r0 remote#br local2 +hg -R local2 parents + +echo % try cloning -r1 clone#branch +hg clone -r1 remote#br local3 +hg -R local3 parents diff --git a/tests/test-issue1306.out b/tests/test-issue1306.out new file mode 100644 --- /dev/null +++ b/tests/test-issue1306.out @@ -0,0 +1,64 @@ +% initialize remote repo with branches +adding a +marked working directory as branch br +adding c +changeset: 2:1630aed6ed2b +branch: br +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: c + +changeset: 1:234f53e6c5ff +branch: br +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: b + +changeset: 0:cb9a9f314b8b +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: a + +% try cloning -r branch +requesting all changes +adding changesets +adding manifests +adding file changes +added 3 changesets with 2 changes to 2 files +updating working directory +2 files updated, 0 files merged, 0 files removed, 0 files unresolved +changeset: 2:1630aed6ed2b +branch: br +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: c + +% try cloning -rother clone#branch +requesting all changes +adding changesets +adding manifests +adding file changes +added 3 changesets with 2 changes to 2 files +updating working directory +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +changeset: 0:cb9a9f314b8b +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: a + +% try cloning -r1 clone#branch +requesting all changes +adding changesets +adding manifests +adding file changes +added 3 changesets with 2 changes to 2 files +updating working directory +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +changeset: 1:234f53e6c5ff +branch: br +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: b + diff --git a/tests/test-url-rev.out b/tests/test-url-rev.out --- a/tests/test-url-rev.out +++ b/tests/test-url-rev.out @@ -109,11 +109,12 @@ 0:1f0dee641bb7 1:cd2a86ecc814 % pull -u -r otherrev url#rev updates to rev % parents -changeset: 2:faba9097cad4 -branch: foo +changeset: 3:4cd725637392 +tag: tip +parent: 0:1f0dee641bb7 user: test date: Thu Jan 01 00:00:00 1970 +0000 -summary: new head of branch foo +summary: add bar % heads changeset: 3:4cd725637392