commit: add a --topic flag
authorMatt Mackall <mpm@selenic.com>
Wed, 10 Jun 2015 17:13:15 -0500
changeset 1850 0da6bf86b718
parent 1849 9218f91619f6
child 1851 67d53e8e0c1a
commit: add a --topic flag
src/topic/__init__.py
--- a/src/topic/__init__.py	Wed Jun 10 16:44:49 2015 -0500
+++ b/src/topic/__init__.py	Wed Jun 10 17:13:15 2015 -0500
@@ -128,6 +128,13 @@
     # i18n: column positioning for "hg summary"
     ui.write(_("topic:  %s\n") % t)
 
+def commitwrap(orig, ui, repo, *args, **opts):
+    if opts.get('topic'):
+        t = opts['topic']
+        with repo.vfs.open('topic', 'w') as f:
+            f.write(t)
+    return orig(ui, repo, *args, **opts)
+
 def updatewrap(orig, ui, repo, *args, **kwargs):
     ret = orig(ui, repo, *args, **kwargs)
     pctx = repo['.']
@@ -144,6 +151,10 @@
                 ui.status(_("switching to topic %s\n") % t)
     return ret
 
+entry = extensions.wrapcommand(commands.table, 'commit', commitwrap)
+entry[1].append(('t', 'topic', '',
+                 _("use specified topic"), _('TOPIC')))
+
 extensions.wrapcommand(commands.table, 'update', updatewrap)
 topicrevset.modsetup()
 cmdutil.summaryhooks.add('topic', summaryhook)