예제 #1
0
 /**
  * @param string Path to repository
  * @param int Number of revision (0 = no limit)
  * @return array  Key are revision number example:
  *        array(
  *            1 => array("author" => "duponc_j", "msg" => "Test", date=> 1265413),
  *            2 => array("revision" => "crivis_s", "msg" => "Test2", date=>4565654)
  *        )
  *
  * Date are unix timestamp
  */
 public static function log($repository, $limit = 25, $start = 0, $end = 0)
 {
     $repository = SVNUtils::getRepositoryPath($repository);
     if ($limit) {
         $limit = escapeshellarg($limit);
         $limit = "--limit {$limit}";
     } else {
         $limit = "";
     }
     if ($start) {
         $revision = "-r {$start}";
         if ($end) {
             $revision .= ":{$end}";
         }
     } else {
         $revision = "";
     }
     $message = ConsoleUtils::runCmdCaptureMessageUnsafe(SVNUtils::svnCommand("log --xml {$revision} {$limit} {$repository}"), $return);
     if ($return) {
         throw new Exception("Can't get subversion repository logs: " . $message);
     }
     return SVNLog::parseOutput($message);
 }
예제 #2
0
 /**
  * List files into Subversion
  *
  * @param string Path to subversion repository
  * @param string Path into subversion repository
  * @return associative array like: array(array(name => "tutu", isDirectory => true))
  */
 public static function listSvn($repository, $path)
 {
     $escape_path = SVNUtils::getRepositoryPath($repository . '/' . $path);
     $lists = ConsoleUtils::runCmdCaptureMessageUnsafe(SVNUtils::svnCommand("ls --xml {$escape_path}"), $return);
     if ($return) {
         throw new USVN_Exception("Can't list subversion repository: " . $lists);
     }
     $res = array();
     $xml = new SimpleXMLElement($lists);
     foreach ($xml->list->entry as $list) {
         if ($list['kind'] == 'file') {
             array_push($res, array("name" => (string) $list->name, "isDirectory" => false, "path" => str_replace('//', '/', $path . "/" . $list->name), "size" => $list->size, "revision" => $list->commit['revision'], "author" => $list->commit->author, "date" => $list->commit->date));
         } else {
             array_push($res, array("name" => (string) $list->name, "isDirectory" => true, "path" => str_replace('//', '/', $path . "/" . $list->name . '/')));
         }
     }
     usort($res, array("SVNUtils", "listSvnSort"));
     return $res;
 }