comparison mercurial/bundle2.py @ 33036:52c7060b707a

bundle: move combineresults() from changegroup to bundle2 The results only need to be combined if they come from a bundle2. More importantly, we'll change its argument to a bundleoperation soon, and then it definitely will no longer belong in changegroup.py.
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 22 Jun 2017 13:58:20 -0700
parents 6e3a6774d998
children d765ad56081f
comparison
equal deleted inserted replaced
33035:6e3a6774d998 33036:52c7060b707a
1476 1476
1477 # parse the changegroup data, otherwise we will block 1477 # parse the changegroup data, otherwise we will block
1478 # in case of sshrepo because we don't know the end of the stream 1478 # in case of sshrepo because we don't know the end of the stream
1479 return changegroup.writechunks(ui, chunkiter, filename, vfs=vfs) 1479 return changegroup.writechunks(ui, chunkiter, filename, vfs=vfs)
1480 1480
1481 def combinechangegroupresults(results):
1482 """logic to combine 0 or more addchangegroup results into one"""
1483 changedheads = 0
1484 result = 1
1485 for ret in results:
1486 # If any changegroup result is 0, return 0
1487 if ret == 0:
1488 result = 0
1489 break
1490 if ret < -1:
1491 changedheads += ret + 1
1492 elif ret > 1:
1493 changedheads += ret - 1
1494 if changedheads > 0:
1495 result = 1 + changedheads
1496 elif changedheads < 0:
1497 result = -1 + changedheads
1498 return result
1499
1481 @parthandler('changegroup', ('version', 'nbchanges', 'treemanifest')) 1500 @parthandler('changegroup', ('version', 'nbchanges', 'treemanifest'))
1482 def handlechangegroup(op, inpart): 1501 def handlechangegroup(op, inpart):
1483 """apply a changegroup part on the repo 1502 """apply a changegroup part on the repo
1484 1503
1485 This is a very early implementation that will massive rework before being 1504 This is a very early implementation that will massive rework before being