[PATCH 9 of 9 V2] obsolete: do not exchange extinct changesets

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Fri Jul 6 12:54:10 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1341534252 -7200
# Node ID d1e45883e73c41694d568329578a8d4b3996a956
# Parent  a4f7ce4f78987bad5054ca91acd2b614fb982104
obsolete: do not exchange extinct changesets

Extinct changesets are excluded from all exchange operations. This is a silent
exclusion because the user should not need to be aware of them.

There is no reason to strongly enforce this exclusion except implementation
simplicity. User should be able to explicitly request an extinct changeset in
the future.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -107,34 +107,37 @@ def findcommonoutgoing(repo, other, only
     if commoninc is None:
         commoninc = findcommonincoming(repo, other, force=force)
     og.commonheads, _any, _hds = commoninc
 
     # compute outgoing
-    if not repo._phasecache.phaseroots[phases.secret]:
+    mayexclude = (repo._phasecache.phaseroots[phases.secret] or repo.obsstore)
+    if not mayexclude:
         og.missingheads = onlyheads or repo.heads()
     elif onlyheads is None:
         # use visible heads as it should be cached
         og.missingheads = repo.visibleheads()
+        # extinct changesets are silently ignored
         og.excluded = [ctx.node() for ctx in repo.set('secret()')]
     else:
         # compute common, missing and exclude secret stuff
         sets = repo.changelog.findcommonmissing(og.commonheads, onlyheads)
         og._common, allmissing = sets
         og._missing = missing = []
         og.excluded = excluded = []
         for node in allmissing:
-            if repo[node].phase() >= phases.secret:
-                excluded.append(node)
-            else:
-                missing.append(node)
-        if excluded:
-            # update missing heads
+            ctx = repo[node]
+            if not ctx.extinct():
+                # extinct changesets are silently ignored
+                if ctx.phase() >= phases.secret:
+                    excluded.append(node)
+                else:
+                    missing.append(node)
+        if len(missing) == len(allmissing):
+            missingheads = onlyheads
+        else: # update missing heads
             missingheads = phases.newheads(repo, onlyheads, excluded)
-        else:
-            missingheads = onlyheads
         og.missingheads = missingheads
-
     if portable:
         # recompute common and missingheads as if -r<rev> had been given for
         # each head of missing, and --base <rev> for each head of the proper
         # ancestors of missing
         og._computecommonmissing()
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -517,21 +517,22 @@ class localrepository(repo.repository):
     def visiblebranchmap(self):
         """return a branchmap for the visible set"""
         # XXX Recomputing this data on the fly is very slow.  We should build a
         # XXX cached version while computin the standard branchmap version.
         sroots = self._phasecache.phaseroots[phases.secret]
-        if sroots:
+        if sroots or self.obsstore:
             vbranchmap = {}
             for branch, nodes in  self.branchmap().iteritems():
                 # search for secret heads.
                 for n in nodes:
                     if self[n].phase() >= phases.secret:
                         nodes = None
                         break
-                # if secreat heads where found we must compute them again
+                # if secret heads were found we must compute them again
                 if nodes is None:
-                    s = self.set('heads(branch(%s) - secret())', branch)
+                    s = self.set('heads(branch(%s) - secret() - extinct())',
+                                 branch)
                     nodes = [c.node() for c in s]
                 vbranchmap[branch] = nodes
         else:
             vbranchmap = self.branchmap()
         return vbranchmap
@@ -1585,14 +1586,14 @@ class localrepository(repo.repository):
 
     def visibleheads(self):
         """return the set of visible head of this self"""
         # XXX we want a cache on this
         sroots = self._phasecache.phaseroots[phases.secret]
-        if sroots:
+        if sroots or self.obsstore:
             # XXX very slow revset. storing heads or secret "boundary"
             # would help.
-            revset = self.set('heads(not (%ln::))', sroots)
+            revset = self.set('heads(not (%ln:: + extinct()))', sroots)
 
             vheads = [ctx.node() for ctx in revset]
             if not vheads:
                 vheads.append(nullid)
         else:
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -150,20 +150,21 @@ Exchange Test
 
 Destination repo does not have any data
 ---------------------------------------
 
 Try to pull markers
+(extinct changeset are excluded but marker are pushed)
 
   $ hg init tmpc
   $ cd tmpc
   $ hg pull ../tmpb
   pulling from ../tmpb
   requesting all changes
   adding changesets
   adding manifests
   adding file changes
-  added 6 changesets with 6 changes to 6 files (+3 heads)
+  added 4 changesets with 4 changes to 4 files (+1 heads)
   (run 'hg heads' to see heads, 'hg merge' to merge)
   $ hg debugobsolete
   ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
   cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
   245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'}
@@ -175,16 +176,10 @@ Try to pull markers
 
   $ hg init tmpd
   $ hg -R tmpb push tmpd
   pushing to tmpd
   searching for changes
-  abort: push includes an obsolete changeset: ca819180edb9!
-  [255]
-  $ hg -R tmpd debugobsolete
-  $ hg -R tmpb push tmpd --rev 'not obsolete()'
-  pushing to tmpd
-  searching for changes
   adding changesets
   adding manifests
   adding file changes
   added 4 changesets with 4 changes to 4 files (+1 heads)
   $ hg -R tmpd debugobsolete
@@ -206,11 +201,11 @@ On pull
   pulling from ../tmpb
   requesting all changes
   adding changesets
   adding manifests
   adding file changes
-  added 6 changesets with 6 changes to 6 files (+3 heads)
+  added 4 changesets with 4 changes to 4 files (+1 heads)
   (run 'hg heads' to see heads, 'hg merge' to merge)
   $ hg debugobsolete
   2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'}
   ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
   cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
@@ -232,30 +227,19 @@ On push
   2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'}
 
 detect outgoing obsolete and unstable
 ---------------------------------------
 
+
   $ hg glog
-  o  changeset:   5:5601fb93a350
+  o  changeset:   3:5601fb93a350
   |  tag:         tip
   |  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
-  |    summary:     add new_2_c
-  |
-  | x  changeset:   3:cdbce2fbb163
-  |/   parent:      1:7c3bad9141dc
-  |    user:        test
-  |    date:        Thu Jan 01 00:00:00 1970 +0000
-  |    summary:     add new_c
-  |
   | o  changeset:   2:245bde4270cd
   |/   user:        test
   |    date:        Thu Jan 01 00:00:00 1970 +0000
   |    summary:     add original_c
   |
@@ -267,25 +251,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 -q 'desc("new_2_c")'
+  $ hg up 'desc("new_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
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add original_d
+  
   $ hg glog -r '::unstable()'
-  @  changeset:   6:7878242aeece
+  @  changeset:   5:6e572121998e
   |  tag:         tip
-  |  parent:      4:ca819180edb9
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     add original_e
+  |
+  x  changeset:   4:7c694bff0650
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     add original_d
   |
-  x  changeset:   4:ca819180edb9
+  o  changeset:   3:5601fb93a350
   |  parent:      1:7c3bad9141dc
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     add new_2_c
+  |  summary:     add new_3_c
   |
   o  changeset:   1:7c3bad9141dc
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     add b
@@ -293,20 +290,79 @@ detect outgoing obsolete and unstable
   o  changeset:   0:1f0dee641bb7
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     add a
   
+
+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!
+  [255]
+
+refuse to push unstable changeset
+
   $ hg push ../tmpc/
   pushing to ../tmpc/
   searching for changes
-  abort: push includes an unstable changeset: 7878242aeece!
+  abort: push includes an unstable changeset: 6e572121998e!
   [255]
 
 Test that extinct changeset are properly detected
 
   $ hg log -r 'extinct()'
-  changeset:   3:cdbce2fbb163
+
+Don't try to push extinct changeset
+
+  $ hg init ../tmpf
+  $ hg out  ../tmpf
+  comparing with ../tmpf
+  searching for changes
+  changeset:   0:1f0dee641bb7
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add a
+  
+  changeset:   1:7c3bad9141dc
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add b
+  
+  changeset:   2:245bde4270cd
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add original_c
+  
+  changeset:   3:5601fb93a350
   parent:      1:7c3bad9141dc
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     add new_c
+  summary:     add new_3_c
   
+  changeset:   4:7c694bff0650
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add original_d
+  
+  changeset:   5:6e572121998e
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add original_e
+  
+  $ hg push ../tmpf -f # -f because be push unstable too
+  pushing to ../tmpf
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 6 changesets with 6 changes to 6 files (+1 heads)
+
+no warning displayed
+
+  $ hg push ../tmpf
+  pushing to ../tmpf
+  searching for changes
+  no changes found
+  [1]


More information about the Mercurial-devel mailing list