D4819: identify: only query remote bookmarks if needed
valentin.gatienbaron (Valentin Gatien-Baron)
phabricator at mercurial-scm.org
Mon Oct 1 14:30:41 UTC 2018
valentin.gatienbaron created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Instead of all the time when operating on a remote repo. This
perf regression was introduced in https://phab.mercurial-scm.org/rHG15a79ac823e8c1c173633f07551905484cb19528, in 4.3.
This datahint method returns nothing for -Tjson, -Tpickle, -Tdebug
--config ui.formatdebug=true and --config ui.formatjson, so the
bookmarks won't show up. I don't know what these formatters are for.
plainformatter and templateformatter work properly, and the few other
uses of datahint should have the same kind of problem.
There is further weirdness where "--template '{node}'" is not enough
to avoid querying the bookmarks, you also need to pass --id or -q.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4819
AFFECTED FILES
mercurial/commands.py
CHANGE DETAILS
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3013,27 +3013,31 @@
output = [hexrev]
fm.data(id=hexrev)
+ bmscache = [None]
def getbms():
+ if bmscache[0] is not None:
+ return bmscache[0]
bms = []
if 'bookmarks' in peer.listkeys('namespaces'):
hexremoterev = hex(remoterev)
bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
if bmr == hexremoterev]
- return sorted(bms)
-
- bms = getbms()
+ bmscache[0] = sorted(bms)
+ return bmscache[0]
+
if bookmarks:
- output.extend(bms)
+ output.extend(getbms())
elif default and not ui.quiet:
# multiple bookmarks for a single parent separated by '/'
- bm = '/'.join(bms)
+ bm = '/'.join(getbms())
if bm:
output.append(bm)
fm.data(node=hex(remoterev))
- fm.data(bookmarks=fm.formatlist(bms, name='bookmark'))
+ if 'bookmarks' in fm.datahint():
+ fm.data(bookmarks=fm.formatlist(getbms(), name='bookmark'))
else:
if rev:
repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list