changeset 3309:09db38b34cb9

parents: add a utility to filter parents There is various strange case of merge out there that needs to be handled. We add an utility function to handle them all.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 18 Dec 2017 06:48:49 +0100
parents 65af5f9f232b
children 87cb2635352b
files hgext3rd/evolve/utility.py
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/utility.py	Mon Dec 18 01:53:20 2017 +0100
+++ b/hgext3rd/evolve/utility.py	Mon Dec 18 06:48:49 2017 +0100
@@ -5,6 +5,8 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+from mercurial.node import nullrev
+
 shorttemplate = "[{label('evolve.rev', rev)}] {desc|firstline}\n"
 
 def obsexcmsg(ui, message, important=False):
@@ -20,3 +22,17 @@
     if ui.configbool('experimental', 'verbose-obsolescence-exchange', False):
         topic = 'OBSEXC'
     ui.progress(topic, *args, **kwargs)
+
+def filterparents(parents):
+    """filter nullrev parents
+
+    (and other crazyness)"""
+    p1, p2 = parents
+    if p1 == nullrev and p2 == nullrev:
+        return ()
+    elif p1 != nullrev and (p2 == nullrev or p1 == p2):
+        return (p1,)
+    elif p1 == nullrev and p2 != nullrev:
+        return (p2,)
+    else:
+        return parents