Commits

Yuya Nishihara committed b054dcf

remove garbage

Comments (0)

Files changed (2)

localrepo.diff

-# HG changeset patch
-# Parent c53590a1d0b334f06f29c6d57271d9e4e62ee0b8
-thgrepo: extend bare repo instance to avoid infinite recursion around getattr
-
-Since hg 4d1671b39168, hg.repository() does not return localrepository but
-a filtered one. Maybe because filtered repo is tricky proxycls instance,
-wrapping it causes infinite recursion of __getattr__().
-
-To avoid the problem, this patch changes to wrap bare localrepository instance
-before calling filtered('visible'). Sadly this change needs to duplicate
-some codes from mercurial.hg module.
-
-diff --git a/tortoisehg/hgqt/thgrepo.py b/tortoisehg/hgqt/thgrepo.py
---- a/tortoisehg/hgqt/thgrepo.py
-+++ b/tortoisehg/hgqt/thgrepo.py
-@@ -17,9 +17,15 @@ import re
- from PyQt4.QtCore import *
- 
- from mercurial import hg, util, error, bundlerepo, extensions, filemerge, node
--from mercurial import merge, subrepo
-+from mercurial import merge, subrepo, localrepo
- from mercurial import ui as uimod
--from mercurial.util import propertycache
-+
-+# XXX should import (un)filteredpropertycache and rename propertycache instead
-+try:
-+    #from mercurial.localrepo import unfilteredpropertycache as propertycache
-+    from mercurial.localrepo import filteredpropertycache as propertycache
-+except AttributeError:  # hg<2.5
-+    from mercurial.util import propertycache
- 
- from tortoisehg.util import hglib, paths
- from tortoisehg.util.patchctx import patchctx
-@@ -35,6 +41,17 @@ else:
-     def dbgoutput(*args):
-         pass
- 
-+def _barelocalrepository(ui, path, create):
-+    '''Create localrepository instance of no filter applied'''
-+    repo = localrepo.instance(ui, path, create)
-+    # duplicated from mercurial.hg._peerorrepo
-+    ui = getattr(repo, 'ui', ui)
-+    for name, module in extensions.extensions():
-+        hook = getattr(module, 'reposetup', None)
-+        if hook:
-+            hook(ui, repo)
-+    return repo
-+
- def repository(_ui=None, path='', create=False, bundle=None):
-     '''Returns a subclassed Mercurial repository to which new
-     THG-specific methods have been added. The repository object
-@@ -50,18 +67,23 @@ def repository(_ui=None, path='', create
-         if _ui is None:
-             _ui = uimod.ui()
-         try:
--            repo = hg.repository(_ui, path, create)
-+            # make sure to extend _bare_ localrepository instance; wrapping
-+            # proxycls of repoview causes infinite recursion.
-+            repo = _barelocalrepository(_ui, path, create)
-             repo.__class__ = _extendrepo(repo)
-             repo._pyqtobj = ThgRepoWrapper(repo)
-             _repocache[path] = repo
--            return repo
-         except EnvironmentError:
-             raise error.RepoError('Cannot open repository at %s' % path)
-     if not os.path.exists(os.path.join(path, '.hg/')):
-         del _repocache[path]
-         # this error must be in local encoding
-         raise error.RepoError('%s is not a valid repository' % path)
--    return _repocache[path]
-+    repo = _repocache[path]
-+    try:
-+        return repo.filtered('visible')
-+    except AttributeError:  # hg<2.5
-+        return repo
- 
- class _LockStillHeld(Exception):
-     'Raised to abort status check due to lock existence'
 grep-nosub.diff
 clonedrepo-redun.diff
 close-self-by-wb.diff
-localrepo.diff
 sigsigconnect.diff
 repo-listeners.diff
 repo-stopwatch.diff