##// END OF EJS Templates
mergestate: store about files resolved in favour of other...
Pulkit Goyal -
r45178:1b8fd4af default
parent child Browse files
Show More
@@ -5955,6 +5955,8 def resolve(ui, repo, *pats, **opts):
5955 5955 if not m(f):
5956 5956 continue
5957 5957
5958 if ms[f] == mergemod.MERGE_RECORD_MERGED_OTHER:
5959 continue
5958 5960 label, key = mergestateinfo[ms[f]]
5959 5961 fm.startitem()
5960 5962 fm.context(ctx=wctx)
@@ -6002,6 +6004,9 def resolve(ui, repo, *pats, **opts):
6002 6004
6003 6005 didwork = True
6004 6006
6007 if ms[f] == mergemod.MERGE_RECORD_MERGED_OTHER:
6008 continue
6009
6005 6010 # don't let driver-resolved files be marked, and run the conclude
6006 6011 # step if asked to resolve
6007 6012 if ms[f] == mergemod.MERGE_RECORD_DRIVER_RESOLVED:
@@ -2855,6 +2855,14 class localrepository(object):
2855 2855 fparent1, fparent2 = fparent2, nullid
2856 2856 elif fparent2 in fparentancestors:
2857 2857 fparent2 = nullid
2858 elif not fparentancestors:
2859 # TODO: this whole if-else might be simplified much more
2860 ms = mergemod.mergestate.read(self)
2861 if (
2862 fname in ms
2863 and ms[fname] == mergemod.MERGE_RECORD_MERGED_OTHER
2864 ):
2865 fparent1, fparent2 = fparent2, nullid
2858 2866
2859 2867 # is the file changed?
2860 2868 text = fctx.data()
@@ -64,6 +64,7 RECORD_LABELS = b'l'
64 64 RECORD_OVERRIDE = b't'
65 65 RECORD_UNSUPPORTED_MANDATORY = b'X'
66 66 RECORD_UNSUPPORTED_ADVISORY = b'x'
67 RECORD_RESOLVED_OTHER = b'R'
67 68
68 69 MERGE_DRIVER_STATE_UNMARKED = b'u'
69 70 MERGE_DRIVER_STATE_MARKED = b'm'
@@ -74,6 +75,9 MERGE_RECORD_RESOLVED = b'r'
74 75 MERGE_RECORD_UNRESOLVED_PATH = b'pu'
75 76 MERGE_RECORD_RESOLVED_PATH = b'pr'
76 77 MERGE_RECORD_DRIVER_RESOLVED = b'd'
78 # represents that the file was automatically merged in favor
79 # of other version. This info is used on commit.
80 MERGE_RECORD_MERGED_OTHER = b'o'
77 81
78 82 ACTION_FORGET = b'f'
79 83 ACTION_REMOVE = b'r'
@@ -91,6 +95,8 ACTION_DIR_RENAME_MOVE_LOCAL = b'dm'
91 95 ACTION_KEEP = b'k'
92 96 ACTION_EXEC = b'e'
93 97 ACTION_CREATED_MERGE = b'cm'
98 # GET the other/remote side and store this info in mergestate
99 ACTION_GET_OTHER_AND_STORE = b'gs'
94 100
95 101
96 102 class mergestate(object):
@@ -227,6 +233,7 class mergestate(object):
227 233 RECORD_CHANGEDELETE_CONFLICT,
228 234 RECORD_PATH_CONFLICT,
229 235 RECORD_MERGE_DRIVER_MERGE,
236 RECORD_RESOLVED_OTHER,
230 237 ):
231 238 bits = record.split(b'\0')
232 239 self._state[bits[0]] = bits[1:]
@@ -453,6 +460,10 class mergestate(object):
453 460 records.append(
454 461 (RECORD_PATH_CONFLICT, b'\0'.join([filename] + v))
455 462 )
463 elif v[0] == MERGE_RECORD_MERGED_OTHER:
464 records.append(
465 (RECORD_RESOLVED_OTHER, b'\0'.join([filename] + v))
466 )
456 467 elif v[1] == nullhex or v[6] == nullhex:
457 468 # Change/Delete or Delete/Change conflicts. These are stored in
458 469 # 'C' records. v[1] is the local file, and is nullhex when the
@@ -551,6 +562,10 class mergestate(object):
551 562 self._state[path] = [MERGE_RECORD_UNRESOLVED_PATH, frename, forigin]
552 563 self._dirty = True
553 564
565 def addmergedother(self, path):
566 self._state[path] = [MERGE_RECORD_MERGED_OTHER, nullhex, nullhex]
567 self._dirty = True
568
554 569 def __contains__(self, dfile):
555 570 return dfile in self._state
556 571
@@ -594,6 +609,8 class mergestate(object):
594 609 """rerun merge process for file path `dfile`"""
595 610 if self[dfile] in (MERGE_RECORD_RESOLVED, MERGE_RECORD_DRIVER_RESOLVED):
596 611 return True, 0
612 if self._state[dfile][0] == MERGE_RECORD_MERGED_OTHER:
613 return True, 0
597 614 stateentry = self._state[dfile]
598 615 state, localkey, lfile, afile, anode, ofile, onode, flags = stateentry
599 616 octx = self._repo[self._other]
@@ -1209,7 +1226,7 def _filternarrowactions(narrowmatch, br
1209 1226 narrowed.
1210 1227 """
1211 1228 nooptypes = {b'k'} # TODO: handle with nonconflicttypes
1212 nonconflicttypes = set(b'a am c cm f g r e'.split())
1229 nonconflicttypes = set(b'a am c cm f g gs r e'.split())
1213 1230 # We mutate the items in the dict during iteration, so iterate
1214 1231 # over a copy.
1215 1232 for f, action in list(actions.items()):
@@ -1348,14 +1365,22 def manifestmerge(
1348 1365 )
1349 1366 else:
1350 1367 actions[f] = (
1351 ACTION_GET,
1368 ACTION_GET_OTHER_AND_STORE
1369 if branchmerge
1370 else ACTION_GET,
1352 1371 (fl2, False),
1353 1372 b'remote is newer',
1354 1373 )
1355 1374 elif nol and n2 == a: # remote only changed 'x'
1356 1375 actions[f] = (ACTION_EXEC, (fl2,), b'update permissions')
1357 1376 elif nol and n1 == a: # local only changed 'x'
1358 actions[f] = (ACTION_GET, (fl1, False), b'remote is newer')
1377 actions[f] = (
1378 ACTION_GET_OTHER_AND_STORE
1379 if branchmerge
1380 else ACTION_GET,
1381 (fl1, False),
1382 b'remote is newer',
1383 )
1359 1384 else: # both changed something
1360 1385 actions[f] = (
1361 1386 ACTION_MERGE,
@@ -1588,6 +1613,8 def calculateupdates(
1588 1613
1589 1614 for f, a in sorted(pycompat.iteritems(actions)):
1590 1615 m, args, msg = a
1616 if m == ACTION_GET_OTHER_AND_STORE:
1617 m = ACTION_GET
1591 1618 repo.ui.debug(b' %s: %s -> %s\n' % (f, msg, m))
1592 1619 if f in fbids:
1593 1620 d = fbids[f]
@@ -1813,6 +1840,7 def emptyactions():
1813 1840 ACTION_KEEP,
1814 1841 ACTION_PATH_CONFLICT,
1815 1842 ACTION_PATH_CONFLICT_RESOLVE,
1843 ACTION_GET_OTHER_AND_STORE,
1816 1844 )
1817 1845 }
1818 1846
@@ -1835,6 +1863,11 def applyupdates(
1835 1863
1836 1864 updated, merged, removed = 0, 0, 0
1837 1865 ms = mergestate.clean(repo, wctx.p1().node(), mctx.node(), labels)
1866
1867 # add ACTION_GET_OTHER_AND_STORE to mergestate
1868 for e in actions[ACTION_GET_OTHER_AND_STORE]:
1869 ms.addmergedother(e[0])
1870
1838 1871 moves = []
1839 1872 for m, l in actions.items():
1840 1873 l.sort()
@@ -2415,6 +2448,7 def update(
2415 2448 ACTION_EXEC,
2416 2449 ACTION_REMOVE,
2417 2450 ACTION_PATH_CONFLICT_RESOLVE,
2451 ACTION_GET_OTHER_AND_STORE,
2418 2452 ):
2419 2453 msg = _(b"conflicting changes")
2420 2454 hint = _(b"commit or update --clean to discard changes")
@@ -2477,6 +2511,10 def update(
2477 2511 actions[m] = []
2478 2512 actions[m].append((f, args, msg))
2479 2513
2514 # ACTION_GET_OTHER_AND_STORE is a ACTION_GET + store in mergestate
2515 for e in actions[ACTION_GET_OTHER_AND_STORE]:
2516 actions[ACTION_GET].append(e)
2517
2480 2518 if not util.fscasesensitive(repo.path):
2481 2519 # check collision between files only in p2 for clean update
2482 2520 if not branchmerge and (
@@ -62,9 +62,9 Make and delete some tags
62 62 6 make bar and baz copies of foo
63 63 5 merge local copy
64 64 4 merge remote copy
65 3 Added tag that for changeset 88586c4e9f02
65 3 Added tag that for changeset 8601262d7472
66 66 2 Removed tag that
67 1 Added tag this for changeset c56a7f387039
67 1 Added tag this for changeset 706614b458c1
68 68 0 mark baz executable
69 69 updating bookmarks
70 70 $ cd new
@@ -76,7 +76,7 Make and delete some tags
76 76 #if execbit
77 77 $ hg bookmarks
78 78 premerge1 3:973ef48a98a4
79 premerge2 8:91d107c423ba
79 premerge2 8:c4968fdf2e5d
80 80 #else
81 81 Different hash because no x bit
82 82 $ hg bookmarks
@@ -96,19 +96,19 Test that redoing a convert results in a
96 96 6 make bar and baz copies of foo
97 97 5 merge local copy
98 98 4 merge remote copy
99 3 Added tag that for changeset 88586c4e9f02
99 3 Added tag that for changeset 8601262d7472
100 100 2 Removed tag that
101 1 Added tag this for changeset c56a7f387039
101 1 Added tag this for changeset 706614b458c1
102 102 0 mark baz executable
103 103 updating bookmarks
104 104 $ hg -R new log -G -T '{rev} {desc}'
105 105 o 8 mark baz executable
106 106 |
107 o 7 Added tag this for changeset c56a7f387039
107 o 7 Added tag this for changeset 706614b458c1
108 108 |
109 109 o 6 Removed tag that
110 110 |
111 o 5 Added tag that for changeset 88586c4e9f02
111 o 5 Added tag that for changeset 8601262d7472
112 112 |
113 113 o 4 merge remote copy
114 114 |\
@@ -319,7 +319,7 Note:
319 319 (branch merge, don't forget to commit)
320 320 $ hg ci -m 'mBDm-0 simple merge - one way'
321 321 $ hg up 'desc("d-2")'
322 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
322 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
323 323 $ hg merge 'desc("b-1")'
324 324 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
325 325 (branch merge, don't forget to commit)
@@ -348,7 +348,6 Note:
348 348 M d
349 349 $ hg status --copies --rev 'desc("d-2")' --rev 'desc("mBDm-0")'
350 350 M b
351 M d
352 351 $ hg status --copies --rev 'desc("d-2")' --rev 'desc("mDBm-0")'
353 352 M b
354 353 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mBDm-0")'
@@ -361,7 +360,7 Note:
361 360 The bugs makes recorded copy is different depending of where we started the merge from since
362 361
363 362 $ hg manifest --debug --rev 'desc("mBDm-0")' | grep '644 d'
364 0bb5445dc4d02f4e0d86cf16f9f3a411d0f17744 644 d
363 b004912a8510032a0350a74daa2803dadfb00e12 644 d
365 364 $ hg manifest --debug --rev 'desc("mDBm-0")' | grep '644 d'
366 365 b004912a8510032a0350a74daa2803dadfb00e12 644 d
367 366
@@ -378,21 +377,13 not a merge.
378 377 rev linkrev nodeid p1 p2
379 378 0 2 01c2f5eabdc4 000000000000 000000000000
380 379 1 8 b004912a8510 000000000000 000000000000
381 2 17 0bb5445dc4d0 01c2f5eabdc4 b004912a8510
382 380
383 381 (This `hg log` output if wrong, since no merge actually happened).
384 382
385 383 $ hg log -Gfr 'desc("mBDm-0")' d
386 o 17 mBDm-0 simple merge - one way
387 |\
388 o : 8 d-2 re-add d
389 :/
390 o 2 i-2: c -move-> d
384 o 8 d-2 re-add d
391 385 |
392 o 1 i-1: a -move-> c
393 |
394 o 0 i-0 initial commit: a b h
395
386 ~
396 387
397 388 This `hg log` output is correct
398 389
@@ -404,7 +395,6 This `hg log` output is correct
404 395 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBDm-0")'
405 396 M b
406 397 A d
407 a
408 398 R a
409 399 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mDBm-0")'
410 400 M b
@@ -525,8 +515,7 Merge:
525 515 rev linkrev nodeid p1 p2
526 516 0 2 01c2f5eabdc4 000000000000 000000000000
527 517 1 8 b004912a8510 000000000000 000000000000
528 2 17 0bb5445dc4d0 01c2f5eabdc4 b004912a8510
529 3 22 c72365ee036f 000000000000 000000000000
518 2 22 c72365ee036f 000000000000 000000000000
530 519 $ hg up 'desc("b-1")'
531 520 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
532 521 $ hg merge 'desc("f-2")'
@@ -534,7 +523,7 Merge:
534 523 (branch merge, don't forget to commit)
535 524 $ hg ci -m 'mBFm-0 simple merge - one way'
536 525 $ hg up 'desc("f-2")'
537 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
526 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
538 527 $ hg merge 'desc("b-1")'
539 528 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
540 529 (branch merge, don't forget to commit)
@@ -562,7 +551,7 The overwriting should take over. Howeve
562 551 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBFm-0")'
563 552 M b
564 553 A d
565 a (true !)
554 h
566 555 h (false !)
567 556 R a
568 557 R h
@@ -577,7 +566,6 The overwriting should take over. Howeve
577 566 R h
578 567 $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mBFm-0")'
579 568 M b
580 M d
581 569 $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mBFm-0")'
582 570 M b
583 571 M d
@@ -595,16 +583,10 The overwriting should take over. Howeve
595 583 The following graphlog is wrong, the "a -> c -> d" chain was overwritten and should not appear.
596 584
597 585 $ hg log -Gfr 'desc("mBFm-0")' d
598 o 23 mBFm-0 simple merge - one way
599 |\
600 o : 22 f-2: rename i -> d
601 | :
602 o : 21 f-1: rename h -> i
603 :/
604 o 2 i-2: c -move-> d
586 o 22 f-2: rename i -> d
605 587 |
606 o 1 i-1: a -move-> c
607 |
588 o 21 f-1: rename h -> i
589 :
608 590 o 0 i-0 initial commit: a b h
609 591
610 592
General Comments 0
You need to be logged in to leave comments. Login now