annotate: check and update command options first
authorYuya Nishihara <yuya@tcha.org>
Sat, 24 Nov 2018 18:38:44 +0900
changeset 40715 e7d6a9082bdf
parent 40714 7c25d2233d53
child 40716 d4c550c703d7
annotate: check and update command options first It helps extracting helper class.
mercurial/commands.py
--- a/mercurial/commands.py	Sat Nov 24 18:36:44 2018 +0900
+++ b/mercurial/commands.py	Sat Nov 24 18:38:44 2018 +0900
@@ -320,6 +320,14 @@
         # 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 @@
         '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():