memctx: make `parents()` return list of one element if it’s not a merge
authorManuel Jacob <me@manueljacob.de>
Sat, 11 Jul 2020 02:13:19 +0200
changeset 45089 d085fcb11c56
parent 45088 3e40abe0a170
child 45090 0ecb3b11fcad
memctx: make `parents()` return list of one element if it’s not a merge It is part of the contract of `parents()` that non-merges return a list of one element. `self._parents` is always a list of two elements in `memctx`. Differential Revision: https://phab.mercurial-scm.org/D8731
mercurial/context.py
--- a/mercurial/context.py	Sat Jul 11 01:14:00 2020 +0200
+++ b/mercurial/context.py	Sat Jul 11 02:13:19 2020 +0200
@@ -2891,6 +2891,11 @@
 
         return scmutil.status(modified, added, removed, [], [], [], [])
 
+    def parents(self):
+        if self._parents[1].node() == nullid:
+            return [self._parents[0]]
+        return self._parents
+
 
 class memfilectx(committablefilectx):
     """memfilectx represents an in-memory file to commit.