[PATCH 2 of 3] subrepo: add table-based dispatch for subrepo types

Augie Fackler durin42 at gmail.com
Thu Dec 31 15:53:41 CST 2009


On Dec 31, 2009, at 4:30 PM, Matt Mackall wrote:

> On Thu, 2009-12-31 at 14:36 -0600, durin42 at gmail.com wrote:
>> # HG changeset patch
>> # User Augie Fackler <durin42 at gmail.com>
>> # Date 1262291380 21600
>> # Node ID 4a6db2e12639bf1374a009a9ffaee015befc056c
>> # Parent  68d80c9814d720f2b7d8b2f39008ae6547a5b128
>> subrepo: add table-based dispatch for subrepo types
>>
>> diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
>> --- a/mercurial/subrepo.py
>> +++ b/mercurial/subrepo.py
>> @@ -10,7 +10,7 @@
>> import config, util, node, error
>> hg = None
>>
>> -nullstate = ('', '')
>> +nullstate = ('', '', 'empty')
>>
>> def state(ctx):
>>     p = config.config()
>> @@ -35,7 +35,11 @@
>>
>>     state = {}
>>     for path, src in p[''].items():
>> -        state[path] = (src, rev.get(path, ''))
>> +        kind = 'hg'
>> +        if src.startswith('['):
>> +            kind, src = src.split(']', 1)
>> +            kind = kind[1:]
>
> We can spare ourselves a few bug reports by handling missing close
> braces now.

Ah, right. I assume that's cause for an abort?

>
>> +        state[path] = (src, rev.get(path, ''), kind)
>>
>>     return state
>>
>> @@ -45,6 +49,7 @@
>>                          for s in sorted(state)]), '')
>>
>> def submerge(repo, wctx, mctx, actx):
>> +    # working context, merging context, ancestor context
>>     if mctx == actx: # backwards?
>>         actx = wctx.p1()
>>     s1 = wctx.substate
>> @@ -56,7 +61,7 @@
>>
>>     def debug(s, msg, r=""):
>>         if r:
>> -            r = "%s:%s" % r
>> +            r = "%s:%s" % r[:-1]
>
> What's this for?

state is now a 3-tuple instead of a 2-tuple. I can alter the debug  
message if you'd prefer. I suppose that makes sense now (didn't before).

>
>>         repo.ui.debug("  subrepo %s: %s %s\n" % (s, msg, r))
>>
>>     for s, l in s1.items():
>> @@ -105,7 +110,7 @@
>>             continue
>>         elif s not in sa:
>>             debug(s, "remote added, get", r)
>> -            wctx.sub(s).get(r)
>> +            mctx.sub(s).get(r)
>
> And this? If this is a bugfix, it wants to be in another patch?

I could go either way. It doesn't matter until the types are actually  
dispatched based on path contents. Will fix in next patchbomb to be a  
separate patch.

>
>> +
>> +def getrepoclass(t):
>> +    try:
>> +        return types[t]
>> +    except KeyError:
>> +        raise util.Abort(_('unknown subrepo type %s') % t)
>
> Only one caller of this trivial function?

Vestigial from earlier variation. Will fix shortly.

> Compare this pattern for
> brevity and clarity:
>
> if t not in types:
>    raise ...
> return types[t]
>
> -- 
> http://selenic.com : development and support for Mercurial and Linux
>
>



More information about the Mercurial-devel mailing list