# HG changeset patch # User Alexis S. L. Carvalho # Date 1188192118 10800 # Node ID 5517aa5aafb0258a309c95f87e3f5004a02f40af # Parent 20770c5d41e0610ce3bbdec109d19601c0817072# Parent 438ff951df70852719d3fb717b144fcf995aad2b Merge with crew-stable diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1516,13 +1516,18 @@ def clone(ui, source, dest=None, **opts) The patch directory must be a nested mercurial repository, as would be created by qinit -c. ''' + def patchdir(repo): + url = repo.url() + if url.endswith('/'): + url = url[:-1] + return url + '/.hg/patches' cmdutil.setremoteconfig(ui, opts) if dest is None: dest = hg.defaultdest(source) sr = hg.repository(ui, ui.expandpath(source)) - patchdir = opts['patches'] or (sr.url() + '/.hg/patches') + patchespath = opts['patches'] or patchdir(sr) try: - pr = hg.repository(ui, patchdir) + pr = hg.repository(ui, patchespath) except hg.RepoError: raise util.Abort(_('versioned patch repository not found' ' (see qinit -c)')) @@ -1543,10 +1548,8 @@ def clone(ui, source, dest=None, **opts) update=False, stream=opts['uncompressed']) ui.note(_('cloning patch repo\n')) - spr, dpr = hg.clone(ui, opts['patches'] or (sr.url() + '/.hg/patches'), - dr.url() + '/.hg/patches', - pull=opts['pull'], - update=not opts['noupdate'], + spr, dpr = hg.clone(ui, opts['patches'] or patchdir(sr), patchdir(dr), + pull=opts['pull'], update=not opts['noupdate'], stream=opts['uncompressed']) if dr.local(): if qbase: diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -335,7 +335,7 @@ def bundle(ui, repo, fname, dest=None, * visit.append(p) else: cmdutil.setremoteconfig(ui, opts) - dest, revs = hg.parseurl( + dest, revs, checkout = hg.parseurl( ui.expandpath(dest or 'default-push', dest or 'default'), revs) other = hg.repository(ui, dest) o = repo.findoutgoing(other, force=opts['force']) @@ -1474,7 +1474,7 @@ def identify(ui, repo, source=None, output = [] if source: - source, revs = hg.parseurl(ui.expandpath(source), []) + source, revs, checkout = hg.parseurl(ui.expandpath(source), []) srepo = hg.repository(ui, source) if not rev and revs: rev = revs[0] @@ -1639,7 +1639,7 @@ def incoming(ui, repo, source="default", See pull for valid source format details. """ - source, revs = hg.parseurl(ui.expandpath(source), opts['rev']) + source, revs, checkout = hg.parseurl(ui.expandpath(source), opts['rev']) cmdutil.setremoteconfig(ui, opts) other = hg.repository(ui, source) @@ -1950,7 +1950,7 @@ def outgoing(ui, repo, dest=None, **opts See pull for valid destination format details. """ - dest, revs = hg.parseurl( + dest, revs, checkout = hg.parseurl( ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev']) cmdutil.setremoteconfig(ui, opts) if revs: @@ -2018,12 +2018,12 @@ def paths(ui, repo, search=None): for name, path in ui.configitems("paths"): ui.write("%s = %s\n" % (name, path)) -def postincoming(ui, repo, modheads, optupdate): +def postincoming(ui, repo, modheads, optupdate, checkout): if modheads == 0: return if optupdate: - if modheads <= 1: - return hg.update(repo, None) + if modheads <= 1 or checkout: + return hg.update(repo, checkout) else: ui.status(_("not updating, since new heads added\n")) if modheads > 1: @@ -2072,7 +2072,7 @@ def pull(ui, repo, source="default", **o Alternatively specify "ssh -C" as your ssh command in your hgrc or with the --ssh command line option. """ - source, revs = hg.parseurl(ui.expandpath(source), opts['rev']) + source, revs, checkout = hg.parseurl(ui.expandpath(source), opts['rev']) cmdutil.setremoteconfig(ui, opts) other = hg.repository(ui, source) @@ -2085,7 +2085,7 @@ def pull(ui, repo, source="default", **o raise util.Abort(error) modheads = repo.pull(other, heads=revs, force=opts['force']) - return postincoming(ui, repo, modheads, opts['update']) + return postincoming(ui, repo, modheads, opts['update'], checkout) def push(ui, repo, dest=None, **opts): """push changes to the specified destination @@ -2117,7 +2117,7 @@ def push(ui, repo, dest=None, **opts): Pushing to http:// and https:// URLs is only possible, if this feature is explicitly enabled on the remote Mercurial server. """ - dest, revs = hg.parseurl( + dest, revs, checkout = hg.parseurl( ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev']) cmdutil.setremoteconfig(ui, opts) @@ -2663,7 +2663,7 @@ def unbundle(ui, repo, fname1, *fnames, gen = changegroup.readbundle(f, fname) modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) - return postincoming(ui, repo, modheads, opts['update']) + return postincoming(ui, repo, modheads, opts['update'], None) def update(ui, repo, node=None, rev=None, clean=False, date=None): """update working directory diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -22,10 +22,10 @@ def parseurl(url, revs): '''parse url#branch, returning url, branch + revs''' if '#' not in url: - return url, (revs or None) + return url, (revs or None), None url, rev = url.split('#', 1) - return url, revs + [rev] + return url, revs + [rev], rev schemes = { 'bundle': bundlerepo, @@ -106,7 +106,7 @@ def clone(ui, source, dest=None, pull=Fa """ origsource = source - source, rev = parseurl(ui.expandpath(source), rev) + source, rev, checkout = parseurl(ui.expandpath(source), rev) if isinstance(source, str): src_repo = repository(ui, source) @@ -149,7 +149,7 @@ def clone(ui, source, dest=None, pull=Fa abspath = origsource copy = False if src_repo.local() and islocal(dest): - abspath = os.path.abspath(origsource) + abspath = os.path.abspath(util.drop_scheme('file', origsource)) copy = not pull and not rev if copy: @@ -226,10 +226,11 @@ def clone(ui, source, dest=None, pull=Fa fp.close() if update: - try: - checkout = dest_repo.lookup("default") - except: - checkout = dest_repo.changelog.tip() + if not checkout: + try: + checkout = dest_repo.lookup("default") + except: + checkout = dest_repo.changelog.tip() _update(dest_repo, checkout) return src_repo, dest_repo diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1352,7 +1352,7 @@ class localrepository(repo.repository): def pull(self, remote, heads=None, force=False): lock = self.lock() try: - fetch = self.findincoming(remote, force=force) + fetch = self.findincoming(remote, heads=heads, force=force) if fetch == [nullid]: self.ui.status(_("requesting all changes\n")) diff --git a/tests/test-clone b/tests/test-clone --- a/tests/test-clone +++ b/tests/test-clone @@ -25,3 +25,11 @@ cd ../d hg clone ../a cd a hg cat a + +# check that we drop the file:// from the path before +# writing the .hgrc +cd ../.. +hg clone file://a e +grep 'file:' e/.hg/hgrc + +exit 0 diff --git a/tests/test-clone.out b/tests/test-clone.out --- a/tests/test-clone.out +++ b/tests/test-clone.out @@ -14,3 +14,4 @@ 1 files, 1 changesets, 1 total revisions destination directory: a 1 files updated, 0 files merged, 0 files removed, 0 files unresolved a +1 files updated, 0 files merged, 0 files removed, 0 files unresolved diff --git a/tests/test-pull-r b/tests/test-pull-r new file mode 100755 --- /dev/null +++ b/tests/test-pull-r @@ -0,0 +1,27 @@ +#!/bin/sh + +hg init repo +cd repo +echo foo > foo +hg ci -qAm 'add foo' -d '0 0' +echo >> foo +hg ci -m 'change foo' -d '0 0' +hg up -qC 0 +echo bar > bar +hg ci -qAm 'add bar' -d '0 0' +hg log +cd .. +hg init copy +cd copy + +echo '% pull -r 0' +hg pull -qr 0 ../repo +hg log + +echo '% pull -r 1' +hg pull -qr 1 ../repo +hg log + +# this used to abort: received changelog group is empty +echo '% pull -r 1 again' +hg pull -qr 1 ../repo diff --git a/tests/test-pull-r.out b/tests/test-pull-r.out new file mode 100644 --- /dev/null +++ b/tests/test-pull-r.out @@ -0,0 +1,37 @@ +changeset: 2:effea6de0384 +tag: tip +parent: 0:bbd179dfa0a7 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add bar + +changeset: 1:ed1b79f46b9a +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: change foo + +changeset: 0:bbd179dfa0a7 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add foo + +% pull -r 0 +changeset: 0:bbd179dfa0a7 +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add foo + +% pull -r 1 +changeset: 1:ed1b79f46b9a +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: change foo + +changeset: 0:bbd179dfa0a7 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add foo + +% pull -r 1 again diff --git a/tests/test-url-rev b/tests/test-url-rev new file mode 100755 --- /dev/null +++ b/tests/test-url-rev @@ -0,0 +1,83 @@ +#!/bin/sh +# test basic functionality of url#rev syntax + +hg init repo +cd repo +echo a > a +hg ci -qAm 'add a' -d '0 0' +hg branch foo +echo >> a +hg ci -m 'change a' -d '0 0' +cd .. + +echo '% clone repo#foo' +hg clone 'repo#foo' clone +echo '% heads' +hg --cwd clone heads +echo '% parents' +hg --cwd clone parents +sed -e 's/default.*#/default = #/' clone/.hg/hgrc +echo + +echo '% changing original repo' +cd repo +echo >> a +hg ci -m 'new head of branch foo' -d '0 0' +hg up -qC default +echo bar > bar +hg ci -qAm 'add bar' -d '0 0' +hg log +echo + +echo '% outgoing' +hg -q outgoing '../clone#foo' +echo + +echo '% push' +hg -q push '../clone#foo' +hg --cwd ../clone heads +cd .. +echo + +echo '% rolling back' +cd clone +hg rollback + +echo '% incoming' +hg -q incoming + +echo '% pull' +hg -q pull +hg heads +echo + +echo '% pull should not have updated' +hg parents -q +echo '% going back to the default branch' +hg up -C 0 +hg parents +echo '% no new revs, no update' +hg pull -qu +hg parents -q +echo '% rollback' +hg rollback +hg up -C 0 +hg parents -q +echo '% pull -u takes us back to branch foo' +hg pull -qu +hg parents + +echo '% rollback' +hg rollback +hg up -C 0 +echo '% parents' +hg parents -q +echo '% heads' +hg heads -q +echo '% pull -u -r otherrev url#rev updates to rev' +hg pull -qur default default +echo '% parents' +hg parents +echo '% heads' +hg heads + diff --git a/tests/test-url-rev.out b/tests/test-url-rev.out new file mode 100644 --- /dev/null +++ b/tests/test-url-rev.out @@ -0,0 +1,130 @@ +marked working directory as branch foo +% clone repo#foo +requesting all changes +adding changesets +adding manifests +adding file changes +added 2 changesets with 2 changes to 1 files +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +% heads +changeset: 1:cd2a86ecc814 +branch: foo +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: change a + +% parents +changeset: 1:cd2a86ecc814 +branch: foo +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: change a + +[paths] +default = #foo + +% changing original repo +changeset: 3:4cd725637392 +tag: tip +parent: 0:1f0dee641bb7 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add bar + +changeset: 2:faba9097cad4 +branch: foo +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: new head of branch foo + +changeset: 1:cd2a86ecc814 +branch: foo +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: change a + +changeset: 0:1f0dee641bb7 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add a + + +% outgoing +2:faba9097cad4 + +% push +changeset: 2:faba9097cad4 +branch: foo +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: new head of branch foo + + +% rolling back +rolling back last transaction +% incoming +2:faba9097cad4 +% pull +changeset: 2:faba9097cad4 +branch: foo +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: new head of branch foo + + +% pull should not have updated +1:cd2a86ecc814 +% going back to the default branch +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +changeset: 0:1f0dee641bb7 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add a + +% no new revs, no update +0:1f0dee641bb7 +% rollback +rolling back last transaction +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +0:1f0dee641bb7 +% pull -u takes us back to branch foo +changeset: 2:faba9097cad4 +branch: foo +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: new head of branch foo + +% rollback +rolling back last transaction +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +% parents +0:1f0dee641bb7 +% heads +1:cd2a86ecc814 +% pull -u -r otherrev url#rev updates to rev +% parents +changeset: 2:faba9097cad4 +branch: foo +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: new head of branch foo + +% heads +changeset: 3:4cd725637392 +tag: tip +parent: 0:1f0dee641bb7 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add bar + +changeset: 2:faba9097cad4 +branch: foo +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: new head of branch foo +