changeset 29467:4c4232e51167

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.
author Sean Farley <sean@farley.io>
date Fri, 27 May 2016 14:00:12 -0700
parents a0efbfbba7b5
children 04b68ce5e964
files hgext/histedit.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Thu May 26 15:43:00 2016 -0700
+++ b/hgext/histedit.py	Fri May 27 14:00:12 2016 -0700
@@ -1269,6 +1269,14 @@
                                     '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: