[PATCH 7 of 9 V2] obsolete: add a flag that allows fixing "bumped" changeset
pierre-yves.david at logilab.fr
pierre-yves.david at logilab.fr
Mon Oct 15 07:46:21 CDT 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1350304080 -7200
# Node ID 327931aebaab5b274af5f8b7cab9a4204a8c0f4e
# Parent 3e8b1d6d762e6d20cc1022486d80a25be033f153
obsolete: add a flag that allows fixing "bumped" changeset
The first obsolescence flag is introduce 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 --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -94,10 +94,41 @@ from i18n import _
_fmfixed = '>BIB20s'
_fmnode = '20s'
_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. <A', (Ad,)>.
+# 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
diskversion = _unpack('>B', data[off:off + 1])[0]
off += 1
@@ -426,21 +457,24 @@ def _computeextinctset(repo):
@cachefor('bumped')
def _computebumpedset(repo):
"""the set of rev trying to obsolete public revision"""
# get all possible bumped changesets
- candidates = _allflatsuccessors(repo, repo.revs('public()'))
+ candidates = _allflatsuccessors(repo, repo.revs('public()'),
+ ignoreflags=bumpedfix)
# revision public or already obsolete don't count as bumped
query = '%ld - obsolete() - public()'
return set(repo.revs(query, candidates))
-def _allflatsuccessors(repo, revs):
+def _allflatsuccessors(repo, revs, ignoreflags=0):
"""return revid of all successors of a set of revs
Only know node are returned (unknown node does not have revid). This
function loose the split vs divergence information, revision are not
grouped by successors set.
+
+ Markers with any flags present in the `ignoreflags` bitfield are ignored.
"""
cl = repo.changelog
pending = [cl.node(r) for r in revs]
# prevent extra processing and cycle
seen = set(pending)
@@ -450,10 +484,13 @@ def _allflatsuccessors(repo, revs):
markersfor = repo.obsstore.precursors
while pending:
nc = pending.pop()
# for all markers that make this node obsolete
for mark in markersfor.get(nc, ()):
+ # ignore marker flagged with with specified flag
+ if mark[2] & ignoreflags:
+ continue
# for all successors
for suc in mark[1]:
# record this as a successors
successors.add(suc)
# add it to the list of node to proceed
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -169,10 +169,47 @@ the public changset
user: test
date: Thu Jan 01 00:00:00 1970 +0000
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
============================
@@ -195,29 +232,32 @@ Try to pull markers
$ hg debugobsolete
245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
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
$ hg debugobsolete -d '1340 0' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
$ hg debugobsolete
245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
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)
$ hg rollback
repository tip rolled back to revision 3 (undo debugobsolete)
$ hg debugobsolete
245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
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 ..
Try to pull markers
@@ -232,10 +272,11 @@ Try to pull markers
$ hg -R tmpd debugobsolete
245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
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
$ hg init empty
$ hg --config extensions.debugkeys=debugkeys.py -R empty push tmpd
@@ -250,16 +291,22 @@ clone support
$ hg clone tmpb clone-dest
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
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
@@ -289,10 +336,11 @@ clone support
$ hg -R clone-dest debugobsolete
245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
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
---------------------------------------
@@ -313,10 +361,11 @@ On pull
2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'}
245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
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
$ hg push ../tmpc
@@ -327,23 +376,24 @@ On push
$ hg -R ../tmpc debugobsolete
245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
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
---------------------------------------
$ 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
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: add original_c
@@ -356,38 +406,38 @@ detect outgoing obsolete and unstable
o changeset: 0:1f0dee641bb7
user: test
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
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: add b
@@ -401,19 +451,19 @@ detect outgoing obsolete and unstable
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
$ 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
$ hg log -r 'extinct()'
@@ -437,22 +487,22 @@ Don't try to push extinct changeset
changeset: 2:245bde4270cd
user: test
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
summary: add original_e
@@ -473,26 +523,26 @@ no warning displayed
[1]
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
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: add original_c
@@ -505,11 +555,11 @@ Do not warn about new head when the new
o changeset: 0:1f0dee641bb7
user: test
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'`
$ hg push ../tmpf
pushing to ../tmpf
@@ -522,13 +572,13 @@ Do not warn about new head when the new
Checking _enable=False warning if obsolete marker exists
$ 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
More information about the Mercurial-devel
mailing list