Confused repository.

Simon King simon at simonking.org.uk
Tue Dec 2 12:29:07 UTC 2014


On Tue, Dec 2, 2014 at 9:02 AM, Rob Landley <rob at landley.net> wrote:
> I accidentally commited a change on top of another change I thought I'd
> rolled back, and since rollback won't go more than one back that means
> my working repository is toast,

Before I answer your other questions, I should point out that the
recommended way to fix this would be to "hg update" to the parent of
the change that you didn't want, and if necessary use "hg graft" to
transfer the commit that you *did* want into the right place.
Unfortunately, this will leave a dangling pair of changes in your
repository, which will cause errors when you "hg push" unless you
specify which revision you want to push.

The safest way to remove the dangling changes is to clone your local
repository using the "-r" switch to specify the revision that you want
to keep.

The experimental "evolve" extension provides a cleaner way of doing
all this - I think you would just run "hg prune <bad-revision>",
probably followed by "hg evolve".

http://mercurial.selenic.com/wiki/EvolveExtension

> so I replaced the .hg subdirectory with
> the one from the website (copying the hgrc file out of it first) and now
> the repository thinks the "current" version is an old commit from July,
> even though the .hg directory I cloned from has the newer commits up to
> yesterday.
>
> Where is it getting this information from?

The "currently checked out revision" is stored in the .hg/dirstate file

http://mercurial.selenic.com/wiki/DirState

>
> $ strace hg identify 2>&1 | grep '^open(' | wc -l
>     621
>
> Is there any way to do a checkout without changing files in the current
> directory?
>

The command "hg debugrebuilddirstate" can be used to change the parent
revision of the working directory without touching any files in the
working directory. As with all debug* commands, you should fully
understand what you are doing before using it.

Hope that helps,

Simon



More information about the Mercurial mailing list