hgext3rd/topic/__init__.py
branchmercurial-4.3
changeset 3418 85cdce113c2c
parent 3380 62f742d144da
parent 3405 5813075618b4
child 3435 4fdcb81a2dd9
equal deleted inserted replaced
3380:62f742d144da 3418:85cdce113c2c
   125     patch,
   125     patch,
   126     phases,
   126     phases,
   127     registrar,
   127     registrar,
   128     scmutil,
   128     scmutil,
   129     templatefilters,
   129     templatefilters,
       
   130     templatekw,
   130     util,
   131     util,
   131 )
   132 )
   132 
   133 
   133 from . import (
   134 from . import (
   134     compat,
   135     compat,
   172               # (first pick I could think off, update as needed
   173               # (first pick I could think off, update as needed
   173               'log.topic': 'green_background',
   174               'log.topic': 'green_background',
   174               'topic.active': 'green',
   175               'topic.active': 'green',
   175              }
   176              }
   176 
   177 
   177 __version__ = '0.6.1.dev'
   178 __version__ = '0.7.0'
   178 
   179 
   179 testedwith = '4.1.3 4.2.3 4.3.3 4.4.2'
   180 testedwith = '4.1.3 4.2.3 4.3.3 4.4.2'
   180 minimumhgversion = '4.1'
   181 minimumhgversion = '4.1'
   181 buglink = 'https://bz.mercurial-scm.org/'
   182 buglink = 'https://bz.mercurial-scm.org/'
   182 
   183 
   323     except (KeyError, AttributeError):
   324     except (KeyError, AttributeError):
   324         pass
   325         pass
   325 
   326 
   326     cmdutil.summaryhooks.add('topic', summaryhook)
   327     cmdutil.summaryhooks.add('topic', summaryhook)
   327 
   328 
       
   329     templatekw.keywords['topic'] = topickw
   328     # Wrap workingctx extra to return the topic name
   330     # Wrap workingctx extra to return the topic name
   329     extensions.wrapfunction(context.workingctx, '__init__', wrapinit)
   331     extensions.wrapfunction(context.workingctx, '__init__', wrapinit)
   330     # Wrap changelog.add to drop empty topic
   332     # Wrap changelog.add to drop empty topic
   331     extensions.wrapfunction(changelog.changelog, 'add', wrapadd)
   333     extensions.wrapfunction(changelog.changelog, 'add', wrapadd)
   332 
   334 
   488     repo._topics = None
   490     repo._topics = None
   489     if util.safehasattr(repo, 'names'):
   491     if util.safehasattr(repo, 'names'):
   490         repo.names.addnamespace(namespaces.namespace(
   492         repo.names.addnamespace(namespaces.namespace(
   491             'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
   493             'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
   492             listnames=lambda repo: repo.topics))
   494             listnames=lambda repo: repo.topics))
       
   495 
       
   496 def topickw(**args):
       
   497     """:topic: String. The topic of the changeset"""
       
   498     return args['ctx'].topic()
   493 
   499 
   494 def wrapinit(orig, self, repo, *args, **kwargs):
   500 def wrapinit(orig, self, repo, *args, **kwargs):
   495     orig(self, repo, *args, **kwargs)
   501     orig(self, repo, *args, **kwargs)
   496     if getattr(repo, 'currenttopic', ''):
   502     if getattr(repo, 'currenttopic', ''):
   497         self._extra[constants.extrakey] = repo.currenttopic
   503         self._extra[constants.extrakey] = repo.currenttopic
   901             # registering the active data is made explicitly later
   907             # registering the active data is made explicitly later
   902             fm.plain(' %s ' % marker, label=label)
   908             fm.plain(' %s ' % marker, label=label)
   903         fm.write('topic', namemask, topic, label=label)
   909         fm.write('topic', namemask, topic, label=label)
   904         fm.data(active=active)
   910         fm.data(active=active)
   905 
   911 
       
   912         if ui.quiet:
       
   913             fm.plain('\n')
       
   914             continue
   906         data = stack.stack(repo, topic=topic)
   915         data = stack.stack(repo, topic=topic)
   907         fm.plain(' (')
   916         fm.plain(' (')
   908         if ui.verbose:
   917         if ui.verbose:
   909             fm.write('branches+', 'on branch: %s',
   918             fm.write('branches+', 'on branch: %s',
   910                      '+'.join(data.branches), # XXX use list directly after 4.0 is released
   919                      '+'.join(data.branches), # XXX use list directly after 4.0 is released
  1007                 rt = marker.date()
  1016                 rt = marker.date()
  1008                 if rt[0] > maxtime[0]:
  1017                 if rt[0] > maxtime[0]:
  1009                     user = marker.metadata().get('user', user)
  1018                     user = marker.metadata().get('user', user)
  1010                     maxtime = rt
  1019                     maxtime = rt
  1011 
  1020 
  1012         # Making the username more better
  1021         username = stack.parseusername(user)
  1013         username = None
       
  1014         if user:
       
  1015             # user is of form "abc <abc@xyz.com>"
       
  1016             username = user.split('<')[0]
       
  1017             if not username:
       
  1018                 # user is of form "<abc@xyz.com>"
       
  1019                 username = user[1:-1]
       
  1020             username = username.strip()
       
  1021 
       
  1022         topicuser = (t, username)
  1022         topicuser = (t, username)
  1023 
  1023 
  1024         if trevs:
  1024         if trevs:
  1025             secspassed = (curtime - maxtime[0])
  1025             secspassed = (curtime - maxtime[0])
  1026         try:
  1026         try: