changeset 1053:5821075b289a

context: update to work with upstream Some upstream code now relies on ctx.repo() to access the repo object, since hggit stored ctx.repo as a field instead of a function, that failed. Let's move it to be a function. For overlaychangectx we can't just store the repo in self._repo because that causes other parts of the base class to act differently and causes tests to fail, so we store it as a new field.
author Durham Goode <durham@fb.com>
date Thu, 05 Oct 2017 11:04:50 -0700
parents 5db8d0d0ae47
children 6bb4c99362f0
files hggit/overlay.py
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/overlay.py
+++ b/hggit/overlay.py
@@ -174,10 +174,13 @@
 
 class overlayfilectx(object):
     def __init__(self, repo, path, fileid=None):
-        self.repo = repo
+        self._repo = repo
         self._path = path
         self.fileid = fileid
 
+    def repo(self):
+        return self._repo
+
     # this is a hack to skip copy detection
     def ancestors(self):
         return [self, self]
@@ -195,7 +198,7 @@
         return self.fileid
 
     def data(self):
-        blob = self.repo.handler.git.get_object(_maybehex(self.fileid))
+        blob = self._repo.handler.git.get_object(_maybehex(self.fileid))
         return blob.data
 
     def isbinary(self):
@@ -203,13 +206,17 @@
 
 class overlaychangectx(context.changectx):
     def __init__(self, repo, sha):
-        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 repo(self):
+        return self._hgrepo
+
     def node(self):
         return bin(self.commit.id)
 
@@ -235,13 +242,13 @@
         return self.commit.message
 
     def parents(self):
-        cl = self.repo.changelog
+        cl = self._hgrepo.changelog
         parents = cl.parents(cl.node(self._rev))
         if not parents:
-            return [self.repo['null']]
+            return [self._hgrepo['null']]
         if parents[1] == nullid:
             parents = parents[:-1]
-        return [self.repo[sha] for sha in parents]
+        return [self._hgrepo[sha] for sha in parents]
 
     def manifestnode(self):
         return bin(self.commit.tree)