[PATCH 4 of 4] tests: add a new test for merging with memctx (RFC DO NOT COMMIT)
Sean Farley
sean.michael.farley at gmail.com
Wed Aug 20 20:02:27 UTC 2014
Pierre-Yves David writes:
> On 08/18/2014 07:42 PM, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley at gmail.com>
>> # Date 1408408797 18000
>> # Mon Aug 18 19:39:57 2014 -0500
>> # Node ID 169eaa48089acce06eb8afa95e1826cd217452ef
>> # Parent ed4082b72da600548d6c9ecec102a3639e9bf3e0
>> tests: add a new test for merging with memctx (RFC DO NOT COMMIT)
>>
>> Currently, the dirstate isn't updated for some reason.
>>
>> diff --git a/tests/test-merge-memctx.t b/tests/test-merge-memctx.t
>> new file mode 100644
>> --- /dev/null
>> +++ b/tests/test-merge-memctx.t
>> @@ -0,0 +1,86 @@
>> +
>> +Create a python script to test merging with memctx
>> +
>> + $ cat > memmerge.py << EOF
>> + > #!/usr/bin/env python
>> + > from mercurial import context, hg, merge, ui as uimod
>> + > from mercurial.node import nullid
>> + >
>> + > ui = uimod.ui()
>> + > myrepo = hg.repository(ui, '.')
>
> What about adding a new command in an extension instead so that you have
> something somewhat clean ?
Because that was too much work. I'd rather fix the manifest and status
stuff below first.
>> + >
>> + > ctxa = myrepo.changectx(2)
>> + > ctxb = myrepo.changectx(3)
>> + > orig = myrepo['.']
>> + >
>> + > # build a memctx off of ctxa (but set parents to ctxa and ctxb)
>> + > rctx = context.memctx(myrepo, [ctxa.node(), ctxb.node()], 'test merge',
>> + > ctxa.files(), ctxa, user=ctxa.user(), date=ctxa.date(),
>> + > extra=ctxa.extra())
>> + >
>> + > stats = merge.update(myrepo, ctxa.node(), True, True, False, ctxa.p1().node(), rctx=rctx)
>> + >
>> + > del rctx._status
>> + > del rctx._manifest
>
> Why is this necessary ?
Because both of those variables are cached before changing the data. I'd
like the cache to be updated after all the changes are made and am
looking into that now.
>> + >
>> + > wlock = myrepo.wlock()
>> + > try:
>> + > node = myrepo.commitctx(rctx)
>> + > myrepo.setparents(orig.node(), nullid)
>
> Why do you need to set parent afterward? commitctx with a memctx is not
> supposed to change the working director parent. Isn't it?
Correct, but merge.update does call repo.setparents. My updated work
doesn't need to do this hack.
>> + > myrepo.dirstate.write()
>
> Note that you dirstate is not going to rewrite itself up. See the
> `_uncommitdirstate` function in evolve for example of dirstate cleanup
> (probably stolen from somewhere in core)
There's something really weird going on with the dirstate that I can't
pin down yet. I can demonstrate it better with my new series.
> But I'm a bit puzzle by why the dirstate need to be touched at all as
> all operation should have happened in memory (same question for set parents)
I think something is going on with repo.commitctx but I'm not sure yet.
More information about the Mercurial-devel
mailing list