hgkw/pretxnkw.py
branchdecodefilter
changeset 8 180d8484503a
parent 6 3ee39807daa5
child 9 437724c81b8f
equal deleted inserted replaced
6:3ee39807daa5 8:180d8484503a
    13 
    13 
    14     if not ui or not repo or not node or hooktype != 'pretxncommit':
    14     if not ui or not repo or not node or hooktype != 'pretxncommit':
    15         # bail out with error
    15         # bail out with error
    16         return True
    16         return True
    17 
    17 
    18     modified, added = repo.status()[1:3]
    18     modified, added = repo.status()[:2]
    19     candidates = modified + added
    19     candidates = modified + added
    20 
    20 
    21     files = []
    21     files = []
    22     for pat, cmd in repo.ui.configitems('encode'):
    22     for pat, cmd in repo.ui.configitems('encode'):
    23         if cmd.endswith(kwencodefilter):
    23         if cmd.endswith(kwencodefilter):
    53         data, kwct = re_kw.subn(kword, data)
    53         data, kwct = re_kw.subn(kword, data)
    54 
    54 
    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             util.copyfile(filename, filename+'~')
    58             absname = os.path.join(repo.root, filename)
       
    59             util.copyfile(absname, absname+'~')
    59             repo.wopener(filename, 'wb').write(data)
    60             repo.wopener(filename, 'wb').write(data)
    60 
    61 
    61     return False
    62     return False