mercurial/subrepoutil.py
changeset 49306 2e726c934fcd
parent 48913 f254fc73d956
child 50604 b539c60a79ac
equal deleted inserted replaced
49305:53e9422a9b45 49306:2e726c934fcd
     4 #
     4 #
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 
     8 
     9 import errno
       
    10 import os
     9 import os
    11 import posixpath
    10 import posixpath
    12 import re
    11 import re
    13 
    12 
    14 from .i18n import _
    13 from .i18n import _
    61 
    60 
    62     def read(f, sections=None, remap=None):
    61     def read(f, sections=None, remap=None):
    63         if f in ctx:
    62         if f in ctx:
    64             try:
    63             try:
    65                 data = ctx[f].data()
    64                 data = ctx[f].data()
    66             except IOError as err:
    65             except FileNotFoundError:
    67                 if err.errno != errno.ENOENT:
       
    68                     raise
       
    69                 # handle missing subrepo spec files as removed
    66                 # handle missing subrepo spec files as removed
    70                 ui.warn(
    67                 ui.warn(
    71                     _(b"warning: subrepo spec file \'%s\' not found\n")
    68                     _(b"warning: subrepo spec file \'%s\' not found\n")
    72                     % repo.pathto(f)
    69                     % repo.pathto(f)
    73                 )
    70                 )
   100                             b"specifier in \'%s\' line %d"
    97                             b"specifier in \'%s\' line %d"
   101                         )
    98                         )
   102                         % (repo.pathto(b'.hgsubstate'), (i + 1))
    99                         % (repo.pathto(b'.hgsubstate'), (i + 1))
   103                     )
   100                     )
   104                 rev[path] = revision
   101                 rev[path] = revision
   105         except IOError as err:
   102         except FileNotFoundError:
   106             if err.errno != errno.ENOENT:
   103             pass
   107                 raise
       
   108 
   104 
   109     def remap(src):
   105     def remap(src):
   110         # type: (bytes) -> bytes
   106         # type: (bytes) -> bytes
   111         for pattern, repl in p.items(b'subpaths'):
   107         for pattern, repl in p.items(b'subpaths'):
   112             # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub
   108             # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub