obsolete: add a `commonversion` function
This function returns the highest common version between the locally known
formats and a list of remotely known formats. This is going to be useful to
know what format should be used for exchange.
--- a/mercurial/obsolete.py Tue Aug 26 11:48:26 2014 +0200
+++ b/mercurial/obsolete.py Tue Aug 26 11:36:23 2014 +0200
@@ -455,6 +455,17 @@
seennodes |= pendingnodes
return seenmarkers
+def commonversion(versions):
+ """Return the newest version listed in both versions and our local formats.
+
+ Returns None if no common version exists.
+ """
+ versions.sort(reverse=True)
+ # search for highest version known on both side
+ for v in versions:
+ if v in formats:
+ return v
+ return None
# arbitrary picked to fit into 8K limit from HTTP server
# you have to take in account: