comparison 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
comparison
equal deleted inserted replaced
18789:fff3a8114510 18790:1e28a7f58f33
2069 repo = hg.peer(ui, opts, repopath) 2069 repo = hg.peer(ui, opts, repopath)
2070 if not repo.capable('known'): 2070 if not repo.capable('known'):
2071 raise util.Abort("known() not supported by target repository") 2071 raise util.Abort("known() not supported by target repository")
2072 flags = repo.known([bin(s) for s in ids]) 2072 flags = repo.known([bin(s) for s in ids])
2073 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) 2073 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2074
2075 @command('debuglabelcomplete', [], _('LABEL...'))
2076 def debuglabelcomplete(ui, repo, *args):
2077 '''complete "labels" - tags, open branch names, bookmark names'''
2078
2079 labels = set()
2080 labels.update(t[0] for t in repo.tagslist())
2081 labels.update(repo[n].branch() for n in repo.heads())
2082 labels.update(repo._bookmarks.keys())
2083 completions = set()
2084 if not args:
2085 args = ['']
2086 for a in args:
2087 completions.update(l for l in labels if l.startswith(a))
2088 ui.write('\n'.join(sorted(completions)))
2089 ui.write('\n')
2074 2090
2075 @command('debugobsolete', 2091 @command('debugobsolete',
2076 [('', 'flags', 0, _('markers flag')), 2092 [('', 'flags', 0, _('markers flag')),
2077 ] + commitopts2, 2093 ] + commitopts2,
2078 _('[OBSOLETED [REPLACEMENT] [REPL... ]')) 2094 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))