| | 92 | sys_hook_paths = ['/etc/subversion/hooks', '/opt/svn/hooks', ] |
| | 93 | for p in sys_hook_paths: |
| | 94 | if os.path.exists(os.path.join(p, "parse_ini.sh")): |
| | 95 | return self.hooks_init_symlink(p, repos_name) |
| | 96 | return self.hooks_init_copy(repos_name) |
| | 97 | |
| | 98 | def hooks_init_symlink(self, hooks_dir, repos_name): |
| | 99 | if not os.path.exists(os.path.join(hooks_dir, "parse_ini.sh")): |
| | 100 | raise Exception("\"%s\" is not a valid hooks location." % hooks_dir) |
| | 101 | dest = "%(root)s/%(entry)s/hooks" % { "root": self.repos_root, "entry": repos_name} |
| | 102 | dest = os.path.abspath(dest) |
| | 103 | |
| | 104 | import shutil |
| | 105 | if os.path.exists(dest): |
| | 106 | assert os.path.basename(dest) == 'hooks' |
| | 107 | shutil.rmtree(dest) |
| | 108 | elif not os.path.exists(os.path.dirname(dest)): |
| | 109 | raise Exception("Destination repository '%s' not exist!" % os.path.dirname(dest)) |
| | 110 | os.symlink(hooks_dir, dest) |
| | 111 | |
| | 112 | def hooks_init_copy(self, repos_name): |