##// END OF EJS Templates
phases: move the binary decoding function in the phases module...
Boris Feld -
r34321:12c42bcd default
parent child Browse files
Show More
@@ -1836,23 +1836,10 b' def handlepushkey(op, inpart):'
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
@@ -310,7 +310,7 b' def _debugobsmarkers(ui, part, indent=0,'
310 def _debugphaseheads(ui, data, indent=0):
310 def _debugphaseheads(ui, data, indent=0):
311 """display version and markers contained in 'data'"""
311 """display version and markers contained in 'data'"""
312 indent_string = ' ' * indent
312 indent_string = ' ' * indent
313 headsbyphase = bundle2._readphaseheads(data)
313 headsbyphase = phases.binarydecode(data)
314 for phase in phases.allphases:
314 for phase in phases.allphases:
315 for head in headsbyphase[phase]:
315 for head in headsbyphase[phase]:
316 ui.write(indent_string)
316 ui.write(indent_string)
@@ -169,6 +169,22 b' def binaryencode(phasemapping):'
169 binarydata.append(_fphasesentry.pack(phase, head))
169 binarydata.append(_fphasesentry.pack(phase, head))
170 return ''.join(binarydata)
170 return ''.join(binarydata)
171
171
172 def binarydecode(stream):
173 """decode a binary stream into a 'phase -> nodes' mapping
174
175 Since phases are integer the mapping is actually a python list."""
176 headsbyphase = [[] for i in allphases]
177 entrysize = _fphasesentry.size
178 while True:
179 entry = stream.read(entrysize)
180 if len(entry) < entrysize:
181 if entry:
182 raise error.Abort(_('bad phase-heads stream'))
183 break
184 phase, node = _fphasesentry.unpack(entry)
185 headsbyphase[phase].append(node)
186 return headsbyphase
187
172 def _trackphasechange(data, rev, old, new):
188 def _trackphasechange(data, rev, old, new):
173 """add a phase move the <data> dictionnary
189 """add a phase move the <data> dictionnary
174
190
General Comments 0
You need to be logged in to leave comments. Login now