changeset 1850:0da6bf86b718

commit: add a --topic flag
author Matt Mackall <mpm@selenic.com>
date Wed, 10 Jun 2015 17:13:15 -0500
parents 9218f91619f6
children 67d53e8e0c1a
files src/topic/__init__.py
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)