"Stripping" changesets from the past of a repository

Jim Hewes jhewes at docucap.com
Tue Nov 17 17:02:43 CST 2009


Thanks, Jochen and Martin. I don't know how the hashes are calculated. I
imagined they might be calculated from the hash of the previous revision
plus the contents of the current one. But even if that's true, you still
need for the first revision to have a fake hash which Mercurial must ignore
and make an exception for. So I see that it would be kludgey.

I suppose if you wanted to try to use hashes as tags, it's probably better
to adopt a convention where you say "this hash applies to that old archived
repository, but not to the new stripped down one". So if you want to go back
and rebuild your release, you must do it from the old archived repository
(which you keep stored somewhere).

Jim


-----Original Message-----
From: mercurial-bounces at selenic.com [mailto:mercurial-bounces at selenic.com]
On Behalf Of Jochen Schulz
Sent: Monday, November 16, 2009 11:32 PM
To: mercurial at selenic.com
Subject: Re: "Stripping" changesets from the past of a repository

Jim Hewes:
> 
> I thought I had read that changeset IDs were calculated based on 
> content from earlier revisions. If so, wouldn't it be possible when 
> stripping out earlier revisions to base the new repository on an 
> initial dummy revision that had a dummy changeset ID that caused all 
> subsequent changesets IDs to be the same as they were before?

If I understand it correctly, this amounts to breaking the hash algorithm in
use (SHA1, I suppose) by finding a collision (two input texts yielding the
same hash). While this is not impossible (has already been done, AFAIK), it
is generally something you don't want to be easily doable because a lot of
other uses of hash functions (mainly security
protocols) depend on this property of the hash function.

So, in a way, Mercurial is explicitly designed to prevent such things.
It really is a feature that you can count on a changeset ID representing one
and only one state of a repository.

J.
--
If politics is the blind leading the blind, entertainment is the fucked- up
leading the hypnotised.
[Agree]   [Disagree]
                 <http://www.slowlydownward.com/NODATA/data_enter2.html>



More information about the Mercurial mailing list