Mercurial > hg-stable
changeset 5248:5517aa5aafb0
Merge with crew-stable
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Mon, 27 Aug 2007 02:21:58 -0300 |
parents | 20770c5d41e0 (current diff) 438ff951df70 (diff) |
children | 0d28d4e5fe1f |
files | hgext/mq.py mercurial/cmdutil.py mercurial/commands.py mercurial/hg.py mercurial/localrepo.py tests/test-pull-r tests/test-url-rev |
diffstat | 10 files changed, 316 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Sun Aug 26 19:13:24 2007 +0200 +++ b/hgext/mq.py Mon Aug 27 02:21:58 2007 -0300 @@ -1516,13 +1516,18 @@ 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 @@ 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:
--- a/mercurial/commands.py Sun Aug 26 19:13:24 2007 +0200 +++ b/mercurial/commands.py Mon Aug 27 02:21:58 2007 -0300 @@ -335,7 +335,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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
--- a/mercurial/hg.py Sun Aug 26 19:13:24 2007 +0200 +++ b/mercurial/hg.py Mon Aug 27 02:21:58 2007 -0300 @@ -22,10 +22,10 @@ '''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 @@ """ 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 @@ 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 @@ 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
--- a/mercurial/localrepo.py Sun Aug 26 19:13:24 2007 +0200 +++ b/mercurial/localrepo.py Mon Aug 27 02:21:58 2007 -0300 @@ -1352,7 +1352,7 @@ 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"))
--- a/tests/test-clone Sun Aug 26 19:13:24 2007 +0200 +++ b/tests/test-clone Mon Aug 27 02:21:58 2007 -0300 @@ -25,3 +25,11 @@ 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
--- a/tests/test-clone.out Sun Aug 26 19:13:24 2007 +0200 +++ b/tests/test-clone.out Mon Aug 27 02:21:58 2007 -0300 @@ -14,3 +14,4 @@ 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-pull-r Mon Aug 27 02:21:58 2007 -0300 @@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-pull-r.out Mon Aug 27 02:21:58 2007 -0300 @@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-url-rev Mon Aug 27 02:21:58 2007 -0300 @@ -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 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-url-rev.out Mon Aug 27 02:21:58 2007 -0300 @@ -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 +