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

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 14, 2014, 10:03 p.m.
Message ID <c897a04605dd7bdd59dd.1408053788@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5402/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 14, 2014, 10:03 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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).
Matt Mackall - Aug. 14, 2014, 11:19 p.m.
On Thu, 2014-08-14 at 15:03 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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

These are queued for stable, thanks.

Patch

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