[PATCH] Add an explicit call to dirstate.write to debugsetparents.

Nathan Binkert nate at binkert.org
Mon Mar 12 20:07:13 CDT 2007


I know this is a way old patch, but I'd like to point out that in the head 
at least, this is necessary if you follow debugsetparents with commit. 
commit might call repo.status() which will overwrite the value that was 
there since it's likely that __del__ will not have happened by then.

Now, I'll admit that this will only happen if you import 
mercurial.commands and are trying to call one after the other in a python 
script.  (I'm trying to make tailor support parents properly.)

Thanks,

   Nate


> Thus spake Chris Mason:
>> Oh, I see.  In this case it is better to write the dirstate explicitly I
>> think in the debugsetparents command.
>
> Fine by me - but there are many other places in hg that rely on __del__
> to write the dirstate, release locks, etc...
>
> Alexis
>
> # HG changeset patch
> # User Alexis S. L. Carvalho <alexis at cecm.usp.br>
> # Date 1153261181 10800
> # Node ID cb0c0ff840d830f844c55227808909d839670439
> # Parent  837119f1bf4dad03cc30479b7c90b74103b4d04a
> Add an explicit call to dirstate.write to debugsetparents.
>
> This avoids relying on __del__ to write the dirstate, which was failing
> when the mq extension was loaded, because of the reference to the repo
> object that mq keeps in its repomap dict.
>
> diff -r 837119f1bf4d -r cb0c0ff840d8 mercurial/commands.py
> --- a/mercurial/commands.py	Mon Jul 17 11:30:33 2006 -0500
> +++ b/mercurial/commands.py	Tue Jul 18 19:19:41 2006 -0300
> @@ -1312,6 +1312,7 @@ def debugsetparents(ui, repo, rev1, rev2
>         rev2 = hex(nullid)
>
>     repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
> +    repo.dirstate.write()
>
> def debugstate(ui, repo):
>     """show the contents of the current dirstate"""
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com
> http://selenic.com/mailman/listinfo/mercurial
>


More information about the Mercurial mailing list