From 36860751cec1d4cf7001505a53a1ee4f3e85146e Mon Sep 17 00:00:00 2001 From: Ryan McElroy Date: Thu, 9 Feb 2017 03:35:58 -0800 Subject: [PATCH] remotefilelog: allow linkrev to be valid for any passed rev Summary: Sometimes we pass in two revs because we're creating a merge commit. Let's handle that case better. Test Plan: tests still pass Reviewers: #mercurial, durham Reviewed By: durham Subscribers: mjpieters Differential Revision: https://phabricator.intern.facebook.com/D4528594 Signature: t1:4528594:1486576897:6bd80017dfe2933e4c1a9685ba35bb1af0440eb0 --- remotefilelog/remotefilectx.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/remotefilelog/remotefilectx.py b/remotefilelog/remotefilectx.py index bae53dcd2b..2d64584cb4 100644 --- a/remotefilelog/remotefilectx.py +++ b/remotefilelog/remotefilectx.py @@ -265,21 +265,20 @@ class remotefilectx(context.filectx): """ Check if a linknode is correct one for the current history. - That is, return True if the linkrev is the ancestor of the first of the - passed in revs (if any), otherwise return False. - - TODO: We may want to consider linkrev being an ancestor of any of the - passed-in revs as sufficient, not just the first. + That is, return True if the linkrev is the ancestor of any of the + passed in revs, otherwise return False. `revs` is a list that usually has one element -- usually the wdir parent or the user-passed rev we're looking back from. It may contain two revs when there is a merge going on, or zero revs when a root node with no parents is being created. """ + if not revs: + return False try: # Use the C fastpath to check if the given linknode is correct. cl = self._repo.changelog - return revs and cl.isancestor(linknode, cl.node(revs[0])) + return any(cl.isancestor(linknode, cl.node(r)) for r in revs) except error.LookupError: # The linknode read from the blob may have been stripped or # otherwise not present in the repository anymore. Do not fail hard