Mercurial > public > mercurial-scm > hg
comparison mercurial/bundle2.py @ 34320: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 |
comparison
equal
deleted
inserted
replaced
34319:5779d096a696 | 34320:12c42bcd4133 |
---|---|
1834 for key in ('namespace', 'key', 'new', 'old', 'ret'): | 1834 for key in ('namespace', 'key', 'new', 'old', 'ret'): |
1835 if key in inpart.params: | 1835 if key in inpart.params: |
1836 kwargs[key] = inpart.params[key] | 1836 kwargs[key] = inpart.params[key] |
1837 raise error.PushkeyFailed(partid=str(inpart.id), **kwargs) | 1837 raise error.PushkeyFailed(partid=str(inpart.id), **kwargs) |
1838 | 1838 |
1839 def _readphaseheads(inpart): | |
1840 headsbyphase = [[] for i in phases.allphases] | |
1841 entrysize = phases._fphasesentry.size | |
1842 while True: | |
1843 entry = inpart.read(entrysize) | |
1844 if len(entry) < entrysize: | |
1845 if entry: | |
1846 raise error.Abort(_('bad phase-heads bundle part')) | |
1847 break | |
1848 phase, node = phases._fphasesentry.unpack(entry) | |
1849 headsbyphase[phase].append(node) | |
1850 return headsbyphase | |
1851 | |
1852 @parthandler('phase-heads') | 1839 @parthandler('phase-heads') |
1853 def handlephases(op, inpart): | 1840 def handlephases(op, inpart): |
1854 """apply phases from bundle part to repo""" | 1841 """apply phases from bundle part to repo""" |
1855 headsbyphase = _readphaseheads(inpart) | 1842 headsbyphase = phases.binarydecode(inpart) |
1856 phases.updatephases(op.repo.unfiltered(), op.gettransaction(), headsbyphase) | 1843 phases.updatephases(op.repo.unfiltered(), op.gettransaction(), headsbyphase) |
1857 op.records.add('phase-heads', {}) | 1844 op.records.add('phase-heads', {}) |
1858 | 1845 |
1859 @parthandler('reply:pushkey', ('return', 'in-reply-to')) | 1846 @parthandler('reply:pushkey', ('return', 'in-reply-to')) |
1860 def handlepushkeyreply(op, inpart): | 1847 def handlepushkeyreply(op, inpart): |