changeset 18211:518c1403838f

clfilter: fallback to unfiltered version when linkrev point to filtered history On `filectx`, linkrev may point to any revision in the repository. When the repository is filtered this may lead to `filectx` trying to build `changectx` for filtered revision. In such case we fallback to creating `changectx` on the unfiltered version of the reposition. This fallback should not be an issue because `changectx` from `filectx` are not used in complex operation that care about filtering. It is complicated to work around the issue in a clearer way as code raising such `filectx` rarely have access to the repository directly. Linkrevs create a lot of issue with filtering. It is stored in revlog entry at creation time and never changed. Nothing prevent the changeset revision pointed to become filtered. Several bogus behavior emerge from such situation. Those bugs are complex to solve and not part of the current effort to install filtering. This changeset is simple hack that prevent plain crash in favor on minor misbehavior without visible effect. This "hack" is longly documented in to code itself to help people that would look at it in the future.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Sat, 29 Dec 2012 00:40:18 +0100
parents f730ed2e093d
children 493778b5fe9f
files mercurial/context.py
diffstat 1 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Mon Dec 24 11:58:40 2012 +0100
+++ b/mercurial/context.py	Sat Dec 29 00:40:18 2012 +0100
@@ -418,7 +418,26 @@
 
     @propertycache
     def _changectx(self):
-        return changectx(self._repo, self._changeid)
+        try:
+            return changectx(self._repo, self._changeid)
+        except error.RepoLookupError:
+            # Linkrev may point to any revision in the repository.  When the
+            # repository is filtered this may lead to `filectx` trying to build
+            # `changectx` for filtered revision. In such case we fallback to
+            # creating `changectx` on the unfiltered version of the reposition.
+            # This fallback should not be an issue because`changectx` from
+            # `filectx` are not used in complexe operation that care about
+            # filtering.
+            #
+            # This fallback is a cheap and dirty fix that prevent several
+            # crash. It does not ensure the behavior is correct. However the
+            # behavior was not correct before filtering either and "incorrect
+            # behavior" is seen as better as "crash"
+            #
+            # Linkrevs have several serious troubles with filtering that are
+            # complicated to solve. Proper handling of the issue here should be
+            # considered when solving linkrev issue are on the table.
+            return changectx(self._repo.unfiltered(), self._changeid)
 
     @propertycache
     def _filelog(self):