Patchwork [3,of,6] histedit: extract common summary code into method

login
register
mail settings
Submitter Sean Farley
Date June 21, 2016, 11:32 p.m.
Message ID <48edf19158a5ca7bcac9.1466551963@laptop.local>
Download mbox | patch
Permalink /patch/15568/
State Changes Requested
Headers show

Comments

Sean Farley - June 21, 2016, 11:32 p.m.
# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1464382812 25200
#      Fri May 27 14:00:12 2016 -0700
# Node ID 48edf19158a5ca7bcac95e815dba8e4d351ba4ee
# Parent  954822f6dc701096c48c61c9183d8f4c487c4773
# EXP-Topic autoverb
histedit: extract common summary code into method

Patch

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)