[Fusionforge-commits] r7990 - in trunk/gforge: common/include debian plugins/scmbzr/common

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Aug 27 15:40:53 CEST 2009


Author: lolando
Date: 2009-08-27 15:40:53 +0200 (Thu, 27 Aug 2009)
New Revision: 7990

Added:
   trunk/gforge/debian/gforge-plugin-scmbzr.postinst
   trunk/gforge/debian/gforge-plugin-scmbzr.prerm
Modified:
   trunk/gforge/common/include/SCMPlugin.class.php
   trunk/gforge/debian/control
   trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php
Log:
Enabling scmbzr

Modified: trunk/gforge/common/include/SCMPlugin.class.php
===================================================================
--- trunk/gforge/common/include/SCMPlugin.class.php	2009-08-27 13:40:42 UTC (rev 7989)
+++ trunk/gforge/common/include/SCMPlugin.class.php	2009-08-27 13:40:53 UTC (rev 7990)
@@ -164,6 +164,28 @@
 		}
 	}
 
+	function AdminUpdate ($params) {
+		$project = $this->checkParams ($params) ;
+		if (!$project) {
+			return false ;
+		}
+		
+		if ($project->usesPlugin ($this->name) ) {
+			if ($params['scm_enable_anonymous']) {
+				$project->SetUsesAnonSCM(true);
+			} else {
+				$project->SetUsesAnonSCM(false);
+			}
+		}
+	}
+	
+	function getAdminPage ($params) {
+		$group =& group_get_object($params['group_id']);
+		if ( $group->usesPlugin ( $this->name ) && $group->isPublic()) {
+			print '<p><input type="checkbox" name="scm_enable_anonymous" value="1" '.$this->c($group->enableAnonSCM()).' /><strong>'._('Enable Anonymous Access').'</strong></p>';
+		}
+	}
+	
 	function checkParams ($params) {
 		$group_id = $params['group_id'] ;
 		$project =& group_get_object($group_id);

Modified: trunk/gforge/debian/control
===================================================================
--- trunk/gforge/debian/control	2009-08-27 13:40:42 UTC (rev 7989)
+++ trunk/gforge/debian/control	2009-08-27 13:40:53 UTC (rev 7990)
@@ -214,6 +214,21 @@
  each FusionForge project to have its own Subversion repository, and gives
  some control over it to the project's administrator.
 
+Package: gforge-plugin-scmbzr
+Architecture: all
+Depends: gforge-common, gforge-db-postgresql | gforge-db, gforge-web-apache2 | gforge-web, gforge-shell-postgresql | gforge-shell, bzr, php5-cli, ${misc:Depends}
+Description: collaborative development tool - Bazaar plugin
+ FusionForge provides many tools to aid collaboration in a
+ development project, such as bug-tracking, task management,
+ mailing-lists, SCM repository, forums, support request helper,
+ web/FTP hosting, release management, etc. All these services are
+ integrated into one web site and managed through a web interface.
+ .
+ This plugin contains the Bazaar subsystem of FusionForge. It allows each
+ FusionForge project to have its own Bazaar repository, and gives some control
+ over it to the project's administrator.
+Provides: gforge-plugin-scm
+
 Package: gforge-plugin-scmcpold
 Architecture: all
 Depends: gforge-common, gforge-db-postgresql | gforge-db, gforge-web-apache2 | gforge-web, gforge-shell-postgresql | gforge-shell, php5-cli, ${misc:Depends}

Added: trunk/gforge/debian/gforge-plugin-scmbzr.postinst
===================================================================
--- trunk/gforge/debian/gforge-plugin-scmbzr.postinst	                        (rev 0)
+++ trunk/gforge/debian/gforge-plugin-scmbzr.postinst	2009-08-27 13:40:53 UTC (rev 7990)
@@ -0,0 +1,51 @@
+#! /bin/sh
+# postinst script for gforge-plugin-scmbzr
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+# quoting from the policy:
+#     Any necessary prompting should almost always be confined to the
+#     post-installation script, and should be protected with a conditional
+#     so that unnecessary prompting doesn't happen if a package's
+#     installation fails and the `postinst' is called with `abort-upgrade',
+#     `abort-remove' or `abort-deconfigure'.
+
+case "$1" in
+    configure)
+	gforge-config
+
+	# Prepare database
+	su -s /bin/sh gforge -c '/usr/share/gforge/bin/register-plugin scmbzr "Bazaar"'
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+

Added: trunk/gforge/debian/gforge-plugin-scmbzr.prerm
===================================================================
--- trunk/gforge/debian/gforge-plugin-scmbzr.prerm	                        (rev 0)
+++ trunk/gforge/debian/gforge-plugin-scmbzr.prerm	2009-08-27 13:40:53 UTC (rev 7990)
@@ -0,0 +1,45 @@
+#! /bin/sh
+# prerm script for gforge-plugin-scmbzr
+#
+# see: dh_installdeb(1)
+set -e
+
+#DEBHELPER#
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|deconfigure)
+	if [ -f /var/run/postgresql/.s.PGSQL.5432 ]
+	then
+		/usr/share/gforge/bin/unregister-plugin scmbzr
+	else
+		echo "WARNING: database not available to unregister scmbzr plugin"
+	fi
+        ;;
+    upgrade|failed-upgrade)
+        ;;
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+
+
+exit 0
+
+

Modified: trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php
===================================================================
--- trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php	2009-08-27 13:40:42 UTC (rev 7989)
+++ trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php	2009-08-27 13:40:53 UTC (rev 7990)
@@ -41,107 +41,24 @@
 		return $this->default_bzr_server ;
 	}
 
-	function getPage ($group_id) {
-		global $HTML, $sys_scm_snapshots_path;
-
-		$project = $this->checkParams ($params) ;
-		if (!$project) {
-			return false ;
-		}
-		
-		if ($project->usesPlugin ($this->name)) {
-			// Table for summary info
-			print ('<table width="100%">
-				 <tr valign="top">
-				 <td width="65%">') ;
-			print _('<p>Documentation for Bazaar (sometimes referred to as "bzr") is available <a href="http://doc.bazaar-vcs.org/latest/en/user-guide/index.html">here</a>.</p>');
-			
-			// Anonymous Bazaar Instructions
-			if ($project->enableAnonSCM()) {
-				print _("<p><b>Anonymous Bazaar Access</b></p><p>This project's Bazaar repository can be accessed anonymously through HTTP.</p>");
-				print '<p>';
-				print _("A list of available branches can be obtained with the following command:") ;
-				print "<br />" ;
-				print '<tt>bzr branches http://' . $project->getSCMBox(). '/' . $this->svn_root .'/'. $project->getUnixName() .'</tt>';
-				print '</p>';
-				print '<p>';
-				print _("To check out one of these branches:") ;
-				print "<br />" ;
-				print '<tt>bzr checkout http://' . $project->getSCMBox(). '/' . $this->svn_root .'/'. $project->getUnixName() .'<i>'._('branchname').'</i></tt>' ;
-				print '</p>';
-			}
-		
-			// Developer Access
-			echo _('<p><b>Developer Bazaar Access via SSH</b></p><p>Only project developers can access the Bazaar branches tree via this method. SSH must be installed on your client machine. Substitute <i>developername</i> with the proper values. Enter your site password when prompted.</p>');
-			print '<p><tt>bzr checkout bzr+ssh://<i>'._('developername').'</i>@' . $project->getSCMBox() . '/'. $this->svn_root .'/'. $project->getUnixName().'/'._('branchname').'</tt></p>' ;
-		
-			// Bazaar Snapshot
-			if ($this->browserDisplayable ($project) {
-				$filename=$project->getUnixName().'-scm-latest.tar.gz';
-				if (file_exists($sys_scm_snapshots_path.'/'.$filename)) {
-					print '<p>[' ;
-					print util_make_link ("/snapshots.php?group_id=$group_id",
-							      _('Download The Nightly Bazaar Tree Snapshot')
-						) ;
-					print ']</p>';
-				}
-			}
-		
-			print '</td><td width="35%" valign="top">' ;
-			// Bazaar Browsing
-		
-			echo $HTML->boxTop(_('Repository History'));
-			echo _('Not implemented yet');
-			/*				echo $this->getDetailedStats(array('group_id'=>$group_id)).'<p>';
-			 if ($this->browserDisplayable ($project) {
-			 echo _('<b>Browse the Bazaar Tree</b><p>Browsing the Bazaar tree gives you a great view into the current status of this project\'s code. You may also view the complete histories of any file in the repository.</p>');
-			 echo '<p>[' ;
-			 echo util_make_link ("/scm/viewvc.php/?root=".$project->getUnixName(),
-			 _('Browse Bazaar Repository')
-			 ) ;
-			 echo ']</p>' ;
-			 }
-			*/
-			echo $HTML->boxBottom();
-			print '</td></tr></table>' ;
-		}
+	function getBlurb () {
+		return _('<p>Documentation for Bazaar (sometimes referred to as "bzr") is available <a href="http://bazaar-vcs.org/Documentation">here</a>.</p>') ;
 	}
-	
-	function AdminUpdate ($params) {
-		$project = $this->checkParams ($params) ;
-		if (!$project) {
-			return false ;
-		}
-		
-		if ( $project->usesPlugin ( $this->name ) ) {
-			if ($params['scmbzr_enable_anon_bzr']) {
-				$project->SetUsesAnonSCM(true);
-			} else {
-				$project->SetUsesAnonSCM(false);
-			}
-		}
-	}
 
-	// This function is used to render checkboxes below
-	function c($v) {
-		if ($v) {
-			return 'checked="checked"';
-		} else {
-			return '';
-		}
+	function getInstructionsForAnon ($project) {
+		$b =  _('<p><b>Anonymous Bazaar Access</b></p><p>This project\'s Bazaar repository can be checked out through anonymous access with the following command(s).</p>');
+		$b .= '<p>' ;
+		$b .= '<tt>bzr checkout http://'.$project->getSCMBox().'/'.$this->bzr_root.'/'.$project->getUnixName().'</tt><br />';
+		$b .= '</p>';
+		return $b ;
 	}
 
-	function getAdminPage ($params) {
-		$project = $this->checkParams ($params) ;
-		if (!$project) {
-			return false ;
-		}
+	function getInstructionsForRW ($project) {
+		$b = '' ;
+		$b .= _('<p><b>Developer Subversion Access via SSH</b></p><p>Only project developers can access the SVN tree via this method. SSH must be installed on your client machine. Substitute <i>developername</i> with the proper values. Enter your site password when prompted.</p>');
+		$b .= '<p><tt>bzr checkout bzr+ssh://<i>'._('developername').'</i>@' . $project->getSCMBox() . '/'. $this->bzr_root .'/'. $project->getUnixName().'/'._('branchname').'</tt></p>' ;
 		
-		if ( $project->usesPlugin ( $this->name ) && $project->isPublic()) {
-			?>
-			<p><input type="checkbox" name="scmbzr_enable_anon_bzr" value="1" <?php echo $this->c($project->enableAnonSCM()); ?> /><strong><?php echo _('Enable Anonymous Access') ?></strong></p>
-																		      <?php
-																		      }
+		return $b ;
 	}
 
 	function getStats ($params) {
@@ -151,83 +68,12 @@
 		}
 		
 		if ($project->usesPlugin ($this->name)) {
-			list($commit_num, $add_num) = $this->getTotalStats($group_id);
-			echo ' (Bazaar: '.sprintf(_('<strong>%1$s</strong> updates, <strong>%2$s</strong> adds'), number_format($commit_num, 0), number_format($add_num, 0)).')';
+			echo ' (Bazaar)';
 		}
 	}
 
-	// Get the total stats for a group
-	function getTotalStats($group_id) {
-		$result = db_query_params ('
-			SELECT SUM(commits) AS commits, SUM(adds) AS adds
-			FROM stats_cvs_group
-			WHERE group_id=$1',
-			array($group_id));
-		$commit_num = db_result($result,0,0);
-		$add_num	= db_result($result,0,1);
-		if (!$commit_num) {
-			$commit_num=0;
-		}
-		if (!$add_num) {
-			$add_num=0;
-		}
-		return array($commit_num, $add_num);
-	}
-
 	function getDetailedStats ($params) {
-		global $HTML;
-		$group_id = $params['group_id'] ;
-
-		$result = db_query('
-			SELECT u.realname, u.user_name, u.user_id, sum(commits) as commits, sum(adds) as adds, sum(adds+commits) as combined
-			FROM stats_cvs_user s, users u
-			WHERE group_id=\''.$group_id.'\' AND s.user_id=u.user_id AND (commits>0 OR adds >0)
-			GROUP BY group_id, realname, user_name, u.user_id
-			ORDER BY combined DESC, realname;
-		');
-
-		if (db_numrows($result) > 0) {
-			$tableHeaders = array(
-				_('Name'),
-				_('Adds'),
-				_('Updates')
-				);
-			echo $HTML->listTableTop($tableHeaders);
-
-			$i = 0;
-			$total = array('adds' => 0, 'commits' => 0);
-
-			while($data = db_fetch_array($result)) {
-				echo '<tr '. $HTML->boxGetAltRowStyle($i) .'>';
-				echo '<td width="50%">' ;
-				echo util_make_link_u ($data['user_name'], $data['user_id'], $data['realname']) ;
-				echo '</td><td width="25%" align="right">'.$data['adds']. '</td>'.
-					'<td width="25%" align="right">'.$data['commits'].'</td></tr>';
-				$total['adds'] += $data['adds'];
-				$total['commits'] += $data['commits'];
-				$i++;
-			}
-			list($commit_num, $add_num) = $this->getTotalStats($group_id);
-			if ($commit_num > $total['commits'] ||
-			    $add_num > $total['adds']) {
-				echo '<tr '. $HTML->boxGetAltRowStyle($i) .'>';
-				echo '<td width="50%">' .
-					_('Unknown') .
-					'</td><td width="25%" align="right">'.
-					($add_num - $total['adds']) . '</td>'.
-					'<td width="25%" align="right">'.
-					($commit_num - $total['commits']) .
-					'</td></tr>';
-				$i++;
-			}
-			echo '<tr '. $HTML->boxGetAltRowStyle($i) .'>';
-			echo '<td width="50%"><strong>'._('Total').':</strong></td>'.
-				'<td width="25%" align="right"><strong>'.$add_num. '</strong></td>'.
-				'<td width="25%" align="right"><strong>'.$commit_num.'</strong></td>';
-			echo '</tr>';
-			echo $HTML->listTableBottom();
-			echo '<hr size="1" />';
-		}
+		return ;
 	}
 
 	function createOrUpdateRepo ($params) {




More information about the Fusionforge-commits mailing list