comparison mercurial/context.py @ 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 5b117f82cbdb
children 3f1552c6bf71
comparison
equal deleted inserted replaced
18210:f730ed2e093d 18211:518c1403838f
416 if fileid is not None: 416 if fileid is not None:
417 self._fileid = fileid 417 self._fileid = fileid
418 418
419 @propertycache 419 @propertycache
420 def _changectx(self): 420 def _changectx(self):
421 return changectx(self._repo, self._changeid) 421 try:
422 return changectx(self._repo, self._changeid)
423 except error.RepoLookupError:
424 # Linkrev may point to any revision in the repository. When the
425 # repository is filtered this may lead to `filectx` trying to build
426 # `changectx` for filtered revision. In such case we fallback to
427 # creating `changectx` on the unfiltered version of the reposition.
428 # This fallback should not be an issue because`changectx` from
429 # `filectx` are not used in complexe operation that care about
430 # filtering.
431 #
432 # This fallback is a cheap and dirty fix that prevent several
433 # crash. It does not ensure the behavior is correct. However the
434 # behavior was not correct before filtering either and "incorrect
435 # behavior" is seen as better as "crash"
436 #
437 # Linkrevs have several serious troubles with filtering that are
438 # complicated to solve. Proper handling of the issue here should be
439 # considered when solving linkrev issue are on the table.
440 return changectx(self._repo.unfiltered(), self._changeid)
422 441
423 @propertycache 442 @propertycache
424 def _filelog(self): 443 def _filelog(self):
425 return self._repo.file(self._path) 444 return self._repo.file(self._path)
426 445