]> git.donarmstrong.com Git - dactyl.git/blob - common/contrib/fix_symlinks.py
Initial import of 1.0~b6
[dactyl.git] / common / contrib / fix_symlinks.py
1 from mercurial import util
2 import os
3
4 def fix_symlinks(ui, repo, hooktype, parent1, **kwargs):
5     revert = hooktype in ('precommit', 'preupdate')
6     ctxt = repo[parent1]
7     for filename in ctxt:
8         file = ctxt[filename]
9         if 'l' in file.flags():
10             path = repo.wjoin(file.path())
11             try:
12                 os.unlink(path)
13             except Exception, e:
14                 print repr(e)
15             if revert:
16                 repo.wwrite(file.path(), file.data(), '')
17             else:
18                 target = os.path.join(os.path.dirname(path), file.data())
19                 util.copyfiles(target, path, True)
20