hgext3rd/topic/__init__.py
branchmercurial-4.3
changeset 3418 85cdce113c2c
parent 3380 62f742d144da
parent 3405 5813075618b4
child 3435 4fdcb81a2dd9
--- a/hgext3rd/topic/__init__.py	Sat Dec 16 23:40:39 2017 +0100
+++ b/hgext3rd/topic/__init__.py	Tue Jan 16 04:35:34 2018 +0100
@@ -127,6 +127,7 @@
     registrar,
     scmutil,
     templatefilters,
+    templatekw,
     util,
 )
 
@@ -174,7 +175,7 @@
               'topic.active': 'green',
              }
 
-__version__ = '0.6.1.dev'
+__version__ = '0.7.0'
 
 testedwith = '4.1.3 4.2.3 4.3.3 4.4.2'
 minimumhgversion = '4.1'
@@ -325,6 +326,7 @@
 
     cmdutil.summaryhooks.add('topic', summaryhook)
 
+    templatekw.keywords['topic'] = topickw
     # Wrap workingctx extra to return the topic name
     extensions.wrapfunction(context.workingctx, '__init__', wrapinit)
     # Wrap changelog.add to drop empty topic
@@ -491,6 +493,10 @@
             'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
             listnames=lambda repo: repo.topics))
 
+def topickw(**args):
+    """:topic: String. The topic of the changeset"""
+    return args['ctx'].topic()
+
 def wrapinit(orig, self, repo, *args, **kwargs):
     orig(self, repo, *args, **kwargs)
     if getattr(repo, 'currenttopic', ''):
@@ -903,6 +909,9 @@
         fm.write('topic', namemask, topic, label=label)
         fm.data(active=active)
 
+        if ui.quiet:
+            fm.plain('\n')
+            continue
         data = stack.stack(repo, topic=topic)
         fm.plain(' (')
         if ui.verbose:
@@ -1009,16 +1018,7 @@
                     user = marker.metadata().get('user', user)
                     maxtime = rt
 
-        # Making the username more better
-        username = None
-        if user:
-            # user is of form "abc <abc@xyz.com>"
-            username = user.split('<')[0]
-            if not username:
-                # user is of form "<abc@xyz.com>"
-                username = user[1:-1]
-            username = username.strip()
-
+        username = stack.parseusername(user)
         topicuser = (t, username)
 
         if trevs: