src/topic/__init__.py
changeset 1848 9a81657deec2
parent 1847 9fa5b8f4e98e
child 1849 9218f91619f6
equal deleted inserted replaced
1847:9fa5b8f4e98e 1848:9a81657deec2
    10 This is sort of similar to a bookmark, but it applies to a whole
    10 This is sort of similar to a bookmark, but it applies to a whole
    11 series instead of a single revision.
    11 series instead of a single revision.
    12 """
    12 """
    13 import functools
    13 import functools
    14 
    14 
       
    15 from mercurial.i18n import _
    15 from mercurial import cmdutil
    16 from mercurial import cmdutil
    16 from mercurial import commands
    17 from mercurial import commands
    17 from mercurial import context
    18 from mercurial import context
    18 from mercurial import extensions
    19 from mercurial import extensions
    19 from mercurial import namespaces
    20 from mercurial import namespaces
   118     current = repo.currenttopic
   119     current = repo.currenttopic
   119     for t in sorted(repo.topics):
   120     for t in sorted(repo.topics):
   120         marker = '*' if t == current else ' '
   121         marker = '*' if t == current else ' '
   121         ui.write(' %s %s\n' % (marker, t))
   122         ui.write(' %s %s\n' % (marker, t))
   122 
   123 
       
   124 def summaryhook(ui, repo):
       
   125     t = repo.currenttopic
       
   126     if not t:
       
   127         return
       
   128     # i18n: column positioning for "hg summary"
       
   129     ui.write(_("topic:  %s\n") % t)
   123 
   130 
   124 def updatewrap(orig, ui, repo, *args, **kwargs):
   131 def updatewrap(orig, ui, repo, *args, **kwargs):
   125     ret = orig(ui, repo, *args, **kwargs)
   132     ret = orig(ui, repo, *args, **kwargs)
   126     pctx = repo['.']
   133     pctx = repo['.']
   127     if pctx.phase() == phases.public and repo.vfs.exists('topic'):
   134     if pctx.phase() == phases.public and repo.vfs.exists('topic'):
   134                 f.write(t)
   141                 f.write(t)
   135     return ret
   142     return ret
   136 
   143 
   137 extensions.wrapcommand(commands.table, 'update', updatewrap)
   144 extensions.wrapcommand(commands.table, 'update', updatewrap)
   138 topicrevset.modsetup()
   145 topicrevset.modsetup()
       
   146 cmdutil.summaryhooks.add('topic', summaryhook)