[PATCH 2 of 6] checkheads: take phases into account when computing new heads with obsolete

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Fri Aug 24 10:14:56 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1345819965 -7200
# Node ID 80142228fec06522f5f4446eb02e9acfcb56df82
# Parent  34b23e69ef5c5be6a5ebc2109b9abb18c27c597f
checkheads: take phases into account when computing new heads with obsolete

Checkheads were more permissive than expected. When the remote heads is public we
don't need to search for successors. None will make a public head disappear.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -291,15 +291,18 @@ def checkheads(repo, remote, outgoing, r
             #
             # This two case will be easy to handle for know changeset but much
             # more tricky for unsynced changes.
             newhs = set()
             for nh in candidate_newhs:
-                for suc in obsolete.anysuccessors(repo.obsstore, nh):
-                    if suc != nh and suc in allmissing:
-                        break
+                if repo[nh].phase() <= phases.public:
+                    newhs.add(nh)
                 else:
-                    newhs.add(nh)
+                    for suc in obsolete.anysuccessors(repo.obsstore, nh):
+                        if suc != nh and suc in allmissing:
+                            break
+                    else:
+                        newhs.add(nh)
         else:
             newhs = candidate_newhs
         if len(newhs) > len(oldhs):
             # strip updates to existing remote heads from the new heads list
             dhs = list(newhs - bookmarkedheads - oldhs)
diff --git a/tests/test-obsolete-checkheads.t b/tests/test-obsolete-checkheads.t
--- a/tests/test-obsolete-checkheads.t
+++ b/tests/test-obsolete-checkheads.t
@@ -69,17 +69,77 @@ Push should not warn about creating new 
   adding changesets
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
 
+old head is now public (public locally version)
+===========================================================
+
+setup
+
+  $ rm -fr ../remote
+  $ cp -r ../backup1 ../remote
+  $ hg -R ../remote phase --public c70b08862e08
+  $ hg pull -v
+  pulling from $TESTTMP/remote
+  searching for changes
+  no changes found
+  $ hg glog --hidden
+  @  71e3228bffe1 (draft) add new
+  |
+  | o  c70b08862e08 (public) add old
+  |/
+  o  b4952fcf48cf (public) add base
+  
+
+Abort: old will still be an head because it's public.
+
+  $ hg push
+  pushing to $TESTTMP/remote
+  searching for changes
+  abort: push creates new remote head 71e3228bffe1!
+  (did you forget to merge? use push -f to force)
+  [255]
+
+old head is now public (public remotly version)
+===========================================================
+
+TODO: Not implemented yet.
+
+# setup
+#
+#   $ rm -fr ../remote
+#   $ cp -r ../backup1 ../remote
+#   $ hg -R ../remote phase --public c70b08862e08
+#   $ hg phase --draft --force c70b08862e08
+#   $ hg glog --hidden
+#   @  71e3228bffe1 (draft) add new
+#   |
+#   | x  c70b08862e08 (draft) add old
+#   |/
+#   o  b4952fcf48cf (public) add base
+#
+#
+#
+# Abort: old will still be an head because it's public.
+#
+#   $ hg push
+#   pushing to $TESTTMP/remote
+#   searching for changes
+#   abort: push creates new remote head 71e3228bffe1!
+#   (did you forget to merge? use push -f to force)
+#   [255]
+
+
 old head is obsolete but remplacement in not pushed
 ===========================================================
 
 setup
 
   $ rm -fr ../remote
   $ cp -r ../backup1 ../remote
+  $ hg phase --draft --force '(0::) - 0'
   $ hg up -q '.^'
   $ mkcommit other
   created new head
   $ hg glog --hidden
   @  d7d41ccbd4de (draft) add other


More information about the Mercurial-devel mailing list