mercurial/subrepo.py
changeset 25768 7a9ef8608a1d
parent 25660 328739ea70c3
child 25769 2538b87660be
equal deleted inserted replaced
25767:026105c442d7 25768:7a9ef8608a1d
    60     """return a state dict, mapping subrepo paths configured in .hgsub
    60     """return a state dict, mapping subrepo paths configured in .hgsub
    61     to tuple: (source from .hgsub, revision from .hgsubstate, kind
    61     to tuple: (source from .hgsub, revision from .hgsubstate, kind
    62     (key in types dict))
    62     (key in types dict))
    63     """
    63     """
    64     p = config.config()
    64     p = config.config()
       
    65     repo = ctx.repo()
    65     def read(f, sections=None, remap=None):
    66     def read(f, sections=None, remap=None):
    66         if f in ctx:
    67         if f in ctx:
    67             try:
    68             try:
    68                 data = ctx[f].data()
    69                 data = ctx[f].data()
    69             except IOError as err:
    70             except IOError as err:
    70                 if err.errno != errno.ENOENT:
    71                 if err.errno != errno.ENOENT:
    71                     raise
    72                     raise
    72                 # handle missing subrepo spec files as removed
    73                 # handle missing subrepo spec files as removed
    73                 ui.warn(_("warning: subrepo spec file \'%s\' not found\n") %
    74                 ui.warn(_("warning: subrepo spec file \'%s\' not found\n") %
    74                         util.pathto(ctx.repo().root, ctx.repo().getcwd(), f))
    75                         util.pathto(repo.root, repo.getcwd(), f))
    75                 return
    76                 return
    76             p.parse(f, data, sections, remap, read)
    77             p.parse(f, data, sections, remap, read)
    77         else:
    78         else:
    78             repo = ctx.repo()
       
    79             raise util.Abort(_("subrepo spec file \'%s\' not found") %
    79             raise util.Abort(_("subrepo spec file \'%s\' not found") %
    80                              util.pathto(repo.root, repo.getcwd(), f))
    80                              util.pathto(repo.root, repo.getcwd(), f))
    81 
    81 
    82     if '.hgsub' in ctx:
    82     if '.hgsub' in ctx:
    83         read('.hgsub')
    83         read('.hgsub')
    93                 if not l:
    93                 if not l:
    94                     continue
    94                     continue
    95                 try:
    95                 try:
    96                     revision, path = l.split(" ", 1)
    96                     revision, path = l.split(" ", 1)
    97                 except ValueError:
    97                 except ValueError:
    98                     repo = ctx.repo()
       
    99                     raise util.Abort(_("invalid subrepository revision "
    98                     raise util.Abort(_("invalid subrepository revision "
   100                                        "specifier in \'%s\' line %d")
    99                                        "specifier in \'%s\' line %d")
   101                                      % (util.pathto(repo.root, repo.getcwd(),
   100                                      % (util.pathto(repo.root, repo.getcwd(),
   102                                         '.hgsubstate'), (i + 1)))
   101                                         '.hgsubstate'), (i + 1)))
   103                 rev[path] = revision
   102                 rev[path] = revision
   130             kind, src = src.split(']', 1)
   129             kind, src = src.split(']', 1)
   131             kind = kind[1:]
   130             kind = kind[1:]
   132             src = src.lstrip() # strip any extra whitespace after ']'
   131             src = src.lstrip() # strip any extra whitespace after ']'
   133 
   132 
   134         if not util.url(src).isabs():
   133         if not util.url(src).isabs():
   135             parent = _abssource(ctx.repo(), abort=False)
   134             parent = _abssource(repo, abort=False)
   136             if parent:
   135             if parent:
   137                 parent = util.url(parent)
   136                 parent = util.url(parent)
   138                 parent.path = posixpath.join(parent.path or '', src)
   137                 parent.path = posixpath.join(parent.path or '', src)
   139                 parent.path = posixpath.normpath(parent.path)
   138                 parent.path = posixpath.normpath(parent.path)
   140                 joined = str(parent)
   139                 joined = str(parent)