mercurial/subrepo.py
changeset 11775 a8614c5a5e9a
parent 11572 324bad1dc230
child 11961 f3075ffa6b30
equal deleted inserted replaced
11774:91c4e6d2c9e5 11775:a8614c5a5e9a
    10 import config, util, node, error
    10 import config, util, node, error
    11 hg = None
    11 hg = None
    12 
    12 
    13 nullstate = ('', '', 'empty')
    13 nullstate = ('', '', 'empty')
    14 
    14 
    15 def state(ctx):
    15 def state(ctx, ui):
    16     """return a state dict, mapping subrepo paths configured in .hgsub
    16     """return a state dict, mapping subrepo paths configured in .hgsub
    17     to tuple: (source from .hgsub, revision from .hgsubstate, kind
    17     to tuple: (source from .hgsub, revision from .hgsubstate, kind
    18     (key in types dict))
    18     (key in types dict))
    19     """
    19     """
    20     p = config.config()
    20     p = config.config()
    25             raise util.Abort(_("subrepo spec file %s not found") % f)
    25             raise util.Abort(_("subrepo spec file %s not found") % f)
    26 
    26 
    27     if '.hgsub' in ctx:
    27     if '.hgsub' in ctx:
    28         read('.hgsub')
    28         read('.hgsub')
    29 
    29 
       
    30     for path, src in ui.configitems('subpaths'):
       
    31         p.set('subpaths', path, src, ui.configsource('subpaths', path))
       
    32 
    30     rev = {}
    33     rev = {}
    31     if '.hgsubstate' in ctx:
    34     if '.hgsubstate' in ctx:
    32         try:
    35         try:
    33             for l in ctx['.hgsubstate'].data().splitlines():
    36             for l in ctx['.hgsubstate'].data().splitlines():
    34                 revision, path = l.split(" ", 1)
    37                 revision, path = l.split(" ", 1)
    43         if src.startswith('['):
    46         if src.startswith('['):
    44             if ']' not in src:
    47             if ']' not in src:
    45                 raise util.Abort(_('missing ] in subrepo source'))
    48                 raise util.Abort(_('missing ] in subrepo source'))
    46             kind, src = src.split(']', 1)
    49             kind, src = src.split(']', 1)
    47             kind = kind[1:]
    50             kind = kind[1:]
       
    51 
       
    52         for pattern, repl in p.items('subpaths'):
       
    53             try:
       
    54                 src = re.sub(pattern, repl, src, 1)
       
    55             except re.error, e:
       
    56                 raise util.Abort(_("bad subrepository pattern in %s: %s")
       
    57                                  % (p.source('subpaths', pattern), e))
       
    58 
    48         state[path] = (src.strip(), rev.get(path, ''), kind)
    59         state[path] = (src.strip(), rev.get(path, ''), kind)
    49 
    60 
    50     return state
    61     return state
    51 
    62 
    52 def writestate(repo, state):
    63 def writestate(repo, state):