[PATCH 1 of 3 topic-ext] commit: add a --topic flag

Matt Mackall mpm at selenic.com
Fri Jun 12 20:49:52 UTC 2015


# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1433974395 18000
#      Wed Jun 10 17:13:15 2015 -0500
# Node ID 0da6bf86b718a4da38a2d79c6d7bc758c19ce2f6
# Parent  9218f91619f6ad719b9b4eb5a0135d9c3f944923
commit: add a --topic flag

diff -r 9218f91619f6 -r 0da6bf86b718 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)


More information about the Mercurial-devel mailing list