Repo corrupted again, no idea why

Adrian Buehlmann adrian at cadifra.com
Sat Oct 2 11:56:06 UTC 2010


On 02.10.2010 12:31, Christian Ebert wrote:
> * Adrian Buehlmann on Friday, October 01, 2010 at 22:37:52 +0200
>> There error scenario for the hardlink problem mentioned is described at
>> http://mercurial.selenic.com/bts/issue761
>>
>> In that scenario, as I understand matters, there are no error messages
>> at the moment the problem starts happening. The corruption is silent.
>>
>> The problem is, if a 'hg clone' was done (without --pull option), then
>> the destination and the source repo share files inside .hg/store by
>> using hardlinks [1], if the filesystem provides the hardlinking feature
>> (NTFS does).
>>
>> Mercurial is designed to break such hardlinks inside .hg if a commit or
>> push is done to one of the clones. The prerequisite for this is, that
>> the Windows API mercurial is using should give a correct answer, if
>> mercurial is asking "how many hardlinks are on this file?".
> 
> From a paranoid pov hg clone w/o pull is dangerous anyway, e.g.
> rm -P:
> 
> $ hg init testrm
> $ cd testrm/
> $ echo foo > a
> $ hg ci -Amfoo a
> $ cd ..
> $ hg clone testrm testrm-hardlink
> updating to branch default
> 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> $ rm -rP testrm-hardlink/
> $ cd testrm
> $ hg log
> abort: requirement '�����������������������' not supported!

I didn't even know about this -P option of rm (what unix/linux was
that?). Only found this for BSD:

-P      Overwrite regular files before deleting them.  Files are over-
        written three times, first with the byte pattern 0xff, then
        0x00, and then 0xff again, before they are deleted.  Files with
        multiple links will not be overwritten nor deleted unless -f is
        specified, a warning is generated instead.

On my Ubuntu Linux, there is no such -P option for rm.

Windows DEL doesn't have such an option. Deleting hardlinked local repos
on Windows seems to work fine, also with Explorer (just moving the clone
root directory to the trash can and deleting the trash is fine).

As quick sample test I tried to emulate your scenario and used a
software I have installed on my Windows 7 called "PGP shredder", which
is supposed to overwrite files before deleting them. It worked as
expected when applied to hardlinked clones: the original clone was still
fine after shreddering the copy. But of course this might not be true
for every piece of software you might allow to fiddle with your files
inside .hg.

So to have a fool-proof & desaster-proof copy, using 'hg clone --pull'
might indeed be a good idea. But the NTFS file system accessed locally
certainly doesn't have a problem with hardlinks.




More information about the Mercurial mailing list