Mercurial > hg-stable
changeset 27929:3b2ac2115464 stable
changegroup: introduce safeversion()
In a few places (at least repair.py and shelve.py), we want to find
the best changegroup version that we can assume users of the repo will
understand. For example, we choose version 01 by default, but if it's
a generaldelta repo, we expect clients to support version 02 anyway,
so we choose that for new bundles (for e.g. "hg strip"). Let's create
a helper for this functionality in changegroup, so we can reuse it
elsewhere later.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 19 Jan 2016 15:32:32 -0800 |
parents | c0f11347b107 |
children | 7cbb3a01fa38 |
files | mercurial/changegroup.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changegroup.py Tue Jan 19 14:27:18 2016 -0800 +++ b/mercurial/changegroup.py Tue Jan 19 15:32:32 2016 -0800 @@ -961,6 +961,15 @@ versions.discard('03') return versions +def safeversion(repo): + # Finds the smallest version that it's safe to assume clients of the repo + # will support. + versions = supportedversions(repo) + if 'generaldelta' in repo.requirements: + versions.discard('01') + assert versions + return min(versions) + def getbundler(version, repo, bundlecaps=None): assert version in supportedversions(repo) return _packermap[version][0](repo, bundlecaps)