[PATCH 5 of 7 V2] obsolete: add a flag that allows fix for "bumped" changeset

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Oct 3 16:21:58 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1349298229 -7200
# Node ID 6f36fcc8f5315fa54d6104348c8d175838f15825
# Parent  d3d9bf88c71542eb5f34e4c9970a66adc536fa83
obsolete: add a flag that allows fix for "bumped" changeset

The first obsolescence marker is introduce to allows for fixing the "bumped"
changeset situation.  For allow fixing this situation, the first flag for
obsolescence marker is introduced.

    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.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -71,6 +71,9 @@
 _fmfsize = struct.calcsize(_fmfixed)
 _fnodesize = struct.calcsize(_fmnode)
 
+# obsolescence marker flag
+bumpedfix = 1
+
 def _readmarkers(data):
     """Read and enumerate markers from raw data"""
     off = 0
@@ -403,13 +406,16 @@
 def _computebumpedset(repo):
     """the set of rev trying to obsolete public revision"""
     # get all possible bumped changeset
-    candidates = _anysuccessors(repo, repo.revs('public()'))
+    candidates = _anysuccessors(repo, repo.revs('public()'),
+                                ignoreflags=bumpedfix)
     # revision public or already obsolete don't account as bumped
     query = '%ld - obsolete() - public()'
     return set(repo.revs(query, candidates))
 
-def _anysuccessors(repo, revs):
+def _anysuccessors(repo, revs, ignoreflags=0):
     """return revid of all successors of a set of revs
+
+    Marker with any flags present in the `ignoreflags` bitfield are ignored.
     """
     toproceed = [repo[r].node() for r in revs]
     # prevent extra processing and cycle
@@ -422,6 +428,9 @@
         nc = toproceed.pop()
         # for all markers that make this node obsolete
         for mark in markersfor.get(nc, ()):
+            # ignore marker with flaged with specified flag
+            if mark[2] & ignoreflags:
+                continue
             # for all successors
             for suc in mark[1]:
                 # record this as a successors
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -166,6 +166,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
@@ -192,6 +229,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
 
@@ -201,6 +239,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)
@@ -211,6 +250,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 ..
 
@@ -229,6 +269,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
 
@@ -247,12 +288,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
@@ -286,6 +333,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
@@ -310,6 +358,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
@@ -324,6 +373,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
@@ -331,12 +381,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
@@ -353,34 +403,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
@@ -398,7 +448,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
@@ -406,7 +456,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
@@ -434,18 +484,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
@@ -470,22 +520,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
@@ -502,7 +552,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'`
@@ -519,10 +569,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


More information about the Mercurial-devel mailing list