# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1527155112 -7200
#      Thu May 24 11:45:12 2018 +0200
# Node ID 58c61489f722a57bb3e18fa002f05157ac6fec8e
# Parent  9cbf81bb5e27003cb30baa946770e00fafcc1af4
overlaychangectx: also assign repo to self._repo

Without doing this, we get test failures due to core Mercurial
methods (e.g. context.obsolete, context.orphan, etc) access self._repo.
If we didn't go this route, we'd need to change core to (correctly) call
self.repo() instead of _repo.

diff --git a/hggit/overlay.py b/hggit/overlay.py
--- a/hggit/overlay.py
+++ b/hggit/overlay.py
@@ -213,8 +213,11 @@
 
 class overlaychangectx(context.changectx):
     def __init__(self, repo, sha):
-        # Can't store this in self._repo because the base class uses that field
-        self._hgrepo = repo
+        # 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
         if not isinstance(sha, basestring):
             sha = sha.hex()
         self.commit = repo.handler.git.get_object(_maybehex(sha))