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

login
register
mail settings
Submitter Sean Farley
Date June 30, 2016, 9:58 p.m.
Message ID <d60ce0a4d2fb05d70f83.1467323932@laptop.office.atlassian.com>
Download mbox | patch
Permalink /patch/15664/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Sean Farley - June 30, 2016, 9:58 p.m.
# HG changeset patch
# User Sean Farley <sean@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.

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)