From patchwork Wed Jan 7 22:02:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,4] debugnamecomplete: rename from debuglabelcomplete From: Sean Farley X-Patchwork-Id: 7363 Message-Id: <45b4fd36ec5d9dc4c20a.1420668134@laptop.local> To: mercurial-devel@selenic.com Cc: --confirm@waste.org Date: Wed, 07 Jan 2015 14:02:14 -0800 # HG changeset patch # User Sean Farley # Date 1413578489 25200 # Fri Oct 17 13:41:29 2014 -0700 # Node ID 45b4fd36ec5d9dc4c20a2f0b17c277d2c950e4fa # Parent f160a3816c78174022f29f623b27cc08768a0135 debugnamecomplete: rename from debuglabelcomplete Now that we have decided on the use of 'name' instead of 'label' we rename this function accordingly. The old method 'debuglabelcomplete' has been left as a deprecated command so that current scripts don't break. diff --git a/contrib/bash_completion b/contrib/bash_completion --- a/contrib/bash_completion +++ b/contrib/bash_completion @@ -108,11 +108,11 @@ shopt -s extglob COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$bookmarks' -- "$cur")) } _hg_labels() { - local labels="$(_hg_cmd debuglabelcomplete "$cur")" + local labels="$(_hg_cmd debugnamecomplete "$cur")" local IFS=$'\n' COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$labels' -- "$cur")) } # this is "kind of" ugly... diff --git a/contrib/zsh_completion b/contrib/zsh_completion --- a/contrib/zsh_completion +++ b/contrib/zsh_completion @@ -161,11 +161,11 @@ typeset -A _hg_cmd_globals compset -P 1 '*:' _hg_labels "$@" } _hg_labels() { - labels=("${(f)$(_hg_cmd debuglabelcomplete)}") + labels=("${(f)$(_hg_cmd debugnamecomplete)}") (( $#labels )) && _describe -t labels 'labels' labels } _hg_bookmarks() { typeset -a bookmark bookmarks diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2342,22 +2342,27 @@ def debugknown(ui, repopath, *ids, **opt 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._bookmarks.keys()) - labels.update(tag for (tag, heads, tip, closed) - in repo.branchmap().iterbranches() if not closed) + '''backwards compatibility with old bash completion scripts (DEPRECATED)''' + debugnamecomplete(ui, repo, *args) + +@command('debugnamecomplete', [], _('NAME...')) +def debugnamecomplete(ui, repo, *args): + '''complete "names" - tags, open branch names, bookmark names''' + + names = set() + names.update(t[0] for t in repo.tagslist()) + names.update(repo._bookmarks.keys()) + 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(l for l in labels if l.startswith(a)) + completions.update(n for n in names if n.startswith(a)) ui.write('\n'.join(sorted(completions))) ui.write('\n') @command('debuglocks', [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')), diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -88,10 +88,11 @@ Show debug commands if there are no othe debugindexdot debuginstall debugknown debuglabelcomplete debuglocks + debugnamecomplete debugobsolete debugpathcomplete debugpushkey debugpvec debugrebuilddirstate @@ -245,10 +246,11 @@ Show all commands + options debugindexdot: debuginstall: debugknown: debuglabelcomplete: debuglocks: force-lock, force-wlock + debugnamecomplete: debugobsolete: flags, record-parents, rev, date, user debugpathcomplete: full, normal, added, removed debugpushkey: debugpvec: debugrebuilddirstate: rev @@ -319,18 +321,18 @@ Test debugpathcomplete $ hg rm Fum $ hg debugpathcomplete -r F Fum -Test debuglabelcomplete +Test debugnamecomplete - $ hg debuglabelcomplete + $ hg debugnamecomplete Fum default fee fie fo tip - $ hg debuglabelcomplete f + $ hg debugnamecomplete f fee fie fo diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -778,13 +778,13 @@ Test list of internal help commands debugindex dump the contents of an index file debugindexdot dump an index DAG as a graphviz dot file debuginstall test Mercurial installation debugknown test whether node ids are known to a repo - debuglabelcomplete - complete "labels" - tags, open branch names, bookmark names debuglocks show or modify state of locks + debugnamecomplete + complete "names" - tags, open branch names, bookmark names debugobsolete create arbitrary obsolete marker debugoptDEP (no help text available) debugpathcomplete complete part or all of a tracked path