[PATCH] subrepo: Update .hgsubstate in case of deleted subrepo

Saint Germain saintger at gmail.com
Fri Feb 19 04:40:55 CST 2010


I'm willing to work on the next patch to manage this case.
But (of course depending on the opinion of hg gurus), I'd prefer to
keep this patch as it is, because it is currently quite simple and I'm
afraid to break other things with the next patch which is quite
sensitive.

Hopefully this patche may make it to the next release...

Regards,

2010/2/19 Steve Losh <steve at stevelosh.com>:
> Saint Germain and I have been talking about this patch on IRC.  I'm happy with this version of the patch, but I think we *might* be able to make it even better.
>
> The main question I have is about deleting .hgsubstate automatically when the user manually deletes .hgsub entirely.
>
> On the surface this seems like a good idea -- if you delete .hgsub that means there are no subrepos any more, so it seems like .hgsubstate should also be deleted.
>
> The question I have is: "What happens when person A deletes .hgsubstate and .hgsub and then tried to merge with person B who has added a new subrepo to .hgsub (and therefore .hgsubstate)?"
>
> Can Mercurial manage to merge the changes cleanly if we leave .hgsubstate blank (but not deleted), or are you going to get merge conflicts no matter what?
>
> On Feb 18, 2010, at 7:20 PM, Saint Germain wrote:
>
>> # HG changeset patch
>> # User Saint Germain <saintger at gmail.com>
>> # Date 1266538364 -3600
>> # Node ID 52bef2e2c25f10e806a0cdec03ed56e08f5a54c2
>> # Parent  b9e44cc97355ff27e05f6cd384061fc12731cec0
>> subrepo: Update .hgsubstate in case of deleted subrepo
>>
>> When a subrepo is deleted from .hgsub, it also need to be removed from .hgsubstate.
>> When .hgsub is removed, .hgsubstate need at least to be blanked out.
>> Previous code was updating .hgsubstate only in case of newly or modified subrepo.
>>
>> diff -r b9e44cc97355 -r 52bef2e2c25f mercurial/localrepo.py
>> --- a/mercurial/localrepo.py  Wed Feb 03 16:09:19 2010 +0000
>> +++ b/mercurial/localrepo.py  Fri Feb 19 01:12:44 2010 +0100
>> @@ -833,8 +833,9 @@
>>                 cctx._text = editor(self, cctx, subs)
>>             edited = (text != cctx._text)
>>
>> -            # commit subs
>> -            if subs:
>> +            # Update .hgsubstate if commited (added to .hgsub or modified) subs
>> +            # or deleted subs (removed from .hgsub)
>> +            if subs or '.hgsub' in changes[0]+changes[2]:
>>                 state = wctx.substate.copy()
>>                 for s in subs:
>>                     self.ui.status(_('committing subrepository %s\n') % s)
>> diff -r b9e44cc97355 -r 52bef2e2c25f tests/test-subrepo
>> --- a/tests/test-subrepo      Wed Feb 03 16:09:19 2010 +0000
>> +++ b/tests/test-subrepo      Fri Feb 19 01:12:44 2010 +0100
>> @@ -160,5 +160,28 @@
>>
>> hg up 5
>> hg merge 4    # try to merge default into br again
>> +cd ..
>> +rm -rf main
>>
>> +echo % test subrepo delete from .hgsubstate
>> +hg init main
>> +mkdir main/nested main/nested2
>> +hg init main/nested
>> +hg init main/nested2
>> +echo test > main/nested/foo
>> +echo test > main/nested2/foo
>> +hg -R main/nested add
>> +hg -R main/nested2 add
>> +hg -R main/nested ci -m test
>> +hg -R main/nested2 ci -m test
>> +echo nested = nested > main/.hgsub
>> +echo nested2 = nested2 >> main/.hgsub
>> +hg -R main add
>> +hg -R main ci -m "nested 1 & 2 added"
>> +echo nested = nested > main/.hgsub
>> +hg -R main ci -m "nested 2 deleted"
>> +cat main/.hgsubstate | sed "s:.* ::"
>> +hg -R main remove main/.hgsub
>> +hg -R main ci -m ".hgsub deleted"
>> +cat main/.hgsubstate
>> exit 0
>> diff -r b9e44cc97355 -r 52bef2e2c25f tests/test-subrepo.out
>> --- a/tests/test-subrepo.out  Wed Feb 03 16:09:19 2010 +0000
>> +++ b/tests/test-subrepo.out  Fri Feb 19 01:12:44 2010 +0100
>> @@ -243,3 +243,10 @@
>> 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>> 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>> (branch merge, don't forget to commit)
>> +% test subrepo delete from .hgsubstate
>> +adding main/nested/foo
>> +adding main/nested2/foo
>> +adding main/.hgsub
>> +committing subrepository nested2
>> +committing subrepository nested
>> +nested
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>
>


More information about the Mercurial-devel mailing list