Changeset 3425
- Timestamp:
- 03/30/08 22:17:54 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tracforgeplugin/0.11/tracforge/admin/prototypes_admin.py
r3406 r3425 116 116 proto.append((req.args['type'], '')) 117 117 elif 'save' in req.args: 118 proto.tag = data['name'] 118 119 proto.save() 119 120 req.redirect(req.href.admin('tracforge/prototypes', proto.tag)) tracforgeplugin/0.11/tracforge/admin/prototypes.py
r3424 r3425 5 5 import os.path 6 6 import time 7 import stat 7 8 8 9 from trac.core import * … … 12 13 from tracforge.admin.api import IProjectSetupParticipant 13 14 from tracforge.admin.util import CommandLine, locate 14 15 # Try and use ctypes to get fchmod16 try:17 import ctypes18 import ctypes.util19 have_ctypes = True20 21 libc = ctypes.CDLL(ctypes.util.find_library('c'))22 except ImportError:23 have_ctypes = False24 15 25 16 class ProjectSetupParticipantBase(Component): … … 150 141 151 142 Valid arguments are `pre`, `post`, or `both`. 152 153 '''NOTE''': You cannot automatically activate the pre-commit hook on154 Windows at this time.155 143 """ 156 144 157 depends = ['repo_type', 'repo_dir' ]145 depends = ['repo_type', 'repo_dir', 'env'] 158 146 159 147 arg_map = { … … 173 161 def execute_setup_action(self, action, args, data, log_cb): 174 162 if data['repo_type'] == 'svn': 175 pre, post = dict(reversed(self.arg_map.itertitems())).get(args, (False, False)) 176 if pre 163 pre, post = dict([(v,k) for k, v in self.arg_map.iteritems()]).get(args, (False, False)) 164 if pre: 165 hookf, trachook = self._install_hook(data['repo_dir'], 'pre-commit') 166 svnlook = locate('svnlook') 167 if os.name == 'nt': 168 hookf.write('%s log -t %%2 %%1 > C:\\temp\\svnlog-%%2\n'%svnlook) 169 hookf.write('%s %s %s file:"C:\\temp\\svnlook-%%2\n"'% 170 (sys.executable, trachook, data['env'].path)) 171 hookf.write('IF ERRORLEVEL 1 SET TRAC_CANCEL=YES\n') 172 hookf.write('DEL /F C:\\temp\\svnlog-%2\n') 173 hookf.write('IF DEFINED TRAC_CANCEL EXIT 1\n') 174 else: 175 hookf.write('%s %s %s "${%s log -t "$2" "$1"}"\n'% 176 (sys.executable, trachook, data['env'].path, svnlook)) 177 if post: 178 hookf, trachook = self._install_hook(data['repo_dir'], 'post-commit') 179 revarg = os.name == 'nt' and '%2' or '$2' 180 hookf.write('%s %s -p "%s" -r "%s"\n'% 181 (sys.executable, trachook, data['env'].path, revarg)) 182 return True 177 183 178 184 # Internal methods … … 197 203 # Open source and sink for the trac hook 198 204 script = resource_stream(__name__, 'scripts/trac-'+hook+'-hook') 199 trachook_file = os.path.join(path, 'hooks', 'trac-'+hook+'-hook') 205 trachook_file = os.path.join(path, 'hooks', 'trac-'+hook+'-hook') 206 print 'Installing script file to %s'%trachook_file 200 207 out = open(trachook_file, 'w') 201 208 # Copy over the given trac hook … … 213 220 hook_file += '.bat' 214 221 hookf = open(hook_file, 'a') 215 hookf.write('%s %s -') 222 if os.name != 'nt' and not os.access(hook_file, os.X_OK): 223 print 'Making %s executable'%hook_file 224 os.chmod(hook_file, os.stat(hook_file).st_mode|stat.S_IXUSR) 225 return hookf, trachook_file
