Patchwork [1,of,4,for-reference] obsstore: add a flag for sha256 hashes

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 10, 2014, 11:25 p.m.
Message ID <b078e4dc9f9abfcf30c0.1412983505@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6213/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 10, 2014, 11:25 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1412977384 18000
#      Fri Oct 10 16:43:04 2014 -0500
# Node ID b078e4dc9f9abfcf30c001b60235cdc53e447920
# Parent  fd759142c6e5487c0f8d65847c9f29f35969c66c
obsstore: add a flag for sha256 hashes

We add flag to inform that the marker is using sha256 hashes. As format 0 is not
able to handle sha256 hashes (32 bytes long), we plain crash if we even attempt to
encode a sha256 with it.
Pierre-Yves David - Oct. 10, 2014, 11:26 p.m.
On 10/10/2014 04:25 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1412977384 18000
> #      Fri Oct 10 16:43:04 2014 -0500
> # Node ID b078e4dc9f9abfcf30c001b60235cdc53e447920
> # Parent  fd759142c6e5487c0f8d65847c9f29f35969c66c
> obsstore: add a flag for sha256 hashes

This has been pushed to the clowncopter along side some minor related 
changes and a load of revset related changesets.

All review done over the phone by Matt.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -110,10 +110,11 @@  from i18n import _
 # as bumped too, we add the `bumpedfix` flag to the marker. <A', (Ad,)>.
 # This flag mean that the successors express the changes between the public and
 # bumped version and fix the situation, breaking the transitivity of
 # "bumped" here.
 bumpedfix = 1
+usingsha256 = 2
 
 ## Parsing and writing of version "0"
 #
 # The header is followed by the markers. Each marker is made of:
 #
@@ -191,10 +192,12 @@  def _fm0readmarkers(data, off=0):
 
         yield (pre, sucs, flags, metadata, date, parents)
 
 def _fm0encodeonemarker(marker):
     pre, sucs, flags, metadata, date, parents = marker
+    if flags & usingsha256:
+        raise util.Abort(_('cannot handle sha256 with old obsstore format'))
     metadata = dict(metadata)
     metadata['date'] = '%d %i' % date
     if parents is not None:
         if not parents:
             # mark that we explicitly recorded no parents