# HG changeset patch # User Pierre-Yves David # Date 2014-08-26 09:36:23 # Node ID cf7014c5f087afb15bac1bcc5186eb15f117a451 # Parent 9829b79481000b3f6f1242959a15a5bf78e56023 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. diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py --- a/mercurial/obsolete.py +++ b/mercurial/obsolete.py @@ -455,6 +455,17 @@ class obsstore(object): 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: