1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 00:17:58 +01:00
Files
pentadactyl-pm/common/contrib/fix_symlinks.py
2010-10-14 04:18:00 -04:00

22 lines
691 B
Python

from mercurial import util
import os
def fix_symlinks(repo, hooktype, parent1, **kwargs):
print map(repr, (repo, hooktype, parent1, kwargs))
revert = hooktype in ('precommit', 'preupdate')
ctxt = repo[parent1]
for filename in ctxt:
file = ctxt[filename]
if 'l' in file.flags():
path = repo.wjoin(file.path())
try:
os.unlink(path)
except Exception, e:
print repr(e)
if revert:
repo.wwrite(file.path(), file.data(), '')
else:
target = os.path.join(os.path.dirname(path), file.data())
util.copyfiles(target, path, True)