[PATCH 5 of 6 DEFAULT] remove: support removing explicit paths in subrepos

David M. Carr david at carrclan.us
Mon Jan 16 17:28:07 CST 2012


On Mon, Jan 16, 2012 at 4:59 AM, Martin Geisler <mg at aragost.com> wrote:
> "David M. Carr" <david at carrclan.us> writes:
>
>> On Sun, Jan 15, 2012 at 10:26 AM, Martin Geisler <mg at lazybytes.net> wrote:
>>> "David M. Carr" <david at carrclan.us> writes:
>>>
>>>> # HG changeset patch
>>>> # User David M. Carr  <david at carrclan.us>
>>>> # Date 1326514745 18000
>>>> # Node ID 471cea2010939c4186b269e0bf47db1f445ad516
>>>> # Parent  97f8b28771e6ad077e58b6536d207e79516b61ac
>>>> remove: support removing explicit paths in subrepos
>>>>
>>> If I understand this part correctly, then it loops over the current
>>> subrepositories and then filters/removes/... files.
>>>
>>> I think that is wrong. There can be further nested Mercurial subrepos
>>> inside the top-level Mercurial subrepos. So there need to be some
>>> form of recusion here.
>>>
>>> The code for 'hg add' should be similar. In 877236cdd437 I moved it
>>> from mercurial.commands to mercurial.cmdutil and in 166b9866580a I
>>> made it understand the -S flag. The basic idea is to have a flow
>>> where
>>>
>>> * command.add kicks things off by calling cmdutil.add
>>>
>>> * cmdutil.add does two things:
>>>
>>>  - operates on the current repo
>>>
>>>  - iterates over subrepos and calls sub.add on the sub objects
>>>    (polymorphism at work)
>>>
>>> * for a hgsubrepo sub, sub.add calls cmdutil.add with the subrepo as the
>>>  current repo. Other subrepo classes just add the files and have no
>>>  further recursive calls (no hgsubrepo inside a gitsubrepo).
>>>
>>> So you can have multiple levels of recursion where cmdutil.add calls
>>> sub.add, which in turn calls back to cmdutil.add.
>>>
>>> That way both mercurial.commands and mercurial.subrepo becomes fairly
>>> thin and the main work is done in mercurial.cmdutil.
>>
>> Thanks for the feedback, Martin. I'll rework this patch series based
>> on the approach of extracting logic out of commands.remove into
>> cmdutil.remove, and add testing of multi-level subrepo recursion. It
>> looks like subrepo already has a "remove" method, that is used for
>> removing the subrepo, as opposed to removing files. Any suggestions on
>> how to handle that?
>
> Well, you could rename the remove method to something else in a first
> patch. Then add a new remove method that matches the 'hg remove'
> command.
>
> --
> Martin Geisler
>
> aragost Trifork
> Professional Mercurial support
> http://mercurial.aragost.com/kick-start/

Based on further testing, it looks like I introduced a bug with
handling of nested subrepos for "hg forget" in 95174c381525.  I'll be
working on a fix for that before coming back to support for "hg
remove".

-- 
David M. Carr
david at carrclan.us


More information about the Mercurial-devel mailing list