D11884: status: when extracting arguments from `opts`, use the same default values

spectral (Kyle Lippincott) phabricator at mercurial-scm.org
Tue Dec 7 23:57:21 UTC 2021


spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Sometimes other code, such as commit when using `commands.commit.post-status`,
  calls `commands.status()` without going through the normal dispatch mechanism
  that would typically fill in the args to be something besides None. As a
  "defense in depth" mechanism for a bug where Mercurial would crash if both
  `commands.commit.post-status` and `experimental.directaccess` were enabled,
  let's sanitize these values to be identical to the values they would have when
  the user invoked this method from the commandline.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6897,9 +6897,9 @@
 
     cmdutil.check_at_most_one_arg(opts, 'rev', 'change')
     opts = pycompat.byteskwargs(opts)
-    revs = opts.get(b'rev')
-    change = opts.get(b'change')
-    terse = opts.get(b'terse')
+    revs = opts.get(b'rev', [])
+    change = opts.get(b'change', b'')
+    terse = opts.get(b'terse', _NOTTERSE)
     if terse is _NOTTERSE:
         if revs:
             terse = b''



To: spectral, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list