mercurial/bundle2.py
changeset 33048 52c7060b707a
parent 33047 6e3a6774d998
child 33049 d765ad56081f
--- a/mercurial/bundle2.py	Wed Jun 21 14:42:04 2017 -0700
+++ b/mercurial/bundle2.py	Thu Jun 22 13:58:20 2017 -0700
@@ -1478,6 +1478,25 @@
     # in case of sshrepo because we don't know the end of the stream
     return changegroup.writechunks(ui, chunkiter, filename, vfs=vfs)
 
+def combinechangegroupresults(results):
+    """logic to combine 0 or more addchangegroup results into one"""
+    changedheads = 0
+    result = 1
+    for ret in results:
+        # If any changegroup result is 0, return 0
+        if ret == 0:
+            result = 0
+            break
+        if ret < -1:
+            changedheads += ret + 1
+        elif ret > 1:
+            changedheads += ret - 1
+    if changedheads > 0:
+        result = 1 + changedheads
+    elif changedheads < 0:
+        result = -1 + changedheads
+    return result
+
 @parthandler('changegroup', ('version', 'nbchanges', 'treemanifest'))
 def handlechangegroup(op, inpart):
     """apply a changegroup part on the repo