[PATCH 2 of 4] annotate: check and update command options first
Yuya Nishihara
yuya at tcha.org
Sat Nov 24 07:34:16 EST 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1543052324 -32400
# Sat Nov 24 18:38:44 2018 +0900
# Node ID b37d6fbea8df01bd7ea822435f4bfce2a97112e7
# Parent 4c5309a4bd4028c260fcc6ceda1ba48167e8733e
annotate: check and update command options first
It helps extracting helper class.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -320,6 +320,14 @@ def annotate(ui, repo, *pats, **opts):
# to mimic the behavior of Mercurial before version 1.5
opts['file'] = True
+ if (not opts.get('user') and not opts.get('changeset')
+ and not opts.get('date') and not opts.get('file')):
+ opts['number'] = True
+
+ linenumber = opts.get('line_number') is not None
+ if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
+ raise error.Abort(_('at least one of -n/-c is required for -l'))
+
rev = opts.get('rev')
if rev:
repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
@@ -373,14 +381,6 @@ def annotate(ui, repo, *pats, **opts):
'lineno': 'line_number',
}
- if (not opts.get('user') and not opts.get('changeset')
- and not opts.get('date') and not opts.get('file')):
- opts['number'] = True
-
- linenumber = opts.get('line_number') is not None
- if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
- raise error.Abort(_('at least one of -n/-c is required for -l'))
-
ui.pager('annotate')
if rootfm.isplain():
More information about the Mercurial-devel
mailing list