Mercurial > public > mercurial-scm > hg-stable
diff mercurial/phases.py @ 34327:12c42bcd4133
phases: move the binary decoding function in the phases module
We move the decoding function near the encoding one in a place where they can
be reused in other place (current target, 'exchange.py').
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Tue, 19 Sep 2017 22:23:41 +0200 |
parents | 5779d096a696 |
children | 4ef472b975ff |
line wrap: on
line diff
--- a/mercurial/phases.py Tue Sep 19 22:01:31 2017 +0200 +++ b/mercurial/phases.py Tue Sep 19 22:23:41 2017 +0200 @@ -169,6 +169,22 @@ binarydata.append(_fphasesentry.pack(phase, head)) return ''.join(binarydata) +def binarydecode(stream): + """decode a binary stream into a 'phase -> nodes' mapping + + Since phases are integer the mapping is actually a python list.""" + headsbyphase = [[] for i in allphases] + entrysize = _fphasesentry.size + while True: + entry = stream.read(entrysize) + if len(entry) < entrysize: + if entry: + raise error.Abort(_('bad phase-heads stream')) + break + phase, node = _fphasesentry.unpack(entry) + headsbyphase[phase].append(node) + return headsbyphase + def _trackphasechange(data, rev, old, new): """add a phase move the <data> dictionnary