mercurial/exchange.py
changeset 22961 a67ea4959ef5
parent 22953 b1d694d3975e
child 22971 3fe571c74b27
--- a/mercurial/exchange.py	Thu Oct 16 15:54:53 2014 +0900
+++ b/mercurial/exchange.py	Thu Oct 16 16:03:04 2014 +0900
@@ -944,8 +944,22 @@
         raise util.Abort('missing support for %s' % exc)
 
     if pullop.fetch:
-        assert len(op.records['changegroup']) == 1
-        pullop.cgresult = op.records['changegroup'][0]['return']
+        changedheads = 0
+        pullop.cgresult = 1
+        for cg in op.records['changegroup']:
+            ret = cg['return']
+            # If any changegroup result is 0, return 0
+            if ret == 0:
+                pullop.cgresult = 0
+                break
+            if ret < -1:
+                changedheads += ret + 1
+            elif ret > 1:
+                changedheads += ret - 1
+        if changedheads > 0:
+            pullop.cgresult = 1 + changedheads
+        elif changedheads < 0:
+            pullop.cgresult = -1 + changedheads
 
     # processing phases change
     for namespace, value in op.records['listkeys']: