Patchwork D548: context: make parents and text optional in metadataonlyctx

login
register
mail settings
Submitter phabricator
Date Aug. 29, 2017, 2:05 p.m.
Message ID <f973df21f7ee59e9e88c311be46cfce2@localhost.localdomain>
Download mbox | patch
Permalink /patch/23465/
State Not Applicable
Headers show

Comments

phabricator - Aug. 29, 2017, 2:05 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGbecce02036e1: context: make parents and text optional in metadataonlyctx (authored by quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D548?vs=1371&id=1391

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS




To: quark, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2298,15 +2298,23 @@ 
     def __new__(cls, repo, originalctx, *args, **kwargs):
         return super(metadataonlyctx, cls).__new__(cls, repo)
 
-    def __init__(self, repo, originalctx, parents, text, user=None, date=None,
-                 extra=None, editor=False):
+    def __init__(self, repo, originalctx, parents=None, text=None, user=None,
+                 date=None, extra=None, editor=False):
+        if text is None:
+            text = originalctx.description()
         super(metadataonlyctx, self).__init__(repo, text, user, date, extra)
         self._rev = None
         self._node = None
         self._originalctx = originalctx
         self._manifestnode = originalctx.manifestnode()
-        parents = [(p or nullid) for p in parents]
-        p1, p2 = self._parents = [changectx(self._repo, p) for p in parents]
+        if parents is None:
+            parents = originalctx.parents()
+        else:
+            parents = [repo[p] for p in parents if p is not None]
+        parents = parents[:]
+        while len(parents) < 2:
+            parents.append(repo[nullid])
+        p1, p2 = self._parents = parents
 
         # sanity check to ensure that the reused manifest parents are
         # manifests of our commit parents