Patchwork [1,of,2,pager-followup] help: avoid mutating passed-in `keep` list in `formattedhelp`

login
register
mail settings
Submitter Augie Fackler
Date March 8, 2017, 11:43 p.m.
Message ID <767afd48cd786deb5beb.1489016600@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/19040/
State Accepted
Headers show

Comments

Augie Fackler - March 8, 2017, 11:43 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1489015893 18000
#      Wed Mar 08 18:31:33 2017 -0500
# Node ID 767afd48cd786deb5bebd542f739a18640c50038
# Parent  8dcc7582ec043d04d800a54a579f0f25ee7b44f4
help: avoid mutating passed-in `keep` list in `formattedhelp`
Yuya Nishihara - March 9, 2017, 4:33 p.m.
On Wed, 08 Mar 2017 18:43:20 -0500, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1489015893 18000
> #      Wed Mar 08 18:31:33 2017 -0500
> # Node ID 767afd48cd786deb5bebd542f739a18640c50038
> # Parent  8dcc7582ec043d04d800a54a579f0f25ee7b44f4
> help: avoid mutating passed-in `keep` list in `formattedhelp`

Queued these, thanks.

Patch

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -618,6 +618,8 @@  def formattedhelp(ui, name, keep=None, u
     """
     if keep is None:
         keep = []
+    else:
+        keep = list(keep) # make a copy so we can mutate this later
     fullname = name
     section = None
     subtopic = None