Mercurial > public > mercurial-scm > hg-stable
diff mercurial/debugcommands.py @ 30957:a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Wed, 01 Feb 2017 17:41:12 +0100 |
parents | 8de38479d60b |
children | 23c801570449 |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Wed Feb 01 17:40:20 2017 +0100 +++ b/mercurial/debugcommands.py Wed Feb 01 17:41:12 2017 +0100 @@ -1142,6 +1142,26 @@ if ui.verbose: printrecords(2) +@command('debugnamecomplete', [], _('NAME...')) +def debugnamecomplete(ui, repo, *args): + '''complete "names" - tags, open branch names, bookmark names''' + + names = set() + # since we previously only listed open branches, we will handle that + # specially (after this for loop) + for name, ns in repo.names.iteritems(): + if name != 'branches': + names.update(ns.listnames(repo)) + names.update(tag for (tag, heads, tip, closed) + in repo.branchmap().iterbranches() if not closed) + completions = set() + if not args: + args = [''] + for a in args: + completions.update(n for n in names if n.startswith(a)) + ui.write('\n'.join(sorted(completions))) + ui.write('\n') + @command('debugupgraderepo', [ ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), ('', 'run', False, _('performs an upgrade')),