Mercurial > public > mercurial-scm > hg
diff mercurial/branchmap.py @ 18124:79db6d40bced
branchmap: store branchcache in a dedicated object
Value and key of branchcache would benefit from being hold by the same object.
Moreover some logic (update, write, validation) could be move on such object.
The creation of this object is the first step toward this move. The result will
clarify branchcache related code and hide most of the detail in the class
itself. This encapsulation will greatly helps implementation of branchcache for
filtered view of the repo.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Sat, 22 Dec 2012 01:44:42 +0100 |
parents | f8a13f061a8a |
children | ad194a8ab5c1 |
line wrap: on
line diff
--- a/mercurial/branchmap.py Sat Dec 22 01:34:23 2012 +0100 +++ b/mercurial/branchmap.py Sat Dec 22 01:44:42 2012 +0100 @@ -9,13 +9,13 @@ import encoding def read(repo): - partial = {} + partial = branchcache() try: f = repo.opener("cache/branchheads") lines = f.read().split('\n') f.close() except (IOError, OSError): - return {}, nullid, nullrev + return branchcache(), nullid, nullrev try: last, lrev = lines.pop(0).split(" ", 1) @@ -37,7 +37,7 @@ except Exception, inst: if repo.ui.debugflag: repo.ui.warn(str(inst), '\n') - partial, last, lrev = {}, nullid, nullrev + partial, last, lrev = branchcache(), nullid, nullrev return partial, last, lrev def write(repo, branches, tip, tiprev): @@ -143,3 +143,7 @@ update(repo, partial, ctxgen) repo._branchcache = partial repo._branchcachetip = tip + +class branchcache(dict): + """A dict like object that hold branches heads cache""" +