pull: move bookmark movements inside the `exchange.pull`
There is no reason for bookmarks to get a special treatment. As a first step we
move the code as is in the `exchange.pull` function. Integration with the rest
of the flow will come later.
Adding bookmarks to pull means that most clone paths are now pulling bookmarks
through pull. We ensure that bookmark-update messages are properly suppressed in
that case.
In test-pull-http.t the 'requesting all changes' message disappear because we
now get the authentication error on the `listkeys`command before such message
is printed.
--- a/mercurial/commands.py Thu Oct 02 12:16:07 2014 -0500
+++ b/mercurial/commands.py Fri Sep 26 17:44:00 2014 -0700
@@ -4960,16 +4960,8 @@
"so a rev cannot be specified.")
raise util.Abort(err)
- modheads = repo.pull(other, heads=revs, force=opts.get('force'))
- bookmarks.updatefromremote(ui, repo, remotebookmarks, other.url())
- # 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()
+ modheads = repo.pull(other, heads=revs, force=opts.get('force'),
+ bookmarks=opts.get('bookmark', ()))
if checkout:
checkout = str(repo.changelog.rev(other.lookup(checkout)))
repo._subtoppath = source
--- a/mercurial/exchange.py Thu Oct 02 12:16:07 2014 -0500
+++ b/mercurial/exchange.py Fri Sep 26 17:44:00 2014 -0700
@@ -781,7 +781,7 @@
if self._tr is not None:
self._tr.release()
-def pull(repo, remote, heads=None, force=False):
+def pull(repo, remote, heads=None, force=False, bookmarks=()):
pullop = pulloperation(repo, remote, heads, force)
if pullop.remote.local():
missing = set(pullop.remote.requirements) - pullop.repo.supported
@@ -791,6 +791,7 @@
" %s") % (', '.join(sorted(missing)))
raise util.Abort(msg)
+ remotebookmarks = remote.listkeys('bookmarks')
lock = pullop.repo.lock()
try:
_pulldiscovery(pullop)
@@ -807,6 +808,18 @@
finally:
pullop.releasetransaction()
lock.release()
+ bookmod.updatefromremote(repo.ui, repo, remotebookmarks, remote.url())
+ # update specified bookmarks
+ if bookmarks:
+ marks = repo._bookmarks
+ writer = repo.ui.status
+ if repo.ui.configbool('ui', 'quietbookmarkmove', False):
+ writer = repo.ui.debug
+ for b in bookmarks:
+ # explicit pull overrides local bookmark if any
+ writer(_("importing bookmark %s\n") % b)
+ marks[b] = repo[remotebookmarks[b]].node()
+ marks.write()
return pullop.cgresult
--- a/mercurial/localrepo.py Thu Oct 02 12:16:07 2014 -0500
+++ b/mercurial/localrepo.py Fri Sep 26 17:44:00 2014 -0700
@@ -1724,7 +1724,14 @@
# if we support it, stream in and adjust our requirements
if not streamreqs - self.supportedformats:
return self.stream_in(remote, streamreqs)
- return self.pull(remote, heads)
+
+ quiet = self.ui.backupconfig('ui', 'quietbookmarkmove')
+ try:
+ self.ui.setconfig('ui', 'quietbookmarkmove', True, 'clone')
+ ret = self.pull(remote, heads)
+ finally:
+ self.ui.restoreconfig(quiet)
+ return ret
def pushkey(self, namespace, key, old, new):
self.hook('prepushkey', throw=True, namespace=namespace, key=key,
--- a/tests/test-hook.t Thu Oct 02 12:16:07 2014 -0500
+++ b/tests/test-hook.t Fri Sep 26 17:44:00 2014 -0700
@@ -196,6 +196,7 @@
$ hg pull -B bar ../a
pulling from ../a
listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
+ listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
no changes found
listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
adding remote bookmark bar
--- a/tests/test-http-proxy.t Thu Oct 02 12:16:07 2014 -0500
+++ b/tests/test-http-proxy.t Fri Sep 26 17:44:00 2014 -0700
@@ -103,21 +103,25 @@
* - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - - (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
+ * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=phases (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
+ * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=phases (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
+ * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=phases (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
+ * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
* - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=phases (glob)
--- a/tests/test-pull-http.t Thu Oct 02 12:16:07 2014 -0500
+++ b/tests/test-pull-http.t Fri Sep 26 17:44:00 2014 -0700
@@ -45,7 +45,6 @@
$ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
$ cat hg.pid >> $DAEMON_PIDS
$ hg clone http://localhost:$HGPORT/ test4
- requesting all changes
abort: authorization failed
[255]
$ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
--- a/tests/test-treediscovery.t Thu Oct 02 12:16:07 2014 -0500
+++ b/tests/test-treediscovery.t Fri Sep 26 17:44:00 2014 -0700
@@ -515,6 +515,7 @@
"GET /?cmd=between HTTP/1.1" 200 - x-hgarg-1:pairs=d8f638ac69e9ae8dea4f09f11d696546a912d961-d57206cc072a18317c1e381fb60aa31bd3401785
"GET /?cmd=capabilities HTTP/1.1" 200 -
"GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
+ "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
"GET /?cmd=heads HTTP/1.1" 200 -
"GET /?cmd=branches HTTP/1.1" 200 - x-hgarg-1:nodes=d8f638ac69e9ae8dea4f09f11d696546a912d961
"GET /?cmd=between HTTP/1.1" 200 - x-hgarg-1:pairs=d8f638ac69e9ae8dea4f09f11d696546a912d961-d57206cc072a18317c1e381fb60aa31bd3401785