+++ /dev/null
-<?php
-
-
-class MTrack_SCM_Svn_CommitHookBridge extends IMTrackCommitHookBridge
-{
- var $repo;
- var $svnlook;
- var $svnrepo;
- var $svntxn;
-
- function __construct($repo, $svnrepo, $svntxn)
- {
- $this->repo = $repo;
- $this->svnlook = MTrackConfig::get('tools', 'svnlook');
- $this->svnrepo = $svnrepo;
- $this->svntxn = explode(' ', $svntxn,2);
- }
-
- function enumChangedOrModifiedFileNames()
- {
- $files = array();
- $fp = $this->run($this->svnlook, 'changed', $this->svntxn, $this->svnrepo);
- while (($line = fgets($fp)) !== false) {
- if (preg_match("/^(\w)\s+(.*)$/", trim($line), $M)) {
- $action = $M[1];
- $path = $M[2];
- if ($action == 'A' || $action == 'U' || $action == 'UU') {
- $files[] = $path;
- }
- }
- }
- return $files;
- }
-
- function getCommitMessage()
- {
- $fp = $this->run($this->svnlook, 'log', $this->svntxn, $this->svnrepo);
-
- $log = stream_get_contents($fp);
- $log = preg_replace('/\[(\d+)\]/',
- "[changeset:" . $this->repo->getBrowseRootName() . ",\$1]", $log);
- return $log;
- }
-
- function getDiffStream($path)
- {
- return $this->run($this->svnlook, 'diff', $this->svntxn, $this->svnrepo, $path);
- }
-
- function getFileStream($path)
- {
- return $this->run($this->svnlook, 'cat', $this->svntxn, $this->svnrepo, $path);
- }
-
- function getChangesetDescriptor()
- {
- $rev = $this->svntxn[1];
- return '[changeset:' . $this->repo->getBrowseRootName() . ",$rev]";
- }
-}