Patchwork [1,of,2,STABLE] debugobsolete: catch ValueError that may be raised by obsstore.create

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 14, 2014, 10:03 p.m.
Message ID <bc57cad7a920f3425bf0.1408053787@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5401/
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 1408053423 25200
#      Thu Aug 14 14:57:03 2014 -0700
# Branch stable
# Node ID bc57cad7a920f3425bf0db6b68475a4c5e3c0436
# Parent  989c16c1b050a314e136675ca9ac73a90d13da2a
debugobsolete: catch ValueError that may be raised by obsstore.create

There is already of couple of error that obsstore.create can raise and we are
going to introduce a cycle check too.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2336,13 +2336,16 @@  def debugobsolete(ui, repo, precursor=No
         succs = tuple(parsenodeid(succ) for succ in successors)
         l = repo.lock()
         try:
             tr = repo.transaction('debugobsolete')
             try:
-                repo.obsstore.create(tr, parsenodeid(precursor), succs,
-                                     opts['flags'], metadata)
-                tr.close()
+                try:
+                    repo.obsstore.create(tr, parsenodeid(precursor), succs,
+                                         opts['flags'], metadata)
+                    tr.close()
+                except ValueError, exc:
+                    raise util.Abort(_('bad obsmarker input: %s') % exc)
             finally:
                 tr.release()
         finally:
             l.release()
     else: