pull: merge bookmark updates and imports
We do all the things in one go now, updating existing bookmark, adding new ones,
and overwriting the ones explicitly specified for --bookmark. This impacts the
tests by removing some duplicated or unnecessary output.
--- a/mercurial/bookmarks.py Sun Sep 28 13:43:31 2014 -0700
+++ b/mercurial/bookmarks.py Sun Sep 28 14:07:56 2014 -0700
@@ -358,6 +358,7 @@
if ui.configbool('ui', 'quietbookmarkmove', False):
status = warn = ui.debug
+ explicit = set(explicit)
changed = []
for b, scid, dcid in addsrc:
if scid in repo: # add remote bookmarks for changes we already have
@@ -366,23 +367,30 @@
for b, scid, dcid in advsrc:
changed.append((b, bin(scid), status,
_("updating bookmark %s\n") % (b)))
+ # remove normal movement from explicit set
+ explicit.difference_update(d[0] for d in changed)
+
for b, scid, dcid in diverge:
- db = _diverge(ui, b, path, localmarks)
- changed.append((db, bin(scid), warn,
- _("divergent bookmark %s stored as %s\n") % (b, db)))
+ if b in explicit:
+ explicit.discard(b)
+ changed.append((b, bin(scid), status,
+ _("importing bookmark %s\n") % (b, b)))
+ else:
+ db = _diverge(ui, b, path, localmarks)
+ changed.append((db, bin(scid), warn,
+ _("divergent bookmark %s stored as %s\n")
+ % (b, db)))
+ for b, scid, dcid in adddst + advdst:
+ if b in explicit:
+ explicit.discard(b)
+ changed.append((b, bin(scid), status,
+ _("importing bookmark %s\n") % (b, b)))
+
if changed:
for b, node, writer, msg in sorted(changed):
localmarks[b] = node
writer(msg)
localmarks.write()
- # update specified bookmarks
- if explicit:
- marks = repo._bookmarks
- for b in explicit:
- # explicit pull overrides local bookmark if any
- repo.ui.status(_("importing bookmark %s\n") % b)
- marks[b] = repo[remotemarks[b]].node()
- marks.write()
def diff(ui, dst, src):
ui.status(_("searching for changed bookmarks\n"))
--- a/tests/test-bookmarks-pushpull.t Sun Sep 28 13:43:31 2014 -0700
+++ b/tests/test-bookmarks-pushpull.t Sun Sep 28 14:07:56 2014 -0700
@@ -61,7 +61,6 @@
$ hg pull -B X ../a
pulling from ../a
no changes found
- importing bookmark X
$ hg bookmark
X 0:4e3505fd9583
* Y 0:4e3505fd9583
@@ -373,7 +372,6 @@
adding remote bookmark Z
adding remote bookmark foo
adding remote bookmark foobar
- importing bookmark Z
$ hg clone http://localhost:$HGPORT/ cloned-bookmarks
requesting all changes
adding changesets
--- a/tests/test-bundle2.t Sun Sep 28 13:43:31 2014 -0700
+++ b/tests/test-bundle2.t Sun Sep 28 14:07:56 2014 -0700
@@ -906,7 +906,6 @@
added 1 changesets with 1 changes to 1 files (+1 heads)
1 new obsolescence markers
updating bookmark book_02de
- importing bookmark book_02de
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg -R other debugobsolete
1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
@@ -928,7 +927,6 @@
added 1 changesets with 1 changes to 1 files (+1 heads)
1 new obsolescence markers
updating bookmark book_42cc
- importing bookmark book_42cc
(run 'hg heads .' to see heads, 'hg merge' to merge)
$ cat main-error.log
$ hg -R other debugobsolete
--- a/tests/test-hook.t Sun Sep 28 13:43:31 2014 -0700
+++ b/tests/test-hook.t Sun Sep 28 14:07:56 2014 -0700
@@ -200,7 +200,6 @@
no changes found
listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
adding remote bookmark bar
- importing bookmark bar
$ cd ../a
test that prepushkey can prevent incoming keys
--- a/tests/test-ssh.t Sun Sep 28 13:43:31 2014 -0700
+++ b/tests/test-ssh.t Sun Sep 28 14:07:56 2014 -0700
@@ -197,7 +197,6 @@
pulling from ssh://user@dummy/remote
no changes found
updating bookmark foo
- importing bookmark foo
$ hg book -d foo
$ hg push -B foo
pushing to ssh://user@dummy/remote