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