2 require_once 'MTrack/SCM.php';
3 require_once 'MTrack/DB.php';
4 require_once 'MTrack/Config.php';
5 require_once 'MTrack/Project.php';
6 require_once 'MTrack/SCMFileEvent.php';
7 //require_once 'MTrack/Changeset.php';
8 //require_once 'MTrack/Wiki.php';
11 class MTrack_Repo extends MTrackSCM
14 public $shortname = null;
15 public $scmtype = null;
16 public $repopath = null;
17 public $browserurl = null;
18 public $browsertype = null;
19 public $description = null;
21 public $clonedfrom = null;
22 public $serverurl = null;
25 private $links_to_add = array();
26 private $links_to_remove = array();
27 private $links = null;
28 static $scms = array();
30 *load class and create instance using array as properties
33 static function factory($ar)
36 $type = ucfirst($ar['scmtype']);
37 $fn = 'MTrack/SCM/'.$type .'/Repo.php';
38 $cls = 'MTrack_SCM_'.$type .'_Repo';
48 static function getAvailableSCMs()
51 $ar = scandir(dirname(__FILE__).'/SCM');
54 if (empty($a) || $a[0] == '.') {
57 $fn = dirname(__FILE__).'/SCM/'.$a.'/Repo.php';
58 if (!file_exists($fn)) {
61 $ret[$a] = MTrack_Repo::factory(array('scmtype'=> $a));
67 function __construct($ar = null) {
70 return; // can accept empty ctrs
72 foreach($ar as $k=>$v) {
78 function reconcileRepoSettings()
80 $c = self::Factory(array('scmtype'=>$this->scmtype));
81 $s->reconcileRepoSettings($this);
84 function getServerURL()
86 if ($this->serverurl) {
87 return $this->serverurl;
90 $url = MTrackConfig::get('repos', "$this->scmtype.serverurl");
92 return $url . $this->getBrowseRootName();
98 function getCheckoutCommand() {
99 $url = $this->getServerURL();
101 return $this->scmtype . ' clone ' . $this->getServerURL();
110 function getWorkingCopy() {
111 throw new Exception("cannot getWorkingCopy from a generic repo object");
114 function deleteRepo(MTrackChangeset $CS) {
115 MTrackDB::q('delete from repos where repoid = ?', $this->repoid);
116 mtrack_rmdir($this->repopath);
121 * i could not find where this is used..
124 if ($this->links === null) {
125 $this->links = array();
126 foreach (MTrackDB::q('select linkid, projid, repopathregex
127 from project_repo_link where repoid = ? order by repopathregex',
128 $this->repoid)->fetchAll() as $row) {
129 $this->links[$row[0]] = array($row[1], $row[2]);
135 function addLink($proj, $regex)
137 if ($proj instanceof MTrackProject) {
138 $this->links_to_add[] = array($proj->projid, $regex);
140 $this->links_to_add[] = array($proj, $regex);
144 function removeLink($linkid)
146 $this->links_to_remove[$linkid] = $linkid;
150 // these are needed just to implement the abstract interface..
151 function getBranches() {}
152 function getTags() {}
153 function readdir($path, $object = null, $ident = null) {}
154 function file($path, $object = null, $ident = null) {}
155 function history($path, $limit = null, $object = null, $ident = null){}
156 function diff($path, $from = null, $to = null) {}
157 function getRelatedChanges($revision) {}
158 function getSCMMetaData() { return null; }
160 * converts a commit log message (cached locally into a working object..)
163 function commitLogToEvent($str) {
164 throw new Exception("no implementation for commitLogToEvent");