[Updated] [+- ] D10863: cmdutil: make resolvecommitoptions() work on str-keyed opts

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Jun 18 21:55:37 UTC 2021


martinvonz updated this revision to Diff 28605.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10863?vs=28543&id=28605

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10863/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D10863

AFFECTED FILES
  hgext/uncommit.py
  mercurial/cmdutil.py
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3104,8 +3104,8 @@
     # list of new nodes created by ongoing graft
     statedata[b'newnodes'] = []
 
+    cmdutil.resolve_commit_options(ui, opts)
     opts = pycompat.byteskwargs(opts)
-    cmdutil.resolvecommitoptions(ui, opts)
 
     editor = cmdutil.getcommiteditor(
         editform=b'graft', **pycompat.strkwargs(opts)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -301,29 +301,29 @@
         check_at_most_one_arg(opts, first, other)
 
 
-def resolvecommitoptions(ui, opts):
+def resolve_commit_options(ui, opts):
     """modify commit options dict to handle related options
 
     The return value indicates that ``rewrite.update-timestamp`` is the reason
     the ``date`` option is set.
     """
-    check_at_most_one_arg(opts, b'date', b'currentdate')
-    check_at_most_one_arg(opts, b'user', b'currentuser')
+    check_at_most_one_arg(opts, 'date', 'currentdate')
+    check_at_most_one_arg(opts, 'user', 'currentuser')
 
     datemaydiffer = False  # date-only change should be ignored?
 
-    if opts.get(b'currentdate'):
-        opts[b'date'] = b'%d %d' % dateutil.makedate()
+    if opts.get('currentdate'):
+        opts['date'] = b'%d %d' % dateutil.makedate()
     elif (
-        not opts.get(b'date')
+        not opts.get('date')
         and ui.configbool(b'rewrite', b'update-timestamp')
-        and opts.get(b'currentdate') is None
+        and opts.get('currentdate') is None
     ):
-        opts[b'date'] = b'%d %d' % dateutil.makedate()
+        opts['date'] = b'%d %d' % dateutil.makedate()
         datemaydiffer = True
 
-    if opts.get(b'currentuser'):
-        opts[b'user'] = ui.username()
+    if opts.get('currentuser'):
+        opts['user'] = ui.username()
 
     return datemaydiffer
 
@@ -2783,7 +2783,6 @@
 
 
 def amend(ui, repo, old, extra, pats, opts):
-    opts = pycompat.byteskwargs(opts)
     # avoid cycle context -> subrepo -> cmdutil
     from . import context
 
@@ -2816,7 +2815,8 @@
         extra.update(wctx.extra())
 
         # date-only change should be ignored?
-        datemaydiffer = resolvecommitoptions(ui, opts)
+        datemaydiffer = resolve_commit_options(ui, opts)
+        opts = pycompat.byteskwargs(opts)
 
         date = old.date()
         if opts.get(b'date'):
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -154,8 +154,8 @@
     given.
     """
     cmdutil.check_note_size(opts)
+    cmdutil.resolve_commit_options(ui, opts)
     opts = pycompat.byteskwargs(opts)
-    cmdutil.resolvecommitoptions(ui, opts)
 
     with repo.wlock(), repo.lock():
 



To: martinvonz, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210618/8efbbe0d/attachment-0002.html>


More information about the Mercurial-patches mailing list