Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 18790:1e28a7f58f33
completion: add a debuglabelcomplete command
When completing a "label" (a symbolic name for a commit), the
bash_completion script currently has to invoke hg three times. For
a large repository, the cost of starting up and loading all the
necessary context over and over is very high.
For instance, in mozilla-central:
time (export HGPLAIN=1; hg tags -q; hg bookmarks -q; hg branches) >/dev/null
0.446 sec
Compare with the debuglabelcomplete command that this commit adds:
time hg debuglabelcomplete >/dev/null
0.148 sec
This greatly helps responsiveness.
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Thu, 21 Mar 2013 10:51:18 -0700 |
parents | b99e62a9b7a2 |
children | 10669e24eb6c |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Mar 21 09:13:16 2013 -0700 +++ b/mercurial/commands.py Thu Mar 21 10:51:18 2013 -0700 @@ -2072,6 +2072,22 @@ flags = repo.known([bin(s) for s in ids]) ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) +@command('debuglabelcomplete', [], _('LABEL...')) +def debuglabelcomplete(ui, repo, *args): + '''complete "labels" - tags, open branch names, bookmark names''' + + labels = set() + labels.update(t[0] for t in repo.tagslist()) + labels.update(repo[n].branch() for n in repo.heads()) + labels.update(repo._bookmarks.keys()) + completions = set() + if not args: + args = [''] + for a in args: + completions.update(l for l in labels if l.startswith(a)) + ui.write('\n'.join(sorted(completions))) + ui.write('\n') + @command('debugobsolete', [('', 'flags', 0, _('markers flag')), ] + commitopts2,