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.
--- 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