Patchwork [4,of,6] localrepo: have stream_in() not modify its argument

login
register
mail settings
Submitter Drew Gottlieb
Date May 1, 2015, 11:19 p.m.
Message ID <74730f9658d383f45cc5.1430522350@waste.org>
Download mbox | patch
Permalink /patch/8835/
State Accepted
Commit 658bd4dc7a73ddd28af58335c3663f48a685466e
Headers show

Comments

Drew Gottlieb - May 1, 2015, 11:19 p.m.
# HG changeset patch
# User Drew Gottlieb <drgott@google.com>
# Date 1429732752 25200
#      Wed Apr 22 12:59:12 2015 -0700
# Node ID 74730f9658d383f45cc5fb2089530df4c981f03e
# Parent  9bc80406fce09833ff5a3ab1845337efb2ad30b6
localrepo: have stream_in() not modify its argument

Localrepo's stream_in function modified its requirements argument. This is not
good practice because it may be unexpected behavior to the caller.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1827,8 +1827,8 @@ 
             # new requirements = old non-format requirements +
             #                    new format-related
             # requirements from the streamed-in repository
-            requirements.update(self.requirements - self.supportedformats)
-            self.requirements = requirements
+            self.requirements = requirements | (
+                    self.requirements - self.supportedformats)
             self._applyopenerreqs()
             self._writerequirements()