Patchwork [09,of,12] debuglabelcomplete: use labels instead of hardcoding tags and bookmarks

login
register
mail settings
Submitter Sean Farley
Date Aug. 18, 2014, 9:18 p.m.
Message ID <186ccd3d9042c0c5ec8c.1408396685@1.0.0.127.in-addr.arpa>
Download mbox | patch
Permalink /patch/5467/
State Changes Requested
Headers show

Comments

Sean Farley - Aug. 18, 2014, 9:18 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1396319547 18000
#      Mon Mar 31 21:32:27 2014 -0500
# Node ID 186ccd3d9042c0c5ec8cb9b9b4d58a7386ea1c65
# Parent  5e3722e0076cc2a3c92758ff762e2916ce05e569
debuglabelcomplete: use labels instead of hardcoding tags and bookmarks

This allows bash completion for arbitrary labels.
Pierre-Yves David - Aug. 21, 2014, 7:57 a.m.
On 08/18/2014 02:18 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1396319547 18000
> #      Mon Mar 31 21:32:27 2014 -0500
> # Node ID 186ccd3d9042c0c5ec8cb9b9b4d58a7386ea1c65
> # Parent  5e3722e0076cc2a3c92758ff762e2916ce05e569
> debuglabelcomplete: use labels instead of hardcoding tags and bookmarks
>
> This allows bash completion for arbitrary labels.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -2293,12 +2293,12 @@ def debugknown(ui, repopath, *ids, **opt
>   @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())
> +    for namespace, l in repo.alllabels().iteritems():
> +        labels.update(name for name, node in l.iteritems())

if you are going to drop the value anyway. use iterkeys()


>       labels.update(tag for (tag, heads, tip, closed)
>                     in repo.branchmap().iterbranches() if not closed)
>       completions = set()
>       if not args:
>           args = ['']
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2293,12 +2293,12 @@  def debugknown(ui, repopath, *ids, **opt
 @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())
+    for namespace, l in repo.alllabels().iteritems():
+        labels.update(name for name, node in l.iteritems())
     labels.update(tag for (tag, heads, tip, closed)
                   in repo.branchmap().iterbranches() if not closed)
     completions = set()
     if not args:
         args = ['']