[Fusionforge-commits] r8135 - in trunk/gforge: packaging/dirs plugins/scmbzr/common plugins/scmbzr/etc/plugins/scmbzr

Roland Mas lolando at libremir.placard.fr.eu.org
Mon Sep 21 22:18:03 CEST 2009


Author: lolando
Date: 2009-09-21 22:18:03 +0200 (Mon, 21 Sep 2009)
New Revision: 8135

Modified:
   trunk/gforge/packaging/dirs/plugin-scmbzr
   trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php
   trunk/gforge/plugins/scmbzr/etc/plugins/scmbzr/serve-branches.conf
Log:
Added logic to maintain a symlink farm for public bzr repositories

Modified: trunk/gforge/packaging/dirs/plugin-scmbzr
===================================================================
--- trunk/gforge/packaging/dirs/plugin-scmbzr	2009-09-21 20:17:54 UTC (rev 8134)
+++ trunk/gforge/packaging/dirs/plugin-scmbzr	2009-09-21 20:18:03 UTC (rev 8135)
@@ -2,3 +2,4 @@
 etc/gforge/plugins/scmbzr
 usr/share/gforge/plugins/scmbzr/common
 var/lib/gforge/chroot/scmrepos/bzr
+var/lib/gforge/plugins/scmbzr/public-repositories

Modified: trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php
===================================================================
--- trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php	2009-09-21 20:17:54 UTC (rev 8134)
+++ trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php	2009-09-21 20:18:03 UTC (rev 8135)
@@ -29,6 +29,7 @@
 		$this->text = 'Bazaar';
 		$this->hooks[] = 'scm_generate_snapshots' ;
                 $this->hooks[] = 'scm_browser_page';
+                $this->hooks[] = 'scm_update_repolist' ;
 
 		require_once $gfconfig.'plugins/scmbzr/config.php' ;
 		
@@ -146,6 +147,55 @@
 		}
 	}
 
+        function updateRepositoryList ($params) {
+                $groups = $this->getGroups () ;
+
+		$dir = '/var/lib/gforge/plugins/scmbzr/public-repositories' ;
+
+		$oldlist = array () ;
+		$dh = opendir ($dir) ;
+		while (($file = readdir($dh)) !== false) {
+			if ($file != '.' && $file != '..') {
+				$oldlist[] = $file ;
+			}
+		}
+		closedir($dh) ;
+		sort ($oldlist) ;
+
+                $newlist = array () ;
+                foreach ($groups as $project) {
+                        if ($this->browserDisplayable ($project)) {
+                                $newlist[] = $project->getUnixName() ;
+                        }
+                }
+		sort ($newlist) ;
+
+		$dellist = array () ;
+		$createlist = array () ;
+
+		while (count ($oldlist) > 0 && count ($newlist) > 0) {
+			$o = $oldlist[0] ;
+			$n = $newlist[0] ;
+			if ($o > $n) {
+				$createlist[] = array_shift ($newlist) ;
+			} elseif ($o < $n) {
+				$dellist[] = array_shift ($oldlist) ;
+			} else {
+				array_shift ($newlist) ;
+				array_shift ($oldlist) ;
+			}
+		}
+		$dellist = array_merge ($dellist, $oldlist) ;
+		$createlist = array_merge ($createlist, $newlist) ;
+
+		foreach ($dellist as $del) {
+			unlink ($dir . '/' . $del) ;
+		}
+		foreach ($createlist as $create) {
+			symlink ($this->bzr_root . '/' . $create, $dir . '/' . $create) ;
+		}
+        }
+
 	function generateSnapshots ($params) {
 		global $sys_scm_snapshots_path ;
 		global $sys_scm_tarballs_path ;

Modified: trunk/gforge/plugins/scmbzr/etc/plugins/scmbzr/serve-branches.conf
===================================================================
--- trunk/gforge/plugins/scmbzr/etc/plugins/scmbzr/serve-branches.conf	2009-09-21 20:17:54 UTC (rev 8134)
+++ trunk/gforge/plugins/scmbzr/etc/plugins/scmbzr/serve-branches.conf	2009-09-21 20:18:03 UTC (rev 8135)
@@ -1,3 +1,3 @@
-served_branches=/var/lib/gforge/chroot/scmrepos/bzr
-prefix=plugins/scmbzr/loggerhead
+served_branches=/var/lib/gforge/plugins/scmbzr/public-repositories
+prefix=/scm/loggerhead
 port=8081




More information about the Fusionforge-commits mailing list