Patchwork [topic-ext] topics: add listnames hook so completion works

login
register
mail settings
Submitter Matt Mackall
Date June 15, 2015, 9:58 p.m.
Message ID <ca2b4e5329fe018fc127.1434405504@ruin.waste.org>
Download mbox | patch
Permalink /patch/9652/
State Accepted
Headers show

Comments

Matt Mackall - June 15, 2015, 9:58 p.m.
# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 1434405404 18000
#      Mon Jun 15 16:56:44 2015 -0500
# Node ID ca2b4e5329fe018fc1279694cc89f74a7d6f4ccd
# Parent  375b9ccb7f25fde4dcf2b61a29ff282396544abe
topics: add listnames hook so completion works
Augie Fackler - June 16, 2015, 4:07 p.m.
On Mon, Jun 15, 2015 at 04:58:24PM -0500, Matt Mackall wrote:
> # HG changeset patch
> # User Matt Mackall <mpm@selenic.com>
> # Date 1434405404 18000
> #      Mon Jun 15 16:56:44 2015 -0500
> # Node ID ca2b4e5329fe018fc1279694cc89f74a7d6f4ccd
> # Parent  375b9ccb7f25fde4dcf2b61a29ff282396544abe
> topics: add listnames hook so completion works

Queued for topics, thanks.

>
> diff -r 375b9ccb7f25 -r ca2b4e5329fe src/topic/__init__.py
> --- a/src/topic/__init__.py	Fri Jun 12 16:49:46 2015 -0500
> +++ b/src/topic/__init__.py	Mon Jun 15 16:56:44 2015 -0500
> @@ -62,10 +62,11 @@
>          def currenttopic(self):
>              return self.vfs.tryread('topic')
>
> +    repo.__class__ = topicrepo
>      if util.safehasattr(repo, 'names'):
>          repo.names.addnamespace(namespaces.namespace(
> -            'topics', 'topic', namemap=_namemap, nodemap=_nodemap))
> -    repo.__class__ = topicrepo
> +            'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
> +            listnames=lambda repo: repo.topics))
>
>  @command('topics [TOPIC]', [
>      ('', 'clear', False, 'clear active topic if any'),
> diff -r 375b9ccb7f25 -r ca2b4e5329fe tests/test-topic.t
> --- a/tests/test-topic.t	Fri Jun 12 16:49:46 2015 -0500
> +++ b/tests/test-topic.t	Mon Jun 15 16:56:44 2015 -0500
> @@ -263,6 +263,12 @@
>       fran
>     * narf
>       query
> +  $ hg debugnamecomplete
> +  default
> +  fran
> +  narf
> +  query
> +  tip
>    $ hg phase --public narf
>
>  POSSIBLE BUG: narf topic stays alive even though we just made all
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - June 16, 2015, 4:10 p.m.
On Mon, Jun 15, 2015 at 04:58:24PM -0500, Matt Mackall wrote:
> # HG changeset patch
> # User Matt Mackall <mpm@selenic.com>
> # Date 1434405404 18000
> #      Mon Jun 15 16:56:44 2015 -0500
> # Node ID ca2b4e5329fe018fc1279694cc89f74a7d6f4ccd
> # Parent  375b9ccb7f25fde4dcf2b61a29ff282396544abe
> topics: add listnames hook so completion works
>
> diff -r 375b9ccb7f25 -r ca2b4e5329fe src/topic/__init__.py
> --- a/src/topic/__init__.py	Fri Jun 12 16:49:46 2015 -0500
> +++ b/src/topic/__init__.py	Mon Jun 15 16:56:44 2015 -0500
> @@ -62,10 +62,11 @@
>          def currenttopic(self):
>              return self.vfs.tryread('topic')
>
> +    repo.__class__ = topicrepo
>      if util.safehasattr(repo, 'names'):
>          repo.names.addnamespace(namespaces.namespace(
> -            'topics', 'topic', namemap=_namemap, nodemap=_nodemap))
> -    repo.__class__ = topicrepo
> +            'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
> +            listnames=lambda repo: repo.topics))
>
>  @command('topics [TOPIC]', [
>      ('', 'clear', False, 'clear active topic if any'),
> diff -r 375b9ccb7f25 -r ca2b4e5329fe tests/test-topic.t
> --- a/tests/test-topic.t	Fri Jun 12 16:49:46 2015 -0500
> +++ b/tests/test-topic.t	Mon Jun 15 16:56:44 2015 -0500
> @@ -263,6 +263,12 @@
>       fran
>     * narf
>       query
> +  $ hg debugnamecomplete
>

The test fails for me here:


+  ** Unknown exception encountered with possibly-broken third-party extension topic
+  ** which supports versions unknown of Mercurial.
+  ** Please disable topic and try your action again.
+  ** If that fixes the bug please report it to the extension author.
+  ** Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2]
+  ** Mercurial Distributed SCM (version 3.4.1+651-a69983942fb4)
+  ** Extensions loaded: rebase, topic
+  Traceback (most recent call last):
+    File "/opt/hg/bin/hg", line 43, in <module>
+      mercurial.dispatch.run()
+    File "/opt/hg/lib/python/mercurial/dispatch.py", line 30, in run
+      sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
+    File "/opt/hg/lib/python/mercurial/dispatch.py", line 92, in dispatch
+      ret = _runcatch(req)
+    File "/opt/hg/lib/python/mercurial/dispatch.py", line 162, in _runcatch
+      return _dispatch(req)
+    File "/opt/hg/lib/python/mercurial/dispatch.py", line 894, in _dispatch
+      cmdpats, cmdoptions)
+    File "/opt/hg/lib/python/mercurial/dispatch.py", line 655, in runcommand
+      ret = _runcommand(ui, options, cmd, d)
+    File "/opt/hg/lib/python/mercurial/dispatch.py", line 1011, in _runcommand
+      return checkargs()
+    File "/opt/hg/lib/python/mercurial/dispatch.py", line 980, in checkargs
+      return cmdfunc()
+    File "/opt/hg/lib/python/mercurial/dispatch.py", line 891, in <lambda>
+      d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
+    File "/opt/hg/lib/python/mercurial/util.py", line 793, in check
+      return func(*args, **kwargs)
+    File "/opt/hg/lib/python/mercurial/commands.py", line 2449, in debugnamecomplete
+      names.update(ns.listnames(repo))
+  TypeError: 'NoneType' object is not callable
+  [1]

Any idea what's up?

> +  default
> +  fran
> +  narf
> +  query
> +  tip
>    $ hg phase --public narf
>
>  POSSIBLE BUG: narf topic stays alive even though we just made all
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Matt Mackall - June 16, 2015, 5:40 p.m.
On Tue, 2015-06-16 at 12:10 -0400, Augie Fackler wrote:
> On Mon, Jun 15, 2015 at 04:58:24PM -0500, Matt Mackall wrote:
> > # HG changeset patch
> > # User Matt Mackall <mpm@selenic.com>
> > # Date 1434405404 18000
> > #      Mon Jun 15 16:56:44 2015 -0500
> > # Node ID ca2b4e5329fe018fc1279694cc89f74a7d6f4ccd
> > # Parent  375b9ccb7f25fde4dcf2b61a29ff282396544abe
> > topics: add listnames hook so completion works
> >
> > diff -r 375b9ccb7f25 -r ca2b4e5329fe src/topic/__init__.py
> > --- a/src/topic/__init__.py	Fri Jun 12 16:49:46 2015 -0500
> > +++ b/src/topic/__init__.py	Mon Jun 15 16:56:44 2015 -0500
> > @@ -62,10 +62,11 @@
> >          def currenttopic(self):
> >              return self.vfs.tryread('topic')
> >
> > +    repo.__class__ = topicrepo
> >      if util.safehasattr(repo, 'names'):
> >          repo.names.addnamespace(namespaces.namespace(
> > -            'topics', 'topic', namemap=_namemap, nodemap=_nodemap))
> > -    repo.__class__ = topicrepo
> > +            'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
> > +            listnames=lambda repo: repo.topics))
> >
> >  @command('topics [TOPIC]', [
> >      ('', 'clear', False, 'clear active topic if any'),
> > diff -r 375b9ccb7f25 -r ca2b4e5329fe tests/test-topic.t
> > --- a/tests/test-topic.t	Fri Jun 12 16:49:46 2015 -0500
> > +++ b/tests/test-topic.t	Mon Jun 15 16:56:44 2015 -0500
> > @@ -263,6 +263,12 @@
> >       fran
> >     * narf
> >       query
> > +  $ hg debugnamecomplete
> >
> 
> The test fails for me here:
> 
> 
> +  ** Unknown exception encountered with possibly-broken third-party extension topic
> +  ** which supports versions unknown of Mercurial.
> +  ** Please disable topic and try your action again.
> +  ** If that fixes the bug please report it to the extension author.
> +  ** Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2]
> +  ** Mercurial Distributed SCM (version 3.4.1+651-a69983942fb4)
> +  ** Extensions loaded: rebase, topic
> +  Traceback (most recent call last):
> +    File "/opt/hg/bin/hg", line 43, in <module>
> +      mercurial.dispatch.run()
> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 30, in run
> +      sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 92, in dispatch
> +      ret = _runcatch(req)
> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 162, in _runcatch
> +      return _dispatch(req)
> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 894, in _dispatch
> +      cmdpats, cmdoptions)
> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 655, in runcommand
> +      ret = _runcommand(ui, options, cmd, d)
> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 1011, in _runcommand
> +      return checkargs()
> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 980, in checkargs
> +      return cmdfunc()
> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 891, in <lambda>
> +      d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
> +    File "/opt/hg/lib/python/mercurial/util.py", line 793, in check
> +      return func(*args, **kwargs)
> +    File "/opt/hg/lib/python/mercurial/commands.py", line 2449, in debugnamecomplete
> +      names.update(ns.listnames(repo))
> +  TypeError: 'NoneType' object is not callable
> +  [1]
> 
> Any idea what's up?

That looks exactly like the behavior before my patch? Sure it applied?
Augie Fackler - June 16, 2015, 5:41 p.m.
On Tue, Jun 16, 2015 at 1:40 PM, Matt Mackall <mpm@selenic.com> wrote:
> On Tue, 2015-06-16 at 12:10 -0400, Augie Fackler wrote:
>> On Mon, Jun 15, 2015 at 04:58:24PM -0500, Matt Mackall wrote:
>> > # HG changeset patch
>> > # User Matt Mackall <mpm@selenic.com>
>> > # Date 1434405404 18000
>> > #      Mon Jun 15 16:56:44 2015 -0500
>> > # Node ID ca2b4e5329fe018fc1279694cc89f74a7d6f4ccd
>> > # Parent  375b9ccb7f25fde4dcf2b61a29ff282396544abe
>> > topics: add listnames hook so completion works
>> >
>> > diff -r 375b9ccb7f25 -r ca2b4e5329fe src/topic/__init__.py
>> > --- a/src/topic/__init__.py Fri Jun 12 16:49:46 2015 -0500
>> > +++ b/src/topic/__init__.py Mon Jun 15 16:56:44 2015 -0500
>> > @@ -62,10 +62,11 @@
>> >          def currenttopic(self):
>> >              return self.vfs.tryread('topic')
>> >
>> > +    repo.__class__ = topicrepo
>> >      if util.safehasattr(repo, 'names'):
>> >          repo.names.addnamespace(namespaces.namespace(
>> > -            'topics', 'topic', namemap=_namemap, nodemap=_nodemap))
>> > -    repo.__class__ = topicrepo
>> > +            'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
>> > +            listnames=lambda repo: repo.topics))
>> >
>> >  @command('topics [TOPIC]', [
>> >      ('', 'clear', False, 'clear active topic if any'),
>> > diff -r 375b9ccb7f25 -r ca2b4e5329fe tests/test-topic.t
>> > --- a/tests/test-topic.t    Fri Jun 12 16:49:46 2015 -0500
>> > +++ b/tests/test-topic.t    Mon Jun 15 16:56:44 2015 -0500
>> > @@ -263,6 +263,12 @@
>> >       fran
>> >     * narf
>> >       query
>> > +  $ hg debugnamecomplete
>> >
>>
>> The test fails for me here:
>>
>>
>> +  ** Unknown exception encountered with possibly-broken third-party extension topic
>> +  ** which supports versions unknown of Mercurial.
>> +  ** Please disable topic and try your action again.
>> +  ** If that fixes the bug please report it to the extension author.
>> +  ** Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2]
>> +  ** Mercurial Distributed SCM (version 3.4.1+651-a69983942fb4)
>> +  ** Extensions loaded: rebase, topic
>> +  Traceback (most recent call last):
>> +    File "/opt/hg/bin/hg", line 43, in <module>
>> +      mercurial.dispatch.run()
>> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 30, in run
>> +      sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
>> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 92, in dispatch
>> +      ret = _runcatch(req)
>> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 162, in _runcatch
>> +      return _dispatch(req)
>> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 894, in _dispatch
>> +      cmdpats, cmdoptions)
>> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 655, in runcommand
>> +      ret = _runcommand(ui, options, cmd, d)
>> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 1011, in _runcommand
>> +      return checkargs()
>> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 980, in checkargs
>> +      return cmdfunc()
>> +    File "/opt/hg/lib/python/mercurial/dispatch.py", line 891, in <lambda>
>> +      d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
>> +    File "/opt/hg/lib/python/mercurial/util.py", line 793, in check
>> +      return func(*args, **kwargs)
>> +    File "/opt/hg/lib/python/mercurial/commands.py", line 2449, in debugnamecomplete
>> +      names.update(ns.listnames(repo))
>> +  TypeError: 'NoneType' object is not callable
>> +  [1]
>>
>> Any idea what's up?
>
> That looks exactly like the behavior before my patch? Sure it applied?


Pretty sure. I'll look again in a bit.

Patch

diff -r 375b9ccb7f25 -r ca2b4e5329fe src/topic/__init__.py
--- a/src/topic/__init__.py	Fri Jun 12 16:49:46 2015 -0500
+++ b/src/topic/__init__.py	Mon Jun 15 16:56:44 2015 -0500
@@ -62,10 +62,11 @@ 
         def currenttopic(self):
             return self.vfs.tryread('topic')
 
+    repo.__class__ = topicrepo
     if util.safehasattr(repo, 'names'):
         repo.names.addnamespace(namespaces.namespace(
-            'topics', 'topic', namemap=_namemap, nodemap=_nodemap))
-    repo.__class__ = topicrepo
+            'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
+            listnames=lambda repo: repo.topics))
 
 @command('topics [TOPIC]', [
     ('', 'clear', False, 'clear active topic if any'),
diff -r 375b9ccb7f25 -r ca2b4e5329fe tests/test-topic.t
--- a/tests/test-topic.t	Fri Jun 12 16:49:46 2015 -0500
+++ b/tests/test-topic.t	Mon Jun 15 16:56:44 2015 -0500
@@ -263,6 +263,12 @@ 
      fran
    * narf
      query
+  $ hg debugnamecomplete
+  default
+  fran
+  narf
+  query
+  tip
   $ hg phase --public narf
 
 POSSIBLE BUG: narf topic stays alive even though we just made all