##// END OF EJS Templates
svn: make hooks safe and fully backward compatible....
marcink -
r436:74eb96f2 stable
parent child Browse files
Show More
@@ -483,17 +483,33 b' def git_post_receive(unused_repo_path, r'
483 return _call_hook('post_push', extras, GitMessageWriter())
483 return _call_hook('post_push', extras, GitMessageWriter())
484
484
485
485
486 def _get_extras_from_txn_id(path, txn_id):
487 extras = {}
488 try:
489 cmd = ['svnlook', 'pget',
490 '-t', txn_id,
491 '--revprop', path, 'rc-scm-extras']
492 stdout, stderr = subprocessio.run_command(
493 cmd, env=os.environ.copy())
494 extras = json.loads(base64.urlsafe_b64decode(stdout))
495 except Exception:
496 log.exception('Failed to extract extras info from txn_id')
497
498 return extras
499
500
486 def svn_pre_commit(repo_path, commit_data, env):
501 def svn_pre_commit(repo_path, commit_data, env):
487 path, txn_id = commit_data
502 path, txn_id = commit_data
488 branches = []
503 branches = []
489 tags = []
504 tags = []
490
505
491 cmd = ['svnlook', 'pget',
506 if env.get('RC_SCM_DATA'):
492 '-t', txn_id,
507 extras = json.loads(env['RC_SCM_DATA'])
493 '--revprop', path, 'rc-scm-extras']
508 else:
494 stdout, stderr = subprocessio.run_command(
509 # fallback method to read from TXN-ID stored data
495 cmd, env=os.environ.copy())
510 extras = _get_extras_from_txn_id(path, txn_id)
496 extras = json.loads(base64.urlsafe_b64decode(stdout))
511 if not extras:
512 return 0
497
513
498 extras['commit_ids'] = []
514 extras['commit_ids'] = []
499 extras['txn_id'] = txn_id
515 extras['txn_id'] = txn_id
@@ -502,10 +518,25 b' def svn_pre_commit(repo_path, commit_dat'
502 'bookmarks': [],
518 'bookmarks': [],
503 'tags': tags,
519 'tags': tags,
504 }
520 }
505 sys.stderr.write(str(extras))
521
506 return _call_hook('pre_push', extras, SvnMessageWriter())
522 return _call_hook('pre_push', extras, SvnMessageWriter())
507
523
508
524
525 def _get_extras_from_commit_id(commit_id, path):
526 extras = {}
527 try:
528 cmd = ['svnlook', 'pget',
529 '-r', commit_id,
530 '--revprop', path, 'rc-scm-extras']
531 stdout, stderr = subprocessio.run_command(
532 cmd, env=os.environ.copy())
533 extras = json.loads(base64.urlsafe_b64decode(stdout))
534 except Exception:
535 log.exception('Failed to extract extras info from commit_id')
536
537 return extras
538
539
509 def svn_post_commit(repo_path, commit_data, env):
540 def svn_post_commit(repo_path, commit_data, env):
510 """
541 """
511 commit_data is path, rev, txn_id
542 commit_data is path, rev, txn_id
@@ -514,13 +545,13 b' def svn_post_commit(repo_path, commit_da'
514 branches = []
545 branches = []
515 tags = []
546 tags = []
516
547
517 cmd = ['svnlook', 'pget',
548 if env.get('RC_SCM_DATA'):
518 '-r', commit_id,
549 extras = json.loads(env['RC_SCM_DATA'])
519 '--revprop', path, 'rc-scm-extras']
550 else:
520 stdout, stderr = subprocessio.run_command(
551 # fallback method to read from TXN-ID stored data
521 cmd, env=os.environ.copy())
552 extras = _get_extras_from_commit_id(commit_id, path)
522
553 if not extras:
523 extras = json.loads(base64.urlsafe_b64decode(stdout))
554 return 0
524
555
525 extras['commit_ids'] = [commit_id]
556 extras['commit_ids'] = [commit_id]
526 extras['txn_id'] = txn_id
557 extras['txn_id'] = txn_id
@@ -533,9 +564,7 b' def svn_post_commit(repo_path, commit_da'
533 if 'repo_size' in extras['hooks']:
564 if 'repo_size' in extras['hooks']:
534 try:
565 try:
535 _call_hook('repo_size', extras, SvnMessageWriter())
566 _call_hook('repo_size', extras, SvnMessageWriter())
536 except:
567 except Exception:
537 pass
568 pass
538
569
539 return _call_hook('post_push', extras, SvnMessageWriter())
570 return _call_hook('post_push', extras, SvnMessageWriter())
540
541
General Comments 0
You need to be logged in to leave comments. Login now