Patchwork localrepo: prevent to copy repo local config, copy baseui instead

login
register
mail settings
Submitter Simon Heimberg
Date Nov. 11, 2013, 10:02 p.m.
Message ID <2e6d6237f2e3698653b5.1384207334@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/2909/
State Accepted
Commit b04cc8651a6354271e5bd17f936cea5151b4121f
Headers show

Comments

Simon Heimberg - Nov. 11, 2013, 10:02 p.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1384207166 -3600
#      Mon Nov 11 22:59:26 2013 +0100
# Node ID 2e6d6237f2e3698653b5e53da461da3683dd9c3d
# Parent  879de101e03bc224aa1b7ba0cb00dc1408187b6e
localrepo: prevent to copy repo local config, copy baseui instead

Copying a repos local configuration to another repo is a bad idea because the
2nd repo gets the configuration of the first. Prevent this by really calling
repo.baseui.copy when repo.ui.copy is called.
This requires some changes in commandserver which needs to clone repo.ui for
rejecting temporary changes.

This patch has its roots back in the topic "repo isolation" around f0564402d059
and was suggested by mpm.
Matt Mackall - Nov. 22, 2013, 9:34 p.m.
On Mon, 2013-11-11 at 23:02 +0100, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1384207166 -3600
> #      Mon Nov 11 22:59:26 2013 +0100
> # Node ID 2e6d6237f2e3698653b5e53da461da3683dd9c3d
> # Parent  879de101e03bc224aa1b7ba0cb00dc1408187b6e
> localrepo: prevent to copy repo local config, copy baseui instead

Queued for default, thanks.

Patch

diff -r 879de101e03b -r 2e6d6237f2e3 mercurial/commandserver.py
--- a/mercurial/commandserver.py	Sat Nov 09 14:50:58 2013 +0100
+++ b/mercurial/commandserver.py	Mon Nov 11 22:59:26 2013 +0100
@@ -184,7 +184,10 @@ 
         # persist between requests
         copiedui = self.ui.copy()
         self.repo.baseui = copiedui
-        self.repo.ui = self.repo.dirstate._ui = self.repoui.copy()
+        # clone ui without using ui.copy because this is protected
+        repoui = self.repoui.__class__(self.repoui)
+        repoui.copy = copiedui.copy # redo copy protection
+        self.repo.ui = self.repo.dirstate._ui = repoui
         self.repo.invalidate()
         self.repo.invalidatedirstate()
 
diff -r 879de101e03b -r 2e6d6237f2e3 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Sat Nov 09 14:50:58 2013 +0100
+++ b/mercurial/localrepo.py	Mon Nov 11 22:59:26 2013 +0100
@@ -171,6 +171,7 @@ 
         self.opener = self.vfs
         self.baseui = baseui
         self.ui = baseui.copy()
+        self.ui.copy = baseui.copy # prevent copying repo configuration
         # A list of callback to shape the phase if no data were found.
         # Callback are in the form: func(repo, roots) --> processed root.
         # This list it to be filled by extension during repo setup