commitextras: no need to special case extras=[]
authorValentin Gatien-Baron <vgatien-baron@janestreet.com>
Mon, 27 Aug 2018 16:03:00 -0400
changeset 39295 3a60416c4fd8
parent 39294 1cb7c9777852
child 39296 ce145f8eface
commitextras: no need to special case extras=[] Differential Revision: https://phab.mercurial-scm.org/D4405
hgext/commitextras.py
--- a/hgext/commitextras.py	Mon Aug 27 16:01:55 2018 -0400
+++ b/hgext/commitextras.py	Mon Aug 27 16:03:00 2018 -0400
@@ -49,25 +49,24 @@
     class repoextra(repo.__class__):
         def commit(self, *innerpats, **inneropts):
             extras = opts.get(r'extra')
-            if extras:
-                for raw in extras:
-                    if '=' not in raw:
-                        msg = _("unable to parse '%s', should follow "
-                                "KEY=VALUE format")
-                        raise error.Abort(msg % raw)
-                    k, v = raw.split('=', 1)
-                    if not k:
-                        msg = _("unable to parse '%s', keys can't be empty")
-                        raise error.Abort(msg % raw)
-                    if re.search('[^\w-]', k):
-                        msg = _("keys can only contain ascii letters, digits,"
-                                " '_' and '-'")
-                        raise error.Abort(msg)
-                    if k in usedinternally:
-                        msg = _("key '%s' is used internally, can't be set "
-                                "manually")
-                        raise error.Abort(msg % k)
-                    inneropts[r'extra'][k] = v
+            for raw in extras:
+                if '=' not in raw:
+                    msg = _("unable to parse '%s', should follow "
+                            "KEY=VALUE format")
+                    raise error.Abort(msg % raw)
+                k, v = raw.split('=', 1)
+                if not k:
+                    msg = _("unable to parse '%s', keys can't be empty")
+                    raise error.Abort(msg % raw)
+                if re.search('[^\w-]', k):
+                    msg = _("keys can only contain ascii letters, digits,"
+                            " '_' and '-'")
+                    raise error.Abort(msg)
+                if k in usedinternally:
+                    msg = _("key '%s' is used internally, can't be set "
+                            "manually")
+                    raise error.Abort(msg % k)
+                inneropts[r'extra'][k] = v
             return super(repoextra, self).commit(*innerpats, **inneropts)
     repo.__class__ = repoextra
     return orig(ui, repo, *pats, **opts)