# HG changeset patch # User Sean Farley # Date 1401756829 18000 # Node ID 68e6927fa387065c087c5b85f9ff396b5fa9ff63 # Parent e4b7374793029823dfe7b960034caa2ff10e1b4a compathacks: add wrapper for memfilectx diff --git a/hgsubversion/compathacks.py b/hgsubversion/compathacks.py --- a/hgsubversion/compathacks.py +++ b/hgsubversion/compathacks.py @@ -1,11 +1,27 @@ """Functions to work around API changes inside Mercurial.""" def branchset(repo): - """Return the set of branches present in a repo. - - Works around branchtags() vanishing between 2.8 and 2.9. - """ - try: - return set(repo.branchmap()) - except AttributeError: - return set(repo.branchtags()) + """Return the set of branches present in a repo. + + Works around branchtags() vanishing between 2.8 and 2.9. + """ + try: + return set(repo.branchmap()) + except AttributeError: + return set(repo.branchtags()) + +def pickle_load(f): + import cPickle as pickle + f.seek(0) + return pickle.load(f) + +def makememfilectx(repo, path, data, islink, isexec, copied): + """Return a memfilectx + + Works around memfilectx() adding a repo argument between 3.0 and 3.1. + """ + from mercurial import context + try: + return context.memfilectx(repo, path, data, islink, isexec, copied) + except TypeError: + return context.memfilectx(path, data, islink, isexec, copied)