pull: gather all bookmark-pulling code together
Pulling bookmarks is done in two rounds. First we do a simple update, then we use
the content of the `bookmark` argument to possibly overwrite some bookmark
with their remote location.
The second step was not done right after the first one for some obscure reason.
We now perform them one after the other.
--- a/mercurial/commands.py Thu Sep 25 02:53:29 2014 -0700
+++ b/mercurial/commands.py Thu Sep 25 17:53:27 2014 -0700
@@ -4961,6 +4961,14 @@
modheads = repo.pull(other, heads=revs, force=opts.get('force'))
bookmarks.updatefromremote(ui, repo, remotebookmarks, source)
+ # update specified bookmarks
+ if opts.get('bookmark'):
+ marks = repo._bookmarks
+ for b in opts['bookmark']:
+ # explicit pull overrides local bookmark if any
+ ui.status(_("importing bookmark %s\n") % b)
+ marks[b] = repo[remotebookmarks[b]].node()
+ marks.write()
if checkout:
checkout = str(repo.changelog.rev(other.lookup(checkout)))
repo._subtoppath = source
@@ -4970,14 +4978,6 @@
finally:
del repo._subtoppath
- # update specified bookmarks
- if opts.get('bookmark'):
- marks = repo._bookmarks
- for b in opts['bookmark']:
- # explicit pull overrides local bookmark if any
- ui.status(_("importing bookmark %s\n") % b)
- marks[b] = repo[remotebookmarks[b]].node()
- marks.write()
finally:
other.close()
return ret
--- a/tests/test-bundle2.t Thu Sep 25 02:53:29 2014 -0700
+++ b/tests/test-bundle2.t Thu Sep 25 17:53:27 2014 -0700
@@ -907,8 +907,8 @@
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)
- importing bookmark book_02de
$ hg -R other debugobsolete
1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
@@ -929,8 +929,8 @@
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)
- importing bookmark book_42cc
$ cat main-error.log
$ hg -R other debugobsolete
1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}