From 855af710bbae85a645326b53be23b5272005f9a6 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Thu, 3 Nov 2016 20:55:16 +0000 Subject: [PATCH] fastannotate: support remotefilelog Summary: In order to support remotefilelog, do not construct `mercurial.context.context` object directly. This reverts a previous attempt to use the fastest manifest look up - `ctx[path]` actually seems good enough. A minor change is made in `protocol.py` to ignore failed requests. Test Plan: Run existing tests Reviewers: #sourcecontrol, rmcelroy Reviewed By: rmcelroy Subscribers: mjpieters Differential Revision: https://phabricator.intern.facebook.com/D4127025 Signature: t1:4127025:1478541481:c15477332582e2c9b22e2732e9e76bf37b5fba74 --- fastannotate/context.py | 17 +---------------- fastannotate/protocol.py | 2 ++ tests/README | 2 +- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/fastannotate/context.py b/fastannotate/context.py index adb4a0ca83..46b74caae9 100644 --- a/fastannotate/context.py +++ b/fastannotate/context.py @@ -13,7 +13,6 @@ import hashlib import os from mercurial import ( - context as hgcontext, error, lock as lockmod, mdiff, @@ -98,21 +97,7 @@ def resolvefctx(repo, rev, path, resolverev=False, adjustctx=None): ctx = _revsingle(repo, rev) else: ctx = repo[rev] - # special handling working copy context - if ctx.rev() is None: - return ctx[path] - # manifest.find is optimized for single file resolution. use it instead - # of manifest.get or ctx.__getitem__ or ctx.filectx for better performance. - # note: this is kind of reinventing ctx.filectx. - try: - fnode, flag = ctx.manifest().find(path) - except KeyError: - raise error.ManifestLookupError(rev, path, _('not found in manifest')) - # TODO: remotefilelog compatibility - remotefilelog does not have a real - # filelog - need a different approach - flog = _getflog(repo, path) - fctx = hgcontext.filectx(repo, path, fileid=fnode, filelog=flog, - changeid=ctx.rev(), changectx=ctx) + fctx = ctx[path] if adjustctx is not None: if adjustctx == 'linkrev': introrev = fctx.linkrev() diff --git a/fastannotate/protocol.py b/fastannotate/protocol.py index d5ac563437..1308b2dae1 100644 --- a/fastannotate/protocol.py +++ b/fastannotate/protocol.py @@ -143,6 +143,8 @@ def clientfetch(repo, paths, lastnodemap=None, peer=None): ui.debug('fastannotate: server returned\n') for result in results: + if result.value is None: + continue for path, content in result.value.iteritems(): # ignore malicious paths if not path.startswith('fastannotate/') or '/../' in (path + '/'): diff --git a/tests/README b/tests/README index 8c08685d07..6999f52dec 100644 --- a/tests/README +++ b/tests/README @@ -18,7 +18,7 @@ Obtaining the test runners If you do not already have a copy of the Mercurial repository, you can obtains one with: - $ hg clone http://selenic.com/hg/ + $ hg clone http://mercurial-scm.org/hg Running against various Mercurial versions ------------------------------------------