hgext/convert/filemap.py
changeset 45942 89a2afe31e82
parent 43105 649d3ac37a12
child 48875 6000f5b25c9b
equal deleted inserted replaced
45941:346af7687c6f 45942:89a2afe31e82
    17 
    17 
    18 SKIPREV = common.SKIPREV
    18 SKIPREV = common.SKIPREV
    19 
    19 
    20 
    20 
    21 def rpairs(path):
    21 def rpairs(path):
    22     '''Yield tuples with path split at '/', starting with the full path.
    22     """Yield tuples with path split at '/', starting with the full path.
    23     No leading, trailing or double '/', please.
    23     No leading, trailing or double '/', please.
    24     >>> for x in rpairs(b'foo/bar/baz'): print(x)
    24     >>> for x in rpairs(b'foo/bar/baz'): print(x)
    25     ('foo/bar/baz', '')
    25     ('foo/bar/baz', '')
    26     ('foo/bar', 'baz')
    26     ('foo/bar', 'baz')
    27     ('foo', 'bar/baz')
    27     ('foo', 'bar/baz')
    28     ('.', 'foo/bar/baz')
    28     ('.', 'foo/bar/baz')
    29     '''
    29     """
    30     i = len(path)
    30     i = len(path)
    31     while i != -1:
    31     while i != -1:
    32         yield path[:i], path[i + 1 :]
    32         yield path[:i], path[i + 1 :]
    33         i = path.rfind(b'/', 0, i)
    33         i = path.rfind(b'/', 0, i)
    34     yield b'.', path
    34     yield b'.', path
    35 
    35 
    36 
    36 
    37 def normalize(path):
    37 def normalize(path):
    38     ''' We use posixpath.normpath to support cross-platform path format.
    38     """We use posixpath.normpath to support cross-platform path format.
    39     However, it doesn't handle None input. So we wrap it up. '''
    39     However, it doesn't handle None input. So we wrap it up."""
    40     if path is None:
    40     if path is None:
    41         return None
    41         return None
    42     return posixpath.normpath(path)
    42     return posixpath.normpath(path)
    43 
    43 
    44 
    44 
    45 class filemapper(object):
    45 class filemapper(object):
    46     '''Map and filter filenames when importing.
    46     """Map and filter filenames when importing.
    47     A name can be mapped to itself, a new name, or None (omit from new
    47     A name can be mapped to itself, a new name, or None (omit from new
    48     repository).'''
    48     repository)."""
    49 
    49 
    50     def __init__(self, ui, path=None):
    50     def __init__(self, ui, path=None):
    51         self.ui = ui
    51         self.ui = ui
    52         self.include = {}
    52         self.include = {}
    53         self.exclude = {}
    53         self.exclude = {}