[PATCH 3 of 6 V2] histedit: extract common summary code into method

Sean Farley sean at farley.io
Thu Jun 30 17:58:52 EDT 2016


# HG changeset patch
# User Sean Farley <sean at farley.io>
# Date 1464382812 25200
#      Fri May 27 14:00:12 2016 -0700
# Node ID d60ce0a4d2fb05d70f83b514474584a3e2ff3446
# Parent  b0e05869a929d0e2367e1815afdcada14499de5b
# EXP-Topic autoverb
histedit: extract common summary code into method

We're going to need to use this code in our autoverb logic so let's
extract it now and save ourselves from code duplication.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1267,10 +1267,18 @@ def _newhistedit(ui, repo, state, revs, 
     if not obsolete.isenabled(repo, obsolete.createmarkersopt):
         backupfile = repair._bundle(repo, [parentctxnode], [topmost], root,
                                     'histedit')
     state.backupfile = backupfile
 
+def _getsummary(ctx):
+    # a common pattern is to extract the summary but default to the empty
+    # string
+    summary = ctx.description() or ''
+    if summary:
+        summary = summary.splitlines()[0]
+    return summary
+
 def bootstrapcontinue(ui, state, opts):
     repo = state.repo
     if state.actions:
         actobj = state.actions.pop(0)
 


More information about the Mercurial-devel mailing list