##// END OF EJS Templates
merge: save merge part labels for later reuse...
Simon Farnsworth -
r28634:3ceac01b default
parent child Browse files
Show More
@@ -2896,6 +2896,14 b' def debugmergestate(ui, repo, *args):'
2896 2896
2897 2897 ui.write(('file extras: %s (%s)\n')
2898 2898 % (filename, ', '.join(extrastrings)))
2899 elif rtype == 'l':
2900 labels = record.split('\0', 2)
2901 labels = [l for l in labels if len(l) > 0]
2902 ui.write(('labels:\n'))
2903 ui.write((' local: %s\n' % labels[0]))
2904 ui.write((' other: %s\n' % labels[1]))
2905 if len(labels) > 2:
2906 ui.write((' base: %s\n' % labels[2]))
2899 2907 else:
2900 2908 ui.write(('unrecognized entry: %s\t%s\n')
2901 2909 % (rtype, record.replace('\0', '\t')))
@@ -2908,7 +2916,7 b' def debugmergestate(ui, repo, *args):'
2908 2916 # sort so that reasonable information is on top
2909 2917 v1records = ms._readrecordsv1()
2910 2918 v2records = ms._readrecordsv2()
2911 order = 'LOm'
2919 order = 'LOml'
2912 2920 def key(r):
2913 2921 idx = order.find(r[0])
2914 2922 if idx == -1:
@@ -68,6 +68,7 b' class mergestate(object):'
68 68 f: a (filename, dictonary) tuple of optional values for a given file
69 69 X: unsupported mandatory record type (used in tests)
70 70 x: unsupported advisory record type (used in tests)
71 l: the labels for the parts of the merge.
71 72
72 73 Merge driver run states (experimental):
73 74 u: driver-resolved files unmarked -- needs to be run next time we're about
@@ -80,11 +81,11 b' class mergestate(object):'
80 81 statepathv2 = 'merge/state2'
81 82
82 83 @staticmethod
83 def clean(repo, node=None, other=None):
84 def clean(repo, node=None, other=None, labels=None):
84 85 """Initialize a brand new merge state, removing any existing state on
85 86 disk."""
86 87 ms = mergestate(repo)
87 ms.reset(node, other)
88 ms.reset(node, other, labels)
88 89 return ms
89 90
90 91 @staticmethod
@@ -100,12 +101,14 b' class mergestate(object):'
100 101 Do not use this directly! Instead call read() or clean()."""
101 102 self._repo = repo
102 103 self._dirty = False
104 self._labels = None
103 105
104 def reset(self, node=None, other=None):
106 def reset(self, node=None, other=None, labels=None):
105 107 self._state = {}
106 108 self._stateextras = {}
107 109 self._local = None
108 110 self._other = None
111 self._labels = labels
109 112 for var in ('localctx', 'otherctx'):
110 113 if var in vars(self):
111 114 delattr(self, var)
@@ -165,6 +168,9 b' class mergestate(object):'
165 168 i += 2
166 169
167 170 self._stateextras[filename] = extras
171 elif rtype == 'l':
172 labels = record.split('\0', 2)
173 self._labels = [l for l in labels if len(l) > 0]
168 174 elif not rtype.islower():
169 175 unsupported.add(rtype)
170 176 self._results = {}
@@ -353,6 +359,9 b' class mergestate(object):'
353 359 rawextras = '\0'.join('%s\0%s' % (k, v) for k, v in
354 360 extras.iteritems())
355 361 records.append(('f', '%s\0%s' % (filename, rawextras)))
362 if self._labels is not None:
363 labels = '\0'.join(self._labels)
364 records.append(('l', labels))
356 365 return records
357 366
358 367 def _writerecords(self, records):
@@ -444,7 +453,7 b' class mergestate(object):'
444 453 def extras(self, filename):
445 454 return self._stateextras.setdefault(filename, {})
446 455
447 def _resolve(self, preresolve, dfile, wctx, labels=None):
456 def _resolve(self, preresolve, dfile, wctx):
448 457 """rerun merge process for file path `dfile`"""
449 458 if self[dfile] in 'rd':
450 459 return True, 0
@@ -481,11 +490,11 b' class mergestate(object):'
481 490 self._repo.wvfs.unlinkpath(dfile, ignoremissing=True)
482 491 complete, r, deleted = filemerge.premerge(self._repo, self._local,
483 492 lfile, fcd, fco, fca,
484 labels=labels)
493 labels=self._labels)
485 494 else:
486 495 complete, r, deleted = filemerge.filemerge(self._repo, self._local,
487 496 lfile, fcd, fco, fca,
488 labels=labels)
497 labels=self._labels)
489 498 if r is None:
490 499 # no real conflict
491 500 del self._state[dfile]
@@ -523,17 +532,17 b' class mergestate(object):'
523 532 else:
524 533 return ctx[f]
525 534
526 def preresolve(self, dfile, wctx, labels=None):
535 def preresolve(self, dfile, wctx):
527 536 """run premerge process for dfile
528 537
529 538 Returns whether the merge is complete, and the exit code."""
530 return self._resolve(True, dfile, wctx, labels=labels)
539 return self._resolve(True, dfile, wctx)
531 540
532 def resolve(self, dfile, wctx, labels=None):
541 def resolve(self, dfile, wctx):
533 542 """run merge process (assuming premerge was run) for dfile
534 543
535 544 Returns the exit code of the merge."""
536 return self._resolve(False, dfile, wctx, labels=labels)[1]
545 return self._resolve(False, dfile, wctx)[1]
537 546
538 547 def counts(self):
539 548 """return counts for updated, merged and removed files in this
@@ -1094,7 +1103,7 b' def applyupdates(repo, actions, wctx, mc'
1094 1103 """
1095 1104
1096 1105 updated, merged, removed = 0, 0, 0
1097 ms = mergestate.clean(repo, wctx.p1().node(), mctx.node())
1106 ms = mergestate.clean(repo, wctx.p1().node(), mctx.node(), labels)
1098 1107 moves = []
1099 1108 for m, l in actions.items():
1100 1109 l.sort()
@@ -1247,7 +1256,7 b' def applyupdates(repo, actions, wctx, mc'
1247 1256 overwrite)
1248 1257 continue
1249 1258 audit(f)
1250 complete, r = ms.preresolve(f, wctx, labels=labels)
1259 complete, r = ms.preresolve(f, wctx)
1251 1260 if not complete:
1252 1261 numupdates += 1
1253 1262 tocomplete.append((f, args, msg))
@@ -1257,7 +1266,7 b' def applyupdates(repo, actions, wctx, mc'
1257 1266 repo.ui.debug(" %s: %s -> m (merge)\n" % (f, msg))
1258 1267 z += 1
1259 1268 progress(_updating, z, item=f, total=numupdates, unit=_files)
1260 ms.resolve(f, wctx, labels=labels)
1269 ms.resolve(f, wctx)
1261 1270
1262 1271 ms.commit()
1263 1272
@@ -452,7 +452,7 b' Resolve conflicted graft'
452 452 c
453 453 =======
454 454 b
455 >>>>>>> other: 5d205f8b35b6 - bar: 1
455 >>>>>>> graft: 5d205f8b35b6 - bar: 1
456 456 $ echo b > a
457 457 $ hg resolve -m a
458 458 (no more unresolved files)
@@ -80,6 +80,9 b' insert unsupported advisory merge record'
80 80 * version 2 records
81 81 local: 8f7551c7e4a2f2efe0bc8c741baf7f227d65d758
82 82 other: e860deea161a2f77de56603b340ebbb4536308ae
83 labels:
84 local: local
85 other: histedit
83 86 unrecognized entry: x advisory record
84 87 file extras: e (ancestorlinknode = 0000000000000000000000000000000000000000)
85 88 file: e (record type "F", state "u", hash 58e6b3a414a1e090dfc6029add0f3555ccba127f)
@@ -95,6 +98,9 b' insert unsupported mandatory merge recor'
95 98 * version 2 records
96 99 local: 8f7551c7e4a2f2efe0bc8c741baf7f227d65d758
97 100 other: e860deea161a2f77de56603b340ebbb4536308ae
101 labels:
102 local: local
103 other: histedit
98 104 file extras: e (ancestorlinknode = 0000000000000000000000000000000000000000)
99 105 file: e (record type "F", state "u", hash 58e6b3a414a1e090dfc6029add0f3555ccba127f)
100 106 local path: e (flags "")
@@ -736,6 +736,9 b' Non-interactive linear update'
736 736 * version 2 records
737 737 local: ab57bf49aa276a22d35a473592d4c34b5abc3eff
738 738 other: 10f9a0a634e82080907e62f075ab119cbc565ea6
739 labels:
740 local: working copy
741 other: destination
739 742 file extras: file1 (ancestorlinknode = ab57bf49aa276a22d35a473592d4c34b5abc3eff)
740 743 file: file1 (record type "C", state "u", hash 60b27f004e454aca81b0480209cce5081ec52390)
741 744 local path: file1 (flags "")
@@ -776,6 +779,9 b' Choose local versions of files'
776 779 * version 2 records
777 780 local: ab57bf49aa276a22d35a473592d4c34b5abc3eff
778 781 other: 10f9a0a634e82080907e62f075ab119cbc565ea6
782 labels:
783 local: working copy
784 other: destination
779 785 file extras: file1 (ancestorlinknode = ab57bf49aa276a22d35a473592d4c34b5abc3eff)
780 786 file: file1 (record type "C", state "r", hash 60b27f004e454aca81b0480209cce5081ec52390)
781 787 local path: file1 (flags "")
@@ -814,6 +820,9 b' Choose other versions of files'
814 820 * version 2 records
815 821 local: ab57bf49aa276a22d35a473592d4c34b5abc3eff
816 822 other: 10f9a0a634e82080907e62f075ab119cbc565ea6
823 labels:
824 local: working copy
825 other: destination
817 826 file extras: file1 (ancestorlinknode = ab57bf49aa276a22d35a473592d4c34b5abc3eff)
818 827 file: file1 (record type "C", state "r", hash 60b27f004e454aca81b0480209cce5081ec52390)
819 828 local path: file1 (flags "")
@@ -854,6 +863,9 b' Fail'
854 863 * version 2 records
855 864 local: ab57bf49aa276a22d35a473592d4c34b5abc3eff
856 865 other: 10f9a0a634e82080907e62f075ab119cbc565ea6
866 labels:
867 local: working copy
868 other: destination
857 869 file extras: file1 (ancestorlinknode = ab57bf49aa276a22d35a473592d4c34b5abc3eff)
858 870 file: file1 (record type "C", state "u", hash 60b27f004e454aca81b0480209cce5081ec52390)
859 871 local path: file1 (flags "")
@@ -900,6 +912,9 b' Force prompts with no input'
900 912 * version 2 records
901 913 local: ab57bf49aa276a22d35a473592d4c34b5abc3eff
902 914 other: 10f9a0a634e82080907e62f075ab119cbc565ea6
915 labels:
916 local: working copy
917 other: destination
903 918 file extras: file1 (ancestorlinknode = ab57bf49aa276a22d35a473592d4c34b5abc3eff)
904 919 file: file1 (record type "C", state "u", hash 60b27f004e454aca81b0480209cce5081ec52390)
905 920 local path: file1 (flags "")
@@ -947,6 +962,9 b' Choose to merge all files'
947 962 * version 2 records
948 963 local: ab57bf49aa276a22d35a473592d4c34b5abc3eff
949 964 other: 10f9a0a634e82080907e62f075ab119cbc565ea6
965 labels:
966 local: working copy
967 other: destination
950 968 file extras: file1 (ancestorlinknode = ab57bf49aa276a22d35a473592d4c34b5abc3eff)
951 969 file: file1 (record type "C", state "u", hash 60b27f004e454aca81b0480209cce5081ec52390)
952 970 local path: file1 (flags "")
@@ -75,6 +75,9 b' Insert unsupported advisory merge record'
75 75 * version 2 records
76 76 local: 3e046f2ecedb793b97ed32108086edd1a162f8bc
77 77 other: 46f0b057b5c061d276b91491c22151f78698abd2
78 labels:
79 local: dest
80 other: source
78 81 unrecognized entry: x advisory record
79 82 file extras: common (ancestorlinknode = 3163e20567cc93074fbb7a53c8b93312e59dbf2c)
80 83 file: common (record type "F", state "u", hash 94c8c21d08740f5da9eaa38d1f175c592692f0d1)
@@ -91,6 +94,9 b' Insert unsupported mandatory merge recor'
91 94 * version 2 records
92 95 local: 3e046f2ecedb793b97ed32108086edd1a162f8bc
93 96 other: 46f0b057b5c061d276b91491c22151f78698abd2
97 labels:
98 local: dest
99 other: source
94 100 file extras: common (ancestorlinknode = 3163e20567cc93074fbb7a53c8b93312e59dbf2c)
95 101 file: common (record type "F", state "u", hash 94c8c21d08740f5da9eaa38d1f175c592692f0d1)
96 102 local path: common (flags "")
General Comments 0
You need to be logged in to leave comments. Login now