php8
[web.mtrack] / MTrack / Repo.php
index d1a2964..c11b402 100644 (file)
@@ -4,14 +4,13 @@ require_once 'MTrack/DB.php';
 require_once 'MTrack/Config.php';
 require_once 'MTrack/Project.php';
 require_once 'MTrack/SCMFileEvent.php';
-require_once 'MTrack/ACL.php';
-//require_once 'MTrack/Changeset.php';
-require_once 'MTrack/Wiki.php';
+ //require_once 'MTrack/Changeset.php';
+//require_once 'MTrack/Wiki.php';
 
 
 class MTrack_Repo extends MTrackSCM 
 {
-    public $repoid = null;
+    public $id = null;
     public $shortname = null;
     public $scmtype = null;
     public $repopath = null;
@@ -33,7 +32,7 @@ class MTrack_Repo extends MTrackSCM
     
     static function factory($ar)
     {
-        print_r($ar);
+        //print_r($ar);
         $type = ucfirst($ar['scmtype']);
         $fn = 'MTrack/SCM/'.$type .'/Repo.php';
         $cls = 'MTrack_SCM_'.$type .'_Repo';
@@ -64,108 +63,7 @@ class MTrack_Repo extends MTrackSCM
         }
         return $ret;
     }  
-    
-    
-    /*static function loadById($id) {
-        list($row) = MTrackDB::q(
-          'select repoid, scmtype from repos where repoid = ?',
-          $id)->fetchAll();
-        if (isset($row[0])) {
-          $type = $row[1];
-          if (isset(self::$scms[$type])) {
-            $class = self::$scms[$type];
-            return new $class($row[0]);
-          }
-          throw new Exception("unsupported repo type $type");
-        }
-        return null;
-    }
-    static function loadByName($name) {
-        $bits = explode('/', $name);
-        if (count($bits) > 1 && $bits[0] == 'default') {
-          array_shift($bits);
-          $name = $bits[0];
-        }
-        if (count($bits) > 1) {
-          // wez/reponame -> per user repo 
-          $u = "user:$bits[0]";
-          $p = "project:$bits[0]";
-          $rows = MTrackDB::q(
-            'select repoid, scmtype from repos where shortname = ? and (parent = ? OR parent = ?)',
-            $bits[1], $u, $p)->fetchAll();
-        } else {
-          $rows = MTrackDB::q(
-            "select repoid, scmtype from repos where shortname = ? and parent =''",
-            $name)->fetchAll();
-        }
-        if (is_array($rows) && isset($rows[0])) {
-          $row = $rows[0];
-          if (isset($row[0])) {
-            $type = $row[1];
-            if (isset(self::$scms[$type])) {
-              $class = self::$scms[$type];
-              return new $class($row[0]);
-            }
-            throw new Exception("unsupported repo type $type");
-          }
-        }
-        return null;
-    }
-    static function loadByLocation($path) 
-    {
-          
-        // we have magic configuration - end users commit into SVN
-        // backend is really git... - so pre-commit hooks have to be from svn
-        list($row) = MTrackDB::q('select repoid, scmtype from repos where repopath = ?', $path)->fetchAll();
-        if (isset($row[0])) {
-          $type = $row[1];
-          if (isset(self::$scms[$type])) {
-            $class = self::$scms[$type];
-            return new $class($row[0]);
-          }
-          throw new Exception("unsupported repo type $type");
-        }
-        return null;
-      }
-  
-    static function loadByChangeSet($cs)
-    {
-        
-        static $re = array();
-        if (isset($re[$cs])) {
-            return $re[$cs];
-        }
-        //using (repoid)  ??
-        $q = MTrackDB::q("
-            select 
-                r.shortname as repo, 
-                p.shortname as proj 
-            from 
-                repos r 
-            left join 
-                project_repo_link l on r.repoid = l.repoid
-            left join 
-                projects p on p.projid = r.projectid
-            where 
-                (parent is null  or length(parent) = 0)
-            AND
-                (
-                    ( ? like CONCAT(proj), '%') 
-                OR
-                    ( ? like CONCAT(repo), '%')
-                )                    
-                ");
-        $ar = $q->fetchAll(PDO::FETCH_ASSOC);
-        if ($ar) {
-            $re[$cs] = self::loadByName($ar['repo']);
-            return $re[$cs];
-        } 
-        $re[$cs] = false;
-        return $re[$cs];
-    }
-    */
-    // methods 
-  
+     
     function __construct($ar = null) {
         
         if (!is_array($ar)) {
@@ -177,7 +75,7 @@ class MTrack_Repo extends MTrackSCM
         
     }
     
-    function reconcileRepoSettings()
+    function reconcileRepoSettings(MTrackSCM $r)
     {
         $c = self::Factory(array('scmtype'=>$this->scmtype));
         $s->reconcileRepoSettings($this);
@@ -258,95 +156,11 @@ class MTrack_Repo extends MTrackSCM
     function diff($path, $from = null, $to = null) {}
     function getRelatedChanges($revision) {}
     function getSCMMetaData() { return null; }
-    
-/* -- We do not support projects yet,
-  and anyway it should be repo's are only part of a single project
-  ... even if they are multiple projects it would not be feasible to
-  ... work that out from the path...
-  
-
-    function projectFromPath($filename)
-    {
-    static $links = array();
-    if (!isset($links[$this->repoid]) || $links[$this->repoid] === null) {
-      $links[$this->repoid] = array();
-      foreach (MTrackDB::q(
-        'select projid, repopathregex from project_repo_link where repoid = ?',
-            $this->repoid) as $row) {
-        $re = str_replace('/', '\\/', $row[1]);
-        $links[$this->repoid][] = array($row[0], "/$re/");
-      }
-    }
-    if (is_array($filename)) {
-      $proj_incidence = array();
-      foreach ($filename as $file) {
-        $proj = $this->projectFromPath($file);
-        if ($proj === null) continue;
-        if (isset($proj_incidence[$proj])) {
-          $proj_incidence[$proj]++;
-        } else {
-          $proj_incidence[$proj] = 1;
-        }
-      }
-      $the_proj = null;
-      $the_proj_count = 0;
-      foreach ($proj_incidence as $proj => $count) {
-        if ($count > $the_proj_count) {
-          $the_proj_count = $count;
-          $the_proj = $proj;
-        }
-      }
-      return $the_proj;
-    }
-
-    if ($filename instanceof MTrackSCMFileEvent) {
-      $filename = $filename->name;
-    }
-
-    // walk through the regexes; take the longest match as definitive
-    $longest = null;
-    $longest_id = null;
-    if ($filename[0] != '/') {
-      $filename = '/' . $filename;
-    }
-    foreach ($links[$this->repoid] as $link) {
-      if (preg_match($link[1], $filename, $M)) {
-        if (strlen($M[0]) > strlen($longest)) {
-          $longest = $M[0];
-          $longest_id = $link[0];
-        }
-      }
-    }
-    return $longest_id;
-  }
-  */
-
-
-
-      
-    /*
-    
-    static function defaultRepo($cfg = null)
-    {
-        static $defrepo = null;
-        if ($defrepo !== null) {
-            return $defrepo; // already to it..
-        }
-        
-        $defrepo = $cfg;
-        if ($defrepo !== null) {
-            $defrepo = strpos($defrepo, '/') === false ?  'default/' . $defrepo :  $defrepo;
-            return $defrepo;
-        }
-        
-        $defrepo = '';
-        $q = MTrackDB::q( 'select parent, shortname from repos order by shortname');
-        foreach($q->fetchAll() as $row) {
-            $defrepo = MTrackSCM::makeDisplayName($row);
-            return $defrepo;
-        }
-        return '';
-        
+    /**
+     *  converts a commit log message (cached locally into a working object..)
+     *  see Browse.php
+     */
+    function commitLogToEvent($str) {
+        throw new Exception("no implementation for commitLogToEvent");
     }
-    */
 }