Patchwork D2970: context: set repo property in basectx

login
register
mail settings
Submitter phabricator
Date March 30, 2018, 6:10 a.m.
Message ID <differential-rev-PHID-DREV-e7rrxl72v6yiq2ba2yai-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29949/
State Superseded
Headers show

Comments

phabricator - March 30, 2018, 6:10 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It seems like a good practice to call the super constructor. Let's
  start by passing the repo along to basectx so it can assign it to a
  private attribute. We should perhaps pass the rev and node along as
  well, but that requires more work before it can be done.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2970

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - March 30, 2018, 6:14 p.m.
indygreg added a comment.


  I accidentally pushed this. Derp.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2970

To: martinvonz, #hg-reviewers, indygreg
Cc: mercurial-devel
phabricator - March 30, 2018, 6:15 p.m.
indygreg added a comment.


  I mean accidentally pushed to Phabricator after the queuing. The queueing was correct.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2970

To: martinvonz, #hg-reviewers, indygreg
Cc: mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -63,6 +63,9 @@ 
     memctx: a context that represents changes in-memory and can also
             be committed."""
 
+    def __init__(self, repo):
+        self._repo = repo
+
     def __bytes__(self):
         return short(self.node())
 
@@ -406,10 +409,10 @@ 
     the repo."""
     def __init__(self, repo, changeid='.'):
         """changeid is a revision number, node, or tag"""
+        super(changectx, self).__init__(repo)
 
         if changeid == '':
             changeid = '.'
-        self._repo = repo
 
         try:
             if isinstance(changeid, int):
@@ -1134,7 +1137,7 @@ 
     wants the ability to commit, e.g. workingctx or memctx."""
     def __init__(self, repo, text="", user=None, date=None, extra=None,
                  changes=None):
-        self._repo = repo
+        super(committablectx, self).__init__(repo)
         self._rev = None
         self._node = None
         self._text = text
@@ -1818,7 +1821,6 @@ 
 
     def __init__(self, repo):
         super(overlayworkingctx, self).__init__(repo)
-        self._repo = repo
         self.clean()
 
     def setbase(self, wrappedctx):