diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py --- a/mercurial/obsolete.py +++ b/mercurial/obsolete.py @@ -102,6 +102,37 @@ from i18n import _ _fmfsize = struct.calcsize(_fmfixed) _fnodesize = struct.calcsize(_fmnode) +### obsolescence marker flag + +## bumpedfix flag +# +# When a changeset A' succeed to a changeset A which became public, we call A' +# "bumped" because it's a successors of a public changesets +# +# o A' (bumped) +# |`: +# | o A +# |/ +# o Z +# +# The way to solve this situation is to create a new changeset Ad as children +# of A. This changeset have the same content than A'. So the diff from A to A' +# is the same than the diff from A to Ad. Ad is marked as a successors of A' +# +# o Ad +# |`: +# | x A' +# |'| +# o | A +# |/ +# o Z +# +# But by transitivity Ad is also a successors of A. To avoid having Ad marked +# as bumped too, we add the `bumpedfix` flag to the marker. . +# This flag mean that the successors are an interdiff that fix the bumped +# situation, breaking the transitivity of "bumped" here. +bumpedfix = 1 + def _readmarkers(data): """Read and enumerate markers from raw data""" off = 0 @@ -351,7 +382,7 @@ def successormarkers(ctx): for data in ctx._repo.obsstore.successors.get(ctx.node(), ()): yield marker(ctx._repo, data) -def allsuccessors(obsstore, nodes): +def allsuccessors(obsstore, nodes, ignoreflags=0): """Yield node for every successor of . Some successors may be unknown locally. @@ -363,6 +394,9 @@ def allsuccessors(obsstore, nodes): current = remaining.pop() yield current for mark in obsstore.successors.get(current, ()): + # ignore marker flagged with with specified flag + if mark[2] & ignoreflags: + continue for suc in mark[1]: if suc not in seen: seen.add(suc) @@ -449,7 +483,8 @@ def _computebumpedset(repo): # get all possible bumped changesets tonode = repo.changelog.node publicnodes = (tonode(r) for r in repo.revs('public()')) - successors = allsuccessors(repo.obsstore, publicnodes) + successors = allsuccessors(repo.obsstore, publicnodes, + ignoreflags=bumpedfix) # revision public or already obsolete don't count as bumped query = '%ld - obsolete() - public()' return set(repo.revs(query, _knownrevs(repo, successors))) diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -171,6 +171,43 @@ the public changeset summary: add new_3_c +Fixing "bumped" situation +We need to create a clone of 5 and add a special marker with a flag + + $ hg up '5^' + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ hg revert -ar 5 + adding new_3_c + $ hg ci -m 'add n3w_3_c' + created new head + $ hg debugobsolete -d '1338 0' --flags 1 `getid new_3_c` `getid n3w_3_c` + $ hg log -r 'bumped()' + $ hg log -G + @ changeset: 6:6f9641995072 + | tag: tip + | parent: 1:7c3bad9141dc + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: add n3w_3_c + | + | o changeset: 2:245bde4270cd + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: add original_c + | + o changeset: 1:7c3bad9141dc + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: add b + | + o changeset: 0:1f0dee641bb7 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: add a + + + + $ cd .. Exchange Test @@ -197,6 +234,7 @@ Try to pull markers cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} + 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'} Rollback//Transaction support @@ -206,6 +244,7 @@ Rollback//Transaction support cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} + 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'} aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 {'date': '1340 0', 'user': 'test'} $ hg rollback -n repository tip rolled back to revision 3 (undo debugobsolete) @@ -216,6 +255,7 @@ Rollback//Transaction support cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} + 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'} $ cd .. @@ -234,6 +274,7 @@ Try to pull markers cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} + 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'} Check obsolete keys are exchanged only if source has an obsolete store @@ -252,12 +293,18 @@ clone support updating to branch default 3 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg -R clone-dest log -G --hidden - @ changeset: 5:5601fb93a350 + @ changeset: 6:6f9641995072 | tag: tip | parent: 1:7c3bad9141dc | user: test | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: add new_3_c + | summary: add n3w_3_c + | + | x changeset: 5:5601fb93a350 + |/ parent: 1:7c3bad9141dc + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: add new_3_c | | x changeset: 4:ca819180edb9 |/ parent: 1:7c3bad9141dc @@ -291,6 +338,7 @@ clone support cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} + 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'} Destination repo have existing data @@ -315,6 +363,7 @@ On pull cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} + 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'} On push @@ -329,6 +378,7 @@ On push cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} + 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'} 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'} detect outgoing obsolete and unstable @@ -336,12 +386,12 @@ detect outgoing obsolete and unstable $ hg glog - o changeset: 3:5601fb93a350 + o changeset: 3:6f9641995072 | tag: tip | parent: 1:7c3bad9141dc | user: test | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: add new_3_c + | summary: add n3w_3_c | | o changeset: 2:245bde4270cd |/ user: test @@ -358,34 +408,34 @@ detect outgoing obsolete and unstable date: Thu Jan 01 00:00:00 1970 +0000 summary: add a - $ hg up 'desc("new_3_c")' + $ hg up 'desc("n3w_3_c")' 3 files updated, 0 files merged, 0 files removed, 0 files unresolved $ mkcommit original_d $ mkcommit original_e $ hg debugobsolete `getid original_d` -d '0 0' $ hg log -r 'obsolete()' - changeset: 4:7c694bff0650 + changeset: 4:94b33453f93b user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: add original_d $ hg glog -r '::unstable()' - @ changeset: 5:6e572121998e + @ changeset: 5:cda648ca50f5 | tag: tip | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: add original_e | - x changeset: 4:7c694bff0650 + x changeset: 4:94b33453f93b | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: add original_d | - o changeset: 3:5601fb93a350 + o changeset: 3:6f9641995072 | parent: 1:7c3bad9141dc | user: test | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: add new_3_c + | summary: add n3w_3_c | o changeset: 1:7c3bad9141dc | user: test @@ -403,7 +453,7 @@ refuse to push obsolete changeset $ hg push ../tmpc/ -r 'desc("original_d")' pushing to ../tmpc/ searching for changes - abort: push includes an obsolete changeset: 7c694bff0650! + abort: push includes an obsolete changeset: 94b33453f93b! [255] refuse to push unstable changeset @@ -411,7 +461,7 @@ refuse to push unstable changeset $ hg push ../tmpc/ pushing to ../tmpc/ searching for changes - abort: push includes an unstable changeset: 6e572121998e! + abort: push includes an unstable changeset: cda648ca50f5! [255] Test that extinct changeset are properly detected @@ -439,18 +489,18 @@ Don't try to push extinct changeset date: Thu Jan 01 00:00:00 1970 +0000 summary: add original_c - changeset: 3:5601fb93a350 + changeset: 3:6f9641995072 parent: 1:7c3bad9141dc user: test date: Thu Jan 01 00:00:00 1970 +0000 - summary: add new_3_c + summary: add n3w_3_c - changeset: 4:7c694bff0650 + changeset: 4:94b33453f93b user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: add original_d - changeset: 5:6e572121998e + changeset: 5:cda648ca50f5 tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 @@ -475,22 +525,22 @@ no warning displayed Do not warn about new head when the new head is a successors of a remote one $ hg glog - @ changeset: 5:6e572121998e + @ changeset: 5:cda648ca50f5 | tag: tip | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: add original_e | - x changeset: 4:7c694bff0650 + x changeset: 4:94b33453f93b | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: add original_d | - o changeset: 3:5601fb93a350 + o changeset: 3:6f9641995072 | parent: 1:7c3bad9141dc | user: test | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: add new_3_c + | summary: add n3w_3_c | | o changeset: 2:245bde4270cd |/ user: test @@ -507,7 +557,7 @@ Do not warn about new head when the new date: Thu Jan 01 00:00:00 1970 +0000 summary: add a - $ hg up -q 'desc(new_3_c)' + $ hg up -q 'desc(n3w_3_c)' $ mkcommit obsolete_e created new head $ hg debugobsolete `getid 'original_e'` `getid 'obsolete_e'` @@ -524,10 +574,10 @@ Checking _enable=False warning if obsole $ echo '[extensions]' >> $HGRCPATH $ echo "obs=!" >> $HGRCPATH $ hg log -r tip - obsolete feature not enabled but 7 markers found! - changeset: 6:d6a026544050 + obsolete feature not enabled but 8 markers found! + changeset: 6:3de5eca88c00 tag: tip - parent: 3:5601fb93a350 + parent: 3:6f9641995072 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: add obsolete_e