From 8b420cd314ecf6d701acb27e3ae989458216c492 Mon Sep 17 00:00:00 2001 From: Stanislau Hlebik Date: Thu, 27 Oct 2016 09:23:05 -0700 Subject: [PATCH] fastmanifest: fallback to old manifest in readshallowfast Summary: fastmanifest makes bundling slower because fastmanifest `readshallowfast` always returns full manifest. That's a big problem for infinitepush. Let's copy-paste readshallowfast implementation from upstream. It uses readshallowdelta() if possible. Test Plan: 1) Run all the tests for fb-hgext 2) Run infinitepush with this extension enabled. Make it is fast Reviewers: durham, simonfar, rmcelroy, quark Reviewed By: quark Subscribers: mjpieters, #sourcecontrol Differential Revision: https://phabricator.intern.facebook.com/D4088360 Tasks: 13907166 Signature: t1:4088360:1477580931:746e4054380403abbc52d1922583021b81f31bb6 --- fastmanifest/__init__.py | 2 +- fastmanifest/implementation.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/fastmanifest/__init__.py b/fastmanifest/__init__.py index f7e583c00e..6b6198d284 100644 --- a/fastmanifest/__init__.py +++ b/fastmanifest/__init__.py @@ -221,7 +221,7 @@ class FastManifestExtension(object): extensions.wrapfunction(manifest.manifest, 'read', factory.read) try: extensions.wrapfunction(manifest.manifest, 'readshallowfast', - factory.read) + factory.readshallowfast) except AttributeError: # The function didn't use to be defined in previous versions # of hg diff --git a/fastmanifest/implementation.py b/fastmanifest/implementation.py index fea4271398..5154fd6fda 100644 --- a/fastmanifest/implementation.py +++ b/fastmanifest/implementation.py @@ -779,6 +779,23 @@ class manifestfactory(object): loadflat=lambda: orig(*args, **kwargs), node=args[1]) + def readshallowfast(self, orig, *args, **kwargs): + # copy-paste from manifest.readshallowfast + manifest = args[0] + if len(args) == 2: + node = args[1] + else: + node = kwargs['node'] + r = manifest.rev(node) + deltaparent = manifest.deltaparent(r) + if (deltaparent != revlog.nullrev and + deltaparent in manifest.parentrevs(r)): + return manifest.readshallowdelta(node) + return hybridmanifest(self.ui, + args[0].opener, + loadflat=lambda: orig(*args, **kwargs), + node=args[1]) + def newgetitem(self, orig, *args, **kwargs): # args[0] == instance of manifestlog # args[1] = node