topics: add listnames hook so completion works
authorMatt Mackall <mpm@selenic.com>
Mon, 15 Jun 2015 16:56:44 -0500
changeset 1857 a506ed8ab8da
parent 1856 7d7f5f9e2f8c
child 1858 4ab1b854ce4e
topics: add listnames hook so completion works
src/topic/__init__.py
tests/test-topic.t
--- a/src/topic/__init__.py	Thu Jun 18 15:46:26 2015 -0400
+++ b/src/topic/__init__.py	Mon Jun 15 16:56:44 2015 -0500
@@ -63,10 +63,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'),
--- a/tests/test-topic.t	Thu Jun 18 15:46:26 2015 -0400
+++ 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