# HG changeset patch # User Bryan O'Sullivan # Date 1184634080 25200 # Node ID 2d545b98a7bccd335800241f8fe11dedb6bf5d4b # Parent bbdcacf7cef820857f3fdfe5594b4fd40d30527e issue 622: pull/unbundle -u updates to default branch if repo was empty diff -r bbdcacf7cef8 -r 2d545b98a7bc mercurial/commands.py --- a/mercurial/commands.py Mon Jul 16 16:50:47 2007 -0700 +++ b/mercurial/commands.py Mon Jul 16 18:01:20 2007 -0700 @@ -2025,11 +2025,13 @@ 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, wasempty): if modheads == 0: return if optupdate: - if modheads == 1: + if wasempty: + return hg.update(repo, repo.lookup('default')) + elif modheads == 1: return hg.update(repo, repo.changelog.tip()) # update else: ui.status(_("not updating, since new heads added\n")) @@ -2091,8 +2093,9 @@ error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.") raise util.Abort(error) + wasempty = repo.changelog.count() == 0 modheads = repo.pull(other, heads=revs, force=opts['force']) - return postincoming(ui, repo, modheads, opts['update']) + return postincoming(ui, repo, modheads, opts['update'], wasempty) def push(ui, repo, dest=None, **opts): """push changes to the specified destination @@ -2656,6 +2659,7 @@ """ fnames = (fname1,) + fnames result = None + wasempty = repo.changelog.count() == 0 for fname in fnames: if os.path.exists(fname): f = open(fname, "rb") @@ -2664,7 +2668,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'], wasempty) def update(ui, repo, node=None, rev=None, clean=False, date=None): """update working directory diff -r bbdcacf7cef8 -r 2d545b98a7bc tests/test-pull --- a/tests/test-pull Mon Jul 16 16:50:47 2007 -0700 +++ b/tests/test-pull Mon Jul 16 18:01:20 2007 -0700 @@ -18,3 +18,9 @@ cat foo hg manifest --debug hg pull + +echo % issue 622 +cd .. +hg init empty +cd empty +hg pull -u ../test diff -r bbdcacf7cef8 -r 2d545b98a7bc tests/test-pull.out --- a/tests/test-pull.out Mon Jul 16 16:50:47 2007 -0700 +++ b/tests/test-pull.out Mon Jul 16 18:01:20 2007 -0700 @@ -21,3 +21,11 @@ pulling from http://localhost:20059/ searching for changes no changes found +% issue 622 +pulling from ../test +requesting all changes +adding changesets +adding manifests +adding file changes +added 1 changesets with 1 changes to 1 files +1 files updated, 0 files merged, 0 files removed, 0 files unresolved