comparison mercurial/exchange.py @ 22961:a67ea4959ef5

bundle2: merge return values when bundle contains multiple changegroups A bundle2 may contain multiple parts adding changegroups, in which case there are multiple operation records for changegroups, each with its own return value. Those multiple return values are aggregated in a single cgresult value for the whole operation. As can be seen in the associated test case, the situation with hooks is not really the best, but without deeper thoughts and changes, we can't do much better. Hopefully, things will be improved before bundle2 is enabled by default. In the meanwhile, multiple changegroups is not expected to be in widespread use, and even less expected to be used for pushes. Also, not many clients cloning or pulling bundle2 with multiple changesets are not expected to have changegroup hooks anyways.
author Mike Hommey <mh@glandium.org>
date Thu, 16 Oct 2014 16:03:04 +0900
parents b1d694d3975e
children 3fe571c74b27
comparison
equal deleted inserted replaced
22960:7c13c9404c2c 22961:a67ea4959ef5
942 op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction) 942 op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
943 except error.BundleValueError, exc: 943 except error.BundleValueError, exc:
944 raise util.Abort('missing support for %s' % exc) 944 raise util.Abort('missing support for %s' % exc)
945 945
946 if pullop.fetch: 946 if pullop.fetch:
947 assert len(op.records['changegroup']) == 1 947 changedheads = 0
948 pullop.cgresult = op.records['changegroup'][0]['return'] 948 pullop.cgresult = 1
949 for cg in op.records['changegroup']:
950 ret = cg['return']
951 # If any changegroup result is 0, return 0
952 if ret == 0:
953 pullop.cgresult = 0
954 break
955 if ret < -1:
956 changedheads += ret + 1
957 elif ret > 1:
958 changedheads += ret - 1
959 if changedheads > 0:
960 pullop.cgresult = 1 + changedheads
961 elif changedheads < 0:
962 pullop.cgresult = -1 + changedheads
949 963
950 # processing phases change 964 # processing phases change
951 for namespace, value in op.records['listkeys']: 965 for namespace, value in op.records['listkeys']:
952 if namespace == 'phases': 966 if namespace == 'phases':
953 _pullapplyphases(pullop, value) 967 _pullapplyphases(pullop, value)