# HG changeset patch # User Sean Farley # Date 2016-05-27 21:00:12 # Node ID 4c4232e511677f06f684bdbf532bdc9e4adf5c9a # Parent a0efbfbba7b5f97573766de9410e50cb4a6a201f 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 @@ -1269,6 +1269,14 @@ def _newhistedit(ui, repo, state, revs, '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: