changeset 26240:2b1434e5eaa0

hg: always create new localrepository instance cachedlocalrepo.copy() didn't actually create new localrepository instances. This meant that the new thread isolation code in hgweb wasn't actually using separate localrepository instances, even though it was properly using separate cachedlocalrepo instances. Because the behavior of the API changed, the single caller in hgweb had to be refactored to always call _webifyrepo() or it may not have used the proper filter. I confirmed via print() debugging that id(repo) is in fact different on each thread. This was not the case before. For reasons I can't yet explain, this does not fix issue4756. I suspect there is shared cache somewhere that isn't thread safe.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 12 Sep 2015 11:31:56 -0700
parents f39953663cc9
children eb97d49768cc
files mercurial/hg.py mercurial/hgweb/hgweb_mod.py
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Thu Sep 10 19:45:46 2015 -0400
+++ b/mercurial/hg.py	Sat Sep 12 11:31:56 2015 -0700
@@ -887,8 +887,13 @@
         return tuple(state), maxmtime
 
     def copy(self):
-        """Obtain a copy of this class instance."""
-        c = cachedlocalrepo(self._repo)
+        """Obtain a copy of this class instance.
+
+        A new localrepository instance is obtained. The new instance should be
+        completely independent of the original.
+        """
+        repo = repository(self._repo.baseui, self._repo.origroot)
+        c = cachedlocalrepo(repo)
         c._state = self._state
         c.mtime = self.mtime
         return c
--- a/mercurial/hgweb/hgweb_mod.py	Thu Sep 10 19:45:46 2015 -0400
+++ b/mercurial/hgweb/hgweb_mod.py	Sat Sep 12 11:31:56 2015 -0700
@@ -235,11 +235,11 @@
         if self._repos:
             cached = self._repos.pop()
             r, created = cached.fetch()
-            if created:
-                r = self._webifyrepo(r)
         else:
             cached = self._lastrepo.copy()
             r, created = cached.fetch()
+        if created:
+            r = self._webifyrepo(r)
 
         self._lastrepo = cached
         self.mtime = cached.mtime