Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 27078:a421debae31d
merge.applyupdates: use counters from mergestate
This eliminates a whole bunch of duplicate code and allows us to update the
removed count for change/delete conflicts where the delete action was chosen.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 20 Nov 2015 16:37:39 -0800 |
parents | ca3fbf9dad8c |
children | a88a10a933b2 |
comparison
equal
deleted
inserted
replaced
27077:ca3fbf9dad8c | 27078:a421debae31d |
---|---|
942 | 942 |
943 Return a tuple of counts (updated, merged, removed, unresolved) that | 943 Return a tuple of counts (updated, merged, removed, unresolved) that |
944 describes how many files were affected by the update. | 944 describes how many files were affected by the update. |
945 """ | 945 """ |
946 | 946 |
947 updated, merged, removed, unresolved = 0, 0, 0, 0 | 947 updated, merged, removed = 0, 0, 0 |
948 ms = mergestate.clean(repo, wctx.p1().node(), mctx.node()) | 948 ms = mergestate.clean(repo, wctx.p1().node(), mctx.node()) |
949 moves = [] | 949 moves = [] |
950 for m, l in actions.items(): | 950 for m, l in actions.items(): |
951 l.sort() | 951 l.sort() |
952 | 952 |
1082 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), | 1082 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), |
1083 overwrite) | 1083 overwrite) |
1084 continue | 1084 continue |
1085 audit(f) | 1085 audit(f) |
1086 complete, r = ms.preresolve(f, wctx, labels=labels) | 1086 complete, r = ms.preresolve(f, wctx, labels=labels) |
1087 if complete: | 1087 if not complete: |
1088 if r is not None and r > 0: | |
1089 unresolved += 1 | |
1090 else: | |
1091 if r is None: | |
1092 updated += 1 | |
1093 else: | |
1094 merged += 1 | |
1095 else: | |
1096 numupdates += 1 | 1088 numupdates += 1 |
1097 tocomplete.append((f, args, msg)) | 1089 tocomplete.append((f, args, msg)) |
1098 | 1090 |
1099 # merge | 1091 # merge |
1100 for f, args, msg in tocomplete: | 1092 for f, args, msg in tocomplete: |
1101 repo.ui.debug(" %s: %s -> m (merge)\n" % (f, msg)) | 1093 repo.ui.debug(" %s: %s -> m (merge)\n" % (f, msg)) |
1102 z += 1 | 1094 z += 1 |
1103 progress(_updating, z, item=f, total=numupdates, unit=_files) | 1095 progress(_updating, z, item=f, total=numupdates, unit=_files) |
1104 r = ms.resolve(f, wctx, labels=labels) | 1096 ms.resolve(f, wctx, labels=labels) |
1105 if r is not None and r > 0: | |
1106 unresolved += 1 | |
1107 else: | |
1108 if r is None: | |
1109 updated += 1 | |
1110 else: | |
1111 merged += 1 | |
1112 | 1097 |
1113 ms.commit() | 1098 ms.commit() |
1099 | |
1100 unresolved = ms.unresolvedcount() | |
1114 | 1101 |
1115 if usemergedriver and not unresolved and ms.mdstate() != 's': | 1102 if usemergedriver and not unresolved and ms.mdstate() != 's': |
1116 if not driverconclude(repo, ms, wctx, labels=labels): | 1103 if not driverconclude(repo, ms, wctx, labels=labels): |
1117 # XXX setting unresolved to at least 1 is a hack to make sure we | 1104 # XXX setting unresolved to at least 1 is a hack to make sure we |
1118 # error out | 1105 # error out |
1119 unresolved = max(unresolved, 1) | 1106 unresolved = max(unresolved, 1) |
1120 | 1107 |
1121 ms.commit() | 1108 ms.commit() |
1122 | 1109 |
1110 msupdated, msmerged, msremoved = ms.counts() | |
1111 updated += msupdated | |
1112 merged += msmerged | |
1113 removed += msremoved | |
1123 progress(_updating, None, total=numupdates, unit=_files) | 1114 progress(_updating, None, total=numupdates, unit=_files) |
1124 | 1115 |
1125 return updated, merged, removed, unresolved | 1116 return updated, merged, removed, unresolved |
1126 | 1117 |
1127 def recordupdates(repo, actions, branchmerge): | 1118 def recordupdates(repo, actions, branchmerge): |