changeset 45089:d085fcb11c56

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
author Manuel Jacob <me@manueljacob.de>
date Sat, 11 Jul 2020 02:13:19 +0200
parents 3e40abe0a170
children 0ecb3b11fcad
files mercurial/context.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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.