src/topic/__init__.py
changeset 1850 0da6bf86b718
parent 1849 9218f91619f6
child 1851 67d53e8e0c1a
equal deleted inserted replaced
1849:9218f91619f6 1850:0da6bf86b718
   126     if not t:
   126     if not t:
   127         return
   127         return
   128     # i18n: column positioning for "hg summary"
   128     # i18n: column positioning for "hg summary"
   129     ui.write(_("topic:  %s\n") % t)
   129     ui.write(_("topic:  %s\n") % t)
   130 
   130 
       
   131 def commitwrap(orig, ui, repo, *args, **opts):
       
   132     if opts.get('topic'):
       
   133         t = opts['topic']
       
   134         with repo.vfs.open('topic', 'w') as f:
       
   135             f.write(t)
       
   136     return orig(ui, repo, *args, **opts)
       
   137 
   131 def updatewrap(orig, ui, repo, *args, **kwargs):
   138 def updatewrap(orig, ui, repo, *args, **kwargs):
   132     ret = orig(ui, repo, *args, **kwargs)
   139     ret = orig(ui, repo, *args, **kwargs)
   133     pctx = repo['.']
   140     pctx = repo['.']
   134     ot = repo.currenttopic
   141     ot = repo.currenttopic
   135     if pctx.phase() == phases.public and repo.vfs.exists('topic'):
   142     if pctx.phase() == phases.public and repo.vfs.exists('topic'):
   142                 f.write(t)
   149                 f.write(t)
   143             if t != ot:
   150             if t != ot:
   144                 ui.status(_("switching to topic %s\n") % t)
   151                 ui.status(_("switching to topic %s\n") % t)
   145     return ret
   152     return ret
   146 
   153 
       
   154 entry = extensions.wrapcommand(commands.table, 'commit', commitwrap)
       
   155 entry[1].append(('t', 'topic', '',
       
   156                  _("use specified topic"), _('TOPIC')))
       
   157 
   147 extensions.wrapcommand(commands.table, 'update', updatewrap)
   158 extensions.wrapcommand(commands.table, 'update', updatewrap)
   148 topicrevset.modsetup()
   159 topicrevset.modsetup()
   149 cmdutil.summaryhooks.add('topic', summaryhook)
   160 cmdutil.summaryhooks.add('topic', summaryhook)