[PATCH 2 of 2 STABLE] obsstore.create: add a simple safeguard about cyclic marker

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Aug 14 17:03:08 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1408053582 25200
#      Thu Aug 14 14:59:42 2014 -0700
# Branch stable
# Node ID c897a04605dd7bdd59dd23ea2bb508e3431e0ffc
# Parent  bc57cad7a920f3425bf0db6b68475a4c5e3c0436
obsstore.create: add a simple safeguard about cyclic marker

We detect when there is a cycle in the marker itself (precursors being listed
as successors).

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -275,10 +275,12 @@ class obsstore(object):
         if len(prec) != 20:
             raise ValueError(prec)
         for succ in succs:
             if len(succ) != 20:
                 raise ValueError(succ)
+        if prec in succs:
+            raise ValueError(_('in-marker cycle with %s') % node.hex(prec))
         marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata))
         return bool(self.add(transaction, [marker]))
 
     def add(self, transaction, markers):
         """Add new markers to the store
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -62,10 +62,18 @@ Killing a single changeset without repla
   tag:         tip
   user:        
   date:        Thu Jan 01 00:00:00 1970 +0000
   
   $ hg up --hidden tip --quiet
+
+Killing a single changeset with itself should fail
+(simple local safe guard)
+
+  $ hg debugobsolete `getid kill_me` `getid kill_me`
+  abort: bad obsmarker input: in-marker cycle with 97b7c2d76b1845ed3eb988cd612611e72406cef0
+  [255]
+
   $ cd ..
 
 Killing a single changeset with replacement
 
   $ hg init tmpb


More information about the Mercurial-devel mailing list