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

login
register
mail settings
Submitter phabricator
Date Dec. 7, 2021, 11:57 p.m.
Message ID <differential-rev-PHID-DREV-tm5qdzzdbolulxj5wy64-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50209/
State New
Headers show

Comments

phabricator - Dec. 7, 2021, 11:57 p.m.
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




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

Patch

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''