# HG changeset patch # User Paul Morelle # Date 1527494922 -7200 # Node ID bbad9283f80f733f39025cab93c6ec7bfa12434f # Parent 58c61489f722a57bb3e18fa002f05157ac6fec8e overlaychangectx: fallback to self._hgrepo if self._repo attribute not found Reverts and replaces 58c61489f722 which had an error in tests with hg 4.5 diff -r 58c61489f722 -r bbad9283f80f hggit/overlay.py --- a/hggit/overlay.py Thu May 24 11:45:12 2018 +0200 +++ b/hggit/overlay.py Mon May 28 10:08:42 2018 +0200 @@ -213,17 +213,22 @@ class overlaychangectx(context.changectx): def __init__(self, repo, sha): - # we need to keep the repo around in a variable that isn't overridden - # by self._repo but we also need to assign this to self._repo so that - # self.obsolete() (and friends) keep working since they access _repo - # directly. - self._hgrepo = self._repo = repo + # Can't store this in self._repo because the base class uses that field + self._hgrepo = repo if not isinstance(sha, basestring): sha = sha.hex() self.commit = repo.handler.git.get_object(_maybehex(sha)) self._overlay = getattr(repo, 'gitoverlay', repo) self._rev = self._overlay.rev(bin(self.commit.id)) + def __getattr__(self, name): + # Since hg 4.6, context.changectx doesn't define self._repo, + # but it is still used by self.obsolete() (and friends) + # So, if the attribute wasn't found, fallback to _hgrepo + if name == '_repo': + return self._hgrepo + return super(overlaychangectx, self).__getattr__(name) + def repo(self): return self._hgrepo