<?php
-/** FusionForge Bazaar plugin
+/**
+ * FusionForge Bazaar plugin
*
* Copyright 2009, Roland Mas
+ * Copyright 2013, Franck Villaume - TrivialDev
*
* This file is part of FusionForge.
*
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
- *
+ *
* FusionForge is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
$this->main_branch_names[] = 'main' ;
$this->main_branch_names[] = 'head' ;
$this->main_branch_names[] = 'HEAD' ;
-
+
$this->register () ;
}
-
+
function getDefaultServer() {
return forge_get_config('default_server', 'scmbzr') ;
}
if (!$project) {
return false ;
}
-
- if ($project->usesPlugin($this->name)) {
+
+ if ($project->usesPlugin($this->name) && forge_check_perm('scm', $project->getID(), 'read')) {
$result = db_query_params('SELECT sum(commits) AS commits, sum(adds) AS adds FROM stats_cvs_group WHERE group_id=$1',
array ($project->getID())) ;
$commit_num = db_result($result,0,'commits');
echo ' (Bazaar: '.sprintf(_('<strong>%1$s</strong> commits, <strong>%2$s</strong> adds'), number_format($commit_num, 0), number_format($add_num, 0)).")";
}
}
-
+
function getBlurb () {
return '<p>' . _('Documentation for Bazaar (sometimes referred to as "bzr") is available <a href="http://bazaar-vcs.org/Documentation">here</a>.') . '</p>';
}
$b .= '<p>';
$b .= _('Only project developers can access the Bazaar branches via this method. SSH must be installed on your client machine. Enter your site password when prompted.');
$b .= '</p>';
- $b .= '<p><tt>bzr checkout bzr+ssh://'.$d.'@' . $project->getSCMBox() . forge_get_config('repos_path', 'scmbzr') .'/'. $project->getUnixName().'/'._('branchname').'</tt></p>' ;
+ $b .= '<p><tt>bzr checkout bzr+ssh://'.$d.'@' . $this->getBoxForProject($project) . forge_get_config('repos_path', 'scmbzr') .'/'. $project->getUnixName().'/'._('branchname').'</tt></p>' ;
} else {
$b .= '<h2>';
$b .= _('Developer Bazaar Access via SSH');
$b .= '<p>';
$b .= _('Only project developers can access the Bazaar branches via this method. SSH must be installed on your client machine. Substitute <i>developername</i> with the proper value. Enter your site password when prompted.');
$b .= '</p>';
- $b .= '<p><tt>bzr checkout bzr+ssh://<i>'._('developername').'</i>@' . $project->getSCMBox() . forge_get_config('repos_path', 'scmbzr') .'/'. $project->getUnixName().'/'._('branchname').'</tt></p>' ;
+ $b .= '<p><tt>bzr checkout bzr+ssh://<i>'._('developername').'</i>@' . $this->getBoxForProject($project) . forge_get_config('repos_path', 'scmbzr') .'/'. $project->getUnixName().'/'._('branchname').'</tt></p>' ;
}
return $b ;
}
if (!$project) {
return false ;
}
-
+
if ($project->usesPlugin ($this->name)) {
if ($this->browserDisplayable ($project)) {
print '<iframe src="'.util_make_url ("/scm/loggerhead/".$project->getUnixName()).'" frameborder="0" width=100% height=700></iframe>' ;
if (!$project) {
return false ;
}
-
+
if (! $project->usesPlugin ($this->name)) {
return false;
}
+ $project_name = $project->getUnixName();
+
$repo = forge_get_config('repos_path', 'scmbzr') . '/' . $project->getUnixName() ;
- $unix_group = 'scm_' . $project->getUnixName() ;
+ $unix_group = 'scm_' . $project_name ;
$repo_exists = false ;
if (is_dir ($repo)) {
$pipe = popen ("bzr info $repo 2>/dev/null", "r") ;
$line = fgets ($pipe) ;
fclose ($pipe) ;
-
- if (preg_match ("/^Shared repository/", $line) != 0) {
+
+ if (preg_match ("/^Shared repository/", $line) != 0
+ || preg_match ("/^Repository branch/", $line) != 0) {
$repo_exists = true ;
}
}
-
+
if (!$repo_exists) {
$tmp_repo = util_mkdtemp('.bzr', $project_name);
if ($tmp_repo == false) {
if (!$project) {
return false ;
}
-
+
if (! $project->usesPlugin ($this->name)) {
return false;
}
db_rollback () ;
return false ;
}
-
+
$res = db_query_params ('DELETE FROM stats_cvs_user WHERE month=$1 AND day=$2 AND group_id=$3',
array ($month_string,
$day,
$adds = $adds + $curadds ;
$updates = $updates + $curupdates ;
}
-
+
// inserting group results in stats_cvs_groups
if ($updates > 0 || $adds > 0) {
if (!db_query_params ('INSERT INTO stats_cvs_group (month,day,group_id,checkouts,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
return false ;
}
}
-
+
// building the user list
$user_list = array_unique( array_merge( array_keys( $usr_adds ), array_keys( $usr_updates ) ) );
} else {
continue;
}
-
+
$uu = $usr_updates[$user] ? $usr_updates[$user] : 0 ;
$ua = $usr_adds[$user] ? $usr_adds[$user] : 0 ;
if ($uu > 0 || $ua > 0) {
if (!$project) {
return false ;
}
-
+
$group_name = $project->getUnixName() ;
- $snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar.gz';
- $tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
+ $snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar'.util_get_compressed_file_extension();
+ $tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
if (! $project->usesPlugin ($this->name)) {
return false;
$today = date ('Y-m-d') ;
$branch = $this->findMainBranch ($project) ;
if ($branch != '') {
- system ("bzr export --root=$group_name-scm-$today $tmp/snapshot.tar.gz $repo/$bname") ;
- chmod ("$tmp/snapshot.tar.gz", 0644) ;
- copy ("$tmp/snapshot.tar.gz", $snapshot) ;
- unlink ("$tmp/snapshot.tar.gz") ;
+ system ("bzr export --root=$group_name-scm-$today --format=tar - $repo/$bname |".forge_get_config('compression_method')."> $tmp/snapshot") ;
+ chmod ("$tmp/snapshot", 0644) ;
+ copy ("$tmp/snapshot", $snapshot) ;
+ unlink ("$tmp/snapshot") ;
system ("rm -rf $tmp/$dir") ;
} else {
unlink ($snapshot) ;
}
- system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
- chmod ("$tmp/tarball.tar.gz", 0644) ;
- copy ("$tmp/tarball.tar.gz", $tarball) ;
- unlink ("$tmp/tarball.tar.gz") ;
+ system ("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball") ;
+ chmod ("$tmp/tarball", 0644) ;
+ copy ("$tmp/tarball", $tarball) ;
+ unlink ("$tmp/tarball") ;
system ("rm -rf $tmp") ;
}
}
// mode: php
// c-file-style: "bsd"
// End:
-
-?>