Patchwork [2,of,4] annotate: check and update command options first

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 24, 2018, 12:34 p.m.
Message ID <b37d6fbea8df01bd7ea8.1543062856@mimosa>
Download mbox | patch
Permalink /patch/36763/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 24, 2018, 12:34 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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():