Mercurial > public > mercurial-scm > hg
comparison mercurial/obsolete.py @ 22345:cf7014c5f087
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 26 Aug 2014 11:36:23 +0200 |
parents | 9680da73cfe0 |
children | 813c6855b97f |
comparison
equal
deleted
inserted
replaced
22344:9829b7948100 | 22345:cf7014c5f087 |
---|---|
453 seenmarkers |= direct | 453 seenmarkers |= direct |
454 pendingnodes -= seennodes | 454 pendingnodes -= seennodes |
455 seennodes |= pendingnodes | 455 seennodes |= pendingnodes |
456 return seenmarkers | 456 return seenmarkers |
457 | 457 |
458 def commonversion(versions): | |
459 """Return the newest version listed in both versions and our local formats. | |
460 | |
461 Returns None if no common version exists. | |
462 """ | |
463 versions.sort(reverse=True) | |
464 # search for highest version known on both side | |
465 for v in versions: | |
466 if v in formats: | |
467 return v | |
468 return None | |
458 | 469 |
459 # arbitrary picked to fit into 8K limit from HTTP server | 470 # arbitrary picked to fit into 8K limit from HTTP server |
460 # you have to take in account: | 471 # you have to take in account: |
461 # - the version header | 472 # - the version header |
462 # - the base85 encoding | 473 # - the base85 encoding |