##// END OF EJS Templates
bundle: move combineresults() from changegroup to bundle2...
Martin von Zweigbergk -
r33036:52c7060b default
parent child Browse files
Show More
@@ -1478,6 +1478,25 b' def writebundle(ui, cg, filename, bundle'
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
@@ -60,25 +60,6 b' def closechunk():'
60 """return a changegroup chunk header (string) for a zero-length chunk"""
60 """return a changegroup chunk header (string) for a zero-length chunk"""
61 return struct.pack(">l", 0)
61 return struct.pack(">l", 0)
62
62
63 def combineresults(results):
64 """logic to combine 0 or more addchangegroup results into one"""
65 changedheads = 0
66 result = 1
67 for ret in results:
68 # If any changegroup result is 0, return 0
69 if ret == 0:
70 result = 0
71 break
72 if ret < -1:
73 changedheads += ret + 1
74 elif ret > 1:
75 changedheads += ret - 1
76 if changedheads > 0:
77 result = 1 + changedheads
78 elif changedheads < 0:
79 result = -1 + changedheads
80 return result
81
82 def writechunks(ui, chunks, filename, vfs=None):
63 def writechunks(ui, chunks, filename, vfs=None):
83 """Write chunks to a file and return its filename.
64 """Write chunks to a file and return its filename.
84
65
@@ -5216,7 +5216,7 b' def unbundle(ui, repo, fname1, *fnames, '
5216 "information"))
5216 "information"))
5217 changes = [r.get('return', 0)
5217 changes = [r.get('return', 0)
5218 for r in op.records['changegroup']]
5218 for r in op.records['changegroup']]
5219 modheads = changegroup.combineresults(changes)
5219 modheads = bundle2.combinechangegroupresults(changes)
5220 else:
5220 else:
5221 txnname = 'unbundle\n%s' % util.hidepassword(url)
5221 txnname = 'unbundle\n%s' % util.hidepassword(url)
5222 with repo.transaction(txnname) as tr:
5222 with repo.transaction(txnname) as tr:
@@ -1398,7 +1398,7 b' def _pullbundle2(pullop):'
1398
1398
1399 if pullop.fetch:
1399 if pullop.fetch:
1400 results = [cg['return'] for cg in op.records['changegroup']]
1400 results = [cg['return'] for cg in op.records['changegroup']]
1401 pullop.cgresult = changegroup.combineresults(results)
1401 pullop.cgresult = bundle2.combinechangegroupresults(results)
1402
1402
1403 # processing phases change
1403 # processing phases change
1404 for namespace, value in op.records['listkeys']:
1404 for namespace, value in op.records['listkeys']:
General Comments 0
You need to be logged in to leave comments. Login now