hgkw/pretxnkw.py
branchdecodefilter
changeset 9 437724c81b8f
parent 8 180d8484503a
child 10 d8cd07b798f2
equal deleted inserted replaced
8:180d8484503a 9:437724c81b8f
    34 
    34 
    35     re_kwcheck = re.compile(r'[$]Hg: (.*?),v.*?\$')
    35     re_kwcheck = re.compile(r'[$]Hg: (.*?),v.*?\$')
    36 
    36 
    37     for filename in files:
    37     for filename in files:
    38 
    38 
    39         data = repo.wopener(filename, 'rb').read()
    39         data = repo.wfile(filename).read()
    40         bn = os.path.basename(filename)
    40         bn = os.path.basename(filename)
    41 
    41 
    42         # check for keywords with incorrect basename
    42         # check for keywords with incorrect basename
    43         # eg. if you forgot to update basename manually after "hg mv"
    43         # eg. if you forgot to update basename manually after "hg mv"
    44         failures = [m for m in map(str, re_kwcheck.findall(data)) if m != bn]
    44         failures = [m for m in map(str, re_kwcheck.findall(data)) if m != bn]
    55         if kwct:
    55         if kwct:
    56             # backup file and write with expanded keyword
    56             # backup file and write with expanded keyword
    57             ui.note(_('expanding keywords in %s\n' % filename))
    57             ui.note(_('expanding keywords in %s\n' % filename))
    58             absname = os.path.join(repo.root, filename)
    58             absname = os.path.join(repo.root, filename)
    59             util.copyfile(absname, absname+'~')
    59             util.copyfile(absname, absname+'~')
    60             repo.wopener(filename, 'wb').write(data)
    60             repo.wfile(filename, 'w').write(data)
    61 
    61 
    62     return False
    62     return False