##// 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 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 501 def svn_pre_commit(repo_path, commit_data, env):
487 502 path, txn_id = commit_data
488 503 branches = []
489 504 tags = []
490 505
491 cmd = ['svnlook', 'pget',
492 '-t', txn_id,
493 '--revprop', path, 'rc-scm-extras']
494 stdout, stderr = subprocessio.run_command(
495 cmd, env=os.environ.copy())
496 extras = json.loads(base64.urlsafe_b64decode(stdout))
506 if env.get('RC_SCM_DATA'):
507 extras = json.loads(env['RC_SCM_DATA'])
508 else:
509 # fallback method to read from TXN-ID stored data
510 extras = _get_extras_from_txn_id(path, txn_id)
511 if not extras:
512 return 0
497 513
498 514 extras['commit_ids'] = []
499 515 extras['txn_id'] = txn_id
@@ -502,10 +518,25 b' def svn_pre_commit(repo_path, commit_dat'
502 518 'bookmarks': [],
503 519 'tags': tags,
504 520 }
505 sys.stderr.write(str(extras))
521
506 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 540 def svn_post_commit(repo_path, commit_data, env):
510 541 """
511 542 commit_data is path, rev, txn_id
@@ -514,13 +545,13 b' def svn_post_commit(repo_path, commit_da'
514 545 branches = []
515 546 tags = []
516 547
517 cmd = ['svnlook', 'pget',
518 '-r', commit_id,
519 '--revprop', path, 'rc-scm-extras']
520 stdout, stderr = subprocessio.run_command(
521 cmd, env=os.environ.copy())
522
523 extras = json.loads(base64.urlsafe_b64decode(stdout))
548 if env.get('RC_SCM_DATA'):
549 extras = json.loads(env['RC_SCM_DATA'])
550 else:
551 # fallback method to read from TXN-ID stored data
552 extras = _get_extras_from_commit_id(commit_id, path)
553 if not extras:
554 return 0
524 555
525 556 extras['commit_ids'] = [commit_id]
526 557 extras['txn_id'] = txn_id
@@ -533,9 +564,7 b' def svn_post_commit(repo_path, commit_da'
533 564 if 'repo_size' in extras['hooks']:
534 565 try:
535 566 _call_hook('repo_size', extras, SvnMessageWriter())
536 except:
567 except Exception:
537 568 pass
538 569
539 570 return _call_hook('post_push', extras, SvnMessageWriter())
540
541
General Comments 0
You need to be logged in to leave comments. Login now