diff --git a/tests/test-check-config-hg.t b/tests/test-check-config-hg.t --- a/tests/test-check-config-hg.t +++ b/tests/test-check-config-hg.t @@ -21,6 +21,7 @@ if ui.configbool("experimental", "histeditng"): conflict on experimental.histeditng: ('bool', '') != ('str', '') at */hgext/histedit.py:*: (glob) + undocumented: extensions.treemanifest (str) undocumented: fastlog.debug (str) undocumented: fastlog.enabled (bool) undocumented: fastmanifest.cachecutoffdays (int) [60] diff --git a/tests/test-treemanifest-disabled.t b/tests/test-treemanifest-disabled.t new file mode 100644 --- /dev/null +++ b/tests/test-treemanifest-disabled.t @@ -0,0 +1,38 @@ + $ CACHEDIR=`pwd`/hgcache + $ PYTHONPATH=$TESTDIR/..:$PYTHONPATH + $ export PYTHONPATH + + $ . "$TESTDIR/library.sh" + + $ hg init client1 + $ cd client1 + $ cat >> .hg/hgrc < [extensions] + > fastmanifest=$TESTDIR/../fastmanifest + > treemanifest=$TESTDIR/../treemanifest + > + > [remotefilelog] + > reponame=master + > cachepath=$CACHEDIR + > usefastdatapack=True + > + > [fastmanifest] + > usetree=True + > usecache=False + > EOF + + $ echo a > a + $ mkdir dir + $ echo b > dir/b + $ hg commit -Aqm 'initial commit' + + $ hg init ../client2 + $ cd ../client2 + $ hg pull ../client1 + pulling from ../client1 + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + (run 'hg update' to get a working copy) diff --git a/treemanifest/__init__.py b/treemanifest/__init__.py --- a/treemanifest/__init__.py +++ b/treemanifest/__init__.py @@ -131,6 +131,9 @@ # prefetches, this constant defines how far back we should search. BASENODESEARCHMAX = 25000 +def treeenabled(ui): + return ui.config('extensions', 'treemanifest', None) not in (None, '!') + def uisetup(ui): extensions.wrapfunction(changegroup.cg1unpacker, '_unpackmanifests', _unpackmanifestscg1) @@ -499,6 +502,9 @@ "server without pushrebase")) def getmanifestlog(orig, self): + if not treeenabled(self.ui): + return orig(self) + if self.ui.configbool('treemanifest', 'treeonly'): mfl = treeonlymanifestlog(self.svfs) setuptreestores(self, mfl) @@ -520,12 +526,13 @@ def _writemanifest(orig, self, transaction, link, p1, p2, added, removed): n = orig(self, transaction, link, p1, p2, added, removed) - if not self._manifestlog._revlog.opener.treemanifestserver: + mfl = self._manifestlog + if (not util.safehasattr(mfl._revlog.opener, 'treemanifestserver') or + not mfl._revlog.opener.treemanifestserver): return n # Since we're adding the root flat manifest, let's add the corresponding # root tree manifest. - mfl = self._manifestlog treemfl = mfl.treemanifestlog m = self._manifestdict @@ -658,6 +665,9 @@ ui.progress(converting, None) def _unpackmanifestscg3(orig, self, repo, *args, **kwargs): + if not treeenabled(repo.ui): + return orig(self, repo, *args, **kwargs) + if repo.ui.configbool('treemanifest', 'treeonly'): self.manifestheader() chain = None @@ -667,6 +677,9 @@ return orig(self, repo, *args, **kwargs) def _unpackmanifestscg1(orig, self, repo, *args, **kwargs): + if not treeenabled(repo.ui): + return orig(self, repo, *args, **kwargs) + if repo.ui.configbool('treemanifest', 'treeonly'): self.manifestheader() chain = None @@ -1053,6 +1066,7 @@ def gettreepackpart2(pushop, bundler): """add parts containing trees being pushed""" if ('treepack' in pushop.stepsdone or + not treeenabled(pushop.repo.ui) or not pushop.repo.ui.configbool('treemanifest', 'sendtrees')): return pushop.stepsdone.add('treepack') @@ -1067,6 +1081,7 @@ **kwargs): """add parts containing trees being pulled""" if ('True' not in b2caps.get('treemanifest', []) or + not treeenabled(repo.ui) or repo.svfs.treemanifestserver or not kwargs.get('cg', True)): return @@ -1101,6 +1116,9 @@ def pull(orig, ui, repo, *pats, **opts): result = orig(ui, repo, *pats, **opts) + if not treeenabled(repo.ui): + return result + repo = repo.unfiltered() ctxs = [] @@ -1437,6 +1455,9 @@ _runrepack(repo, datastore, histstore, packpath, PACK_CATEGORY) def striptrees(orig, repo, tr, striprev, files): + if not treeenabled(repo.ui): + return orig(repo, tr, striprev, files) + if repo.ui.configbool('treemanifest', 'server'): treerevlog = repo.manifestlog.treemanifestlog._revlog for dir in util.dirs(files):