hgext/histedit.py
changeset 27203 b6a0f0895a25
parent 27202 2226cd4f32ed
child 27204 6b77e749af4a
--- a/hgext/histedit.py	Wed Dec 02 12:19:01 2015 -0800
+++ b/hgext/histedit.py	Wed Dec 02 12:19:01 2015 -0800
@@ -359,6 +359,23 @@
             raise error.Abort(_('unknown changeset %s listed')
                               % ha[:12])
 
+    def torule(self):
+        """build a histedit rule line for an action
+
+        by default lines are in the form:
+        <hash> <rev> <summary>
+        """
+        ctx = self.repo[self.node]
+        summary = ''
+        if ctx.description():
+            summary = ctx.description().splitlines()[0]
+        line = '%s %s %d %s' % (self.verb, ctx, ctx.rev(), summary)
+        # trim to 75 columns by default so it's not stupidly wide in my editor
+        # (the 5 more are left for verb)
+        maxlen = self.repo.ui.configint('histedit', 'linelen', default=80)
+        maxlen = max(maxlen, 22) # avoid truncating hash
+        return util.ellipsis(line, maxlen)
+
     def constraints(self):
         """Return a set of constrains that this action should be verified for
         """