Patchwork [STABLE] graft: use opts.get() consistently

login
register
mail settings
Submitter Gábor Stefanik
Date July 25, 2016, 3:01 p.m.
Message ID <8c2595fa5ecd6d1274b7.1469458892@waste.org>
Download mbox | patch
Permalink /patch/15984/
State Accepted
Headers show

Comments

Gábor Stefanik - July 25, 2016, 3:01 p.m.
# HG changeset patch
# User Gábor Stefanik <gabor.stefanik@nng.com>
# Date 1469458842 -7200
#      Mon Jul 25 17:00:42 2016 +0200
# Branch stable
# Node ID 8c2595fa5ecd6d1274b742ab818c7bb3e82c50ed
# Parent  9c2cc107547fd701a7604349632f2f590366f17c
graft: use opts.get() consistently

Make life easier for extension writers.
Augie Fackler - July 27, 2016, 1:14 p.m.
On Mon, Jul 25, 2016 at 10:01:32AM -0500, Gábor Stefanik wrote:
> # HG changeset patch
> # User Gábor Stefanik <gabor.stefanik@nng.com>
> # Date 1469458842 -7200
> #      Mon Jul 25 17:00:42 2016 +0200
> # Branch stable
> # Node ID 8c2595fa5ecd6d1274b742ab818c7bb3e82c50ed
> # Parent  9c2cc107547fd701a7604349632f2f590366f17c
> graft: use opts.get() consistently

I think this is borderline for stable, but I'll take it since it
probably helps extensions a ton.

>
> Make life easier for extension writers.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4089,12 +4089,12 @@
>          return _dograft(ui, repo, *revs, **opts)
>
>  def _dograft(ui, repo, *revs, **opts):
> -    if revs and opts['rev']:
> +    if revs and opts.get('rev'):
>          ui.warn(_('warning: inconsistent use of --rev might give unexpected '
>                    'revision ordering!\n'))
>
>      revs = list(revs)
> -    revs.extend(opts['rev'])
> +    revs.extend(opts.get('rev'))
>
>      if not opts.get('user') and opts.get('currentuser'):
>          opts['user'] = ui.username()
> @@ -4104,7 +4104,7 @@
>      editor = cmdutil.getcommiteditor(editform='graft', **opts)
>
>      cont = False
> -    if opts['continue']:
> +    if opts.get('continue'):
>          cont = True
>          if revs:
>              raise error.Abort(_("can't specify --continue and revisions"))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4089,12 +4089,12 @@ 
         return _dograft(ui, repo, *revs, **opts)
 
 def _dograft(ui, repo, *revs, **opts):
-    if revs and opts['rev']:
+    if revs and opts.get('rev'):
         ui.warn(_('warning: inconsistent use of --rev might give unexpected '
                   'revision ordering!\n'))
 
     revs = list(revs)
-    revs.extend(opts['rev'])
+    revs.extend(opts.get('rev'))
 
     if not opts.get('user') and opts.get('currentuser'):
         opts['user'] = ui.username()
@@ -4104,7 +4104,7 @@ 
     editor = cmdutil.getcommiteditor(editform='graft', **opts)
 
     cont = False
-    if opts['continue']:
+    if opts.get('continue'):
         cont = True
         if revs:
             raise error.Abort(_("can't specify --continue and revisions"))