# HG changeset patch # User Pierre-Yves David # Date 1350600113 -7200 # Node ID 70b08df24fefa12ed460334714f142be2a3be93b # Parent 1cb51d65453dd6d2cf38e2733a326d87125ac256 obsolete: add a flag that allows fixing "bumped" changeset The first obsolescence flag is introduced to allows for fixing the "bumped" changeset situation. bumpedfix == 1. Creator of new changesets intended to fix "bumped" situation should not forget to add this flag to the marker. Otherwise the newly created changeset will be bumped too. See inlined documentation for details. diff -r 1cb51d65453d -r 70b08df24fef mercurial/obsolete.py --- a/mercurial/obsolete.py Mon Oct 15 14:45:27 2012 +0200 +++ b/mercurial/obsolete.py Fri Oct 19 00:41:53 2012 +0200 @@ -102,6 +102,37 @@ _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 @@ 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 @@ 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 @@ # 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 -r 1cb51d65453d -r 70b08df24fef tests/test-obsolete.t --- a/tests/test-obsolete.t Mon Oct 15 14:45:27 2012 +0200 +++ b/tests/test-obsolete.t Fri Oct 19 00:41:53 2012 +0200 @@ -171,6 +171,43 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ $ 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 @@ 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 @@ $ 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 @@ $ 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 @@ 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 @@ 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 @@ 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 @@ $ 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