A tale of user-friendliness with "hg merge" and "hg rollback".

Adrian Buehlmann adrian at cadifra.com
Tue Oct 13 17:42:53 CDT 2009


On 13.10.2009 23:37, Kevin Bullock wrote:
> On 13 Oct 2009, at 4:10 PM, Adrian Buehlmann wrote:
> 
>> Ultimate question: shouldn't 'hg rollback' fail with
>>
>>   no rollback information available
>>
>> for each and every successful fresh clone, no matter from
>> where it was cloned?
> 
> I'll let others answer this one, but...
> 
>> Rollback is supposed to bring a repository back to some previous  
>> state.
>>
>> But an empty directory is not a valid repository.
>>
>> Couldn't we say that for any repository X where hg verify succeeds and
>> where we can do a hg rollback on X, a later 'hg verify' should succeed
>> too? (the 'verify invariant').
>>
>> But 'hg verify' fails on an empty directory.
> 
> A clone-then-rollback doesn't leave an empty directory, nor an invalid  
> repository:
> 
> $ hg init test-repo
> $ cd test-repo
> $ echo foo > foo.txt
> $ hg ci -A -m 'add foo.txt'
> adding foo.txt
> $ cd ..
> $ hg clone --pull test-repo cloned-repo
> requesting all changes
> adding changesets
> adding manifests
> adding file changes
> added 1 changesets with 1 changes to 1 files
> updating working directory
> 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> $ cd cloned-repo/
> $ hg log --style compact
> 0[tip]   bd3bf3d2bd00   2009-10-13 16:33 -0500   kbullock
>    add foo.txt
> 
> $ ls
> foo.txt
> $ hg rollback
> rolling back last transaction
> $ ls -A
> .hg/  foo.txt
> $ hg verify
> checking changesets
> checking manifests
> crosschecking files in changesets and manifests
> checking files
> 0 files, 0 changesets, 0 total revisions
> $ hg log --style compact
> $
> 
> It leaves a repository with no changesets. But your 'verify invariant'  
> holds.

Right. My bad.

But it brings you back to a state that you actually didn't have before.
You have the foo.txt file in the repo root.

The state before the clone --pull was a nonexistent directory.

The resulting state is actually looking quite terrifying: you have all
your "usual" files in the repo root, but the history is "gone".
A Potemkin repo.

And the --pull was needed to demonstrate it (or a pull over the wire).

A standard local clone can't be rolled back.




More information about the Mercurial mailing list