# HG changeset patch # User Alexis S. L. Carvalho # Date 2007-08-27 04:44:35 # Node ID 20817af258d87f0262a9c4f933ee134689d40b3c # Parent fe55e3d6dc0b9979fba553ebcecc0bd7ee457aa1 pull -u: if "url#rev" was given, update to rev diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2021,12 +2021,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: @@ -2089,7 +2089,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 @@ -2661,7 +2661,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/tests/test-url-rev b/tests/test-url-rev --- a/tests/test-url-rev +++ b/tests/test-url-rev @@ -51,3 +51,33 @@ 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 --- a/tests/test-url-rev.out +++ b/tests/test-url-rev.out @@ -76,3 +76,55 @@ date: Thu Jan 01 00:00:00 1970 +0 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 +