[PATCH RFC] clone: copy hgrc paths if source and dest are local

Peter Arrenbrecht peter.arrenbrecht at gmail.com
Mon Jun 14 01:48:33 CDT 2010


On Sun, Jun 13, 2010 at 8:13 PM, Adrian Buehlmann <adrian at cadifra.com> wrote:
> On 13.06.2010 16:35, Bill Barry wrote:
>> Adrian Buehlmann wrote:
>>> On 13.06.2010 15:32, Adrian Buehlmann wrote:
>>>
>>>> On 13.06.2010 15:28, Adrian Buehlmann wrote:
>>>>
>>>>> # HG changeset patch
>>>>> # User Adrian Buehlmann <adrian at cadifra.com>
>>>>> # Date 1276435473 -7200
>>>>> # Node ID 237a4167922c61f1ac6ad68e6fcf62a3f15c446f
>>>>> # Parent  285bcf40e04bf8ec0980d3238a4d71e886054ed9
>>>>> clone: copy hgrc paths if source and dest are local
>>>>>
>>>>> diff --git a/mercurial/hg.py b/mercurial/hg.py
>>>>> --- a/mercurial/hg.py
>>>>> +++ b/mercurial/hg.py
>>>>> @@ -344,6 +344,10 @@ def clone(ui, source, dest=None, pull=Fa
>>>>>              fp = dest_repo.opener("hgrc", "w", text=True)
>>>>>              fp.write("[paths]\n")
>>>>>              fp.write("default = %s\n" % abspath)
>>>>> +            if src_repo.local():
>>>>> +                for n, p in src_repo.ui.configitems('paths'):
>>>>> +                    if n != 'default':
>>>>> +                        fp.write("%s = %s\n" % (n, p))
>>>>>              fp.close()
>>>>>
>>>>>              dest_repo.ui.setconfig('paths', 'default', abspath)
>>>>>
>>>> Would this make sense?
>>>>
>>>>
>>>
>>> No it doesn't, as it sets repo-local identical overrides for global
>>> config paths in the local .hg/hgrc of the destination repo, which is
>>> unwanted.
>>
>> +1
>>
>> If you want global paths, simply set them up globally. My local paths
>> are usually localized from one repo to another.
>
> It's not possible to setup subgroups of global paths though.
>
> For example, when doing a GUI (TortoiseHg in my case), we show a list of
> all paths available (repo.ui.configitems('paths')) for a repo, which
> then includes all global paths (let's assume there is one global
> 'mercurial.ini' or 'hgrc' for the user with those global paths).
>
> But I as a user have repositories that are grouped into related
> repositories, e.g. group A is "all mercurial clones", group B is "all
> TortoiseHg clones", etc.
>
> If I am inside a mercurial clone (opened in my GUI), I don't want to
> have the TortoiseHg paths in scope, i.e. the UI shouldn't show me the
> TortoiseHg paths if I open the list of defined paths.

Just an idea: We add a [groups] setting to .hg/hgrc, and this causes
hg to also read ~/.hgrc.x for every x in [groups], containing
per-group overrides for ~/.hgrc. Then we make local clones copy the
[groups] setting. This might also be a solution for what I once
attempted to solve by having hg go back the parent dir hierarchy
looking for .hgrc.defaults files. Or we use a single group=x setting
to keep this simpler and use include files in ~/.hgrc.x instead if we
need composable aspects in .hgrc.
-parren


More information about the Mercurial-devel mailing list