Anonymous avatar Anonymous committed 3a482a6

STABLE: config file stabilized and re-integration completed. Begin regression tests. Next step: allow profile and/or theme switching.

Comments (0)

Files changed (5)

admin/application/config/phphgadmin.php

 <?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
 
-
+/******************
+ * phpHgAdmin Configuration
+ * 
+ * You can verify this configuration by accessing checkinstall.php through a web browser.
+ * checkinstall.php can be safely removed afterwards.
+ *******************/
+/*
+ * Full URl to phpHgAdmin
+ */
 $config['base_url']	= "http://localhost:8080/admin/";
 
+/******************
+ * HGRC Configuration
+ ****************************/
+/*
+ * Default available configuration of HGRC.
+ * Available help language translation will be assumed to be hgphp_tooltip_hgrc_ARRAYNAME_KEY, i.e. hgphp_tooltip_hgrc_paths_default
+ *
+ * Create one or more common hgrc defaults which can be used for any number of profiles.
+ * 
+ * Shortcuts
+ * %1$s = the current profile's hgserve_url
+ * %2$s = the current repository's name
+ */
+$config['default_hgrc']['general']['paths']['default'] = '%1$s%2$s'; 
+$config['default_hgrc']['general']['web']['allow_archive'] = '';
+$config['default_hgrc']['general']['web']['allow_push'] = '';
+$config['default_hgrc']['general']['web']['allowpull'] = '';
+$config['default_hgrc']['general']['web']['allow_read'] = '';
+$config['default_hgrc']['general']['web']['contact'] = '';
+$config['default_hgrc']['general']['web']['description'] = '';
+$config['default_hgrc']['general']['web']['name'] = '%2$s';
+$config['default_hgrc']['general']['web']['push_ssl'] = '';
+$config['default_hgrc']['general']['web']['style'] = '';
+	
+/*
+ * HGRC config which are booleans. Used as hints when rendering UI input elements
+ */
+$config['hgrc_bools_arr']['web'] = array('allowpull', 'push_ssl');
+
+/*********************
+ * Mercurial Profiles
+ *********************/
+	
+/*
+ * The profile to use if the user does not specify one explicitly.
+ */
+$config['default_profile'] = 'default';
+	
+/*
+ * Collection of profiles. Each profile has
+ * ini                - absolute path and name of file used by hgwebdir.cgi to index repositories (i.e. a hgweb.config)
+ * default_repo_dir   - absolute local path to folder on disk where created repositories will be saved. Trailing slash required!
+ * hgserve_url        - absolute path to where Mercurial is serving the repository via web interface. Trailing slash required!
+ * default_hgrc       - reference to a hgrc profile (above) or a declaration of one in the same format
+ */
 $config['profile']['default']['ini'] = 'C:\Users\joshjcarrier\workspace\hg-php.joshjcarrier.com\admin\lock\cgi-bin/hgweb.config';
 $config['profile']['default']['default_repo_dir'] = 'C:\Users\joshjcarrier\workspace\hg-php.joshjcarrier.com\admin\lock\cgi-bin/';
 $config['profile']['default']['hgserve_url'] = 'http://localhost:8080/';
+$config['profile']['default']['default_hgrc'] = $config['default_hgrc']['general'];
 
-$config['default_profile'] = 'default';
+/*
+ * Manager theme - mimics available Mercurial themes
+ * Valid themes: coal, gitweb, monoblue, paper
+ * A blank string defaults to paper.
+ */
+$config['theme'] = 'paper';
 
 /*
  * Global permission levels, which override the authenticated user's permissions.
 $config['hgwebconf_allow_repo_view'] = true;
 $config['hgwebconf_allow_repo_delete'] = true;
 
-/*
- * Absolute local path and filename to where the hgweb.config file is saved
- * E.g. /home/jcarrier/htdocs/hg/hgweb.config
- */
-//$config['hgwebconf_abs_filepath'] = 'C:\Users\joshjcarrier\workspace\hg-php.joshjcarrier.com\admin\lock\cgi-bin\hgweb.config';
-
-/*
- * Accessing the Mercurial repository.
- * This management tool assumes all Mercurial repositories reside in one location.
- * *Note: Update the repository listings (i.e. create a new repository) to put this value in to effect on hgweb.config.
- * Must be writable by web server.
- * Trailing slash required!
- * E.g. /home/jcarrier/hg_repositories/
- */
-//$config['repositories_abs_dir'] = 'C:\Users\joshjcarrier\workspace\hg-php.joshjcarrier.com\admin\lock\cgi-bin/';
-
-/*
- * Manager theme - mimics available Mercurial themes
- * Valid themes: coal, gitweb, monoblue, paper
- * A blank string defaults to paper.
- */
-$config['theme'] = 'paper';
-
-/******************
- * HGRC Configuration
- ****************************/
-/*
- * Default available configuration of HGRC.
- * Available help language translation will be assumed to be hgphp_tooltip_hgrc_ARRAYNAME_KEY, i.e. hgphp_tooltip_hgrc_paths_default
- */
-$config['hgrc_default_arr'] = array(
-		'paths' => array(
-			'default' 			=> 	'http://localhost/%s' // project name denoted by %s
-		),
-			
-		'web' => array(
-			'allow_archive' 	=> 	'',
-			'allow_push' 		=> 	'',
-			'allowpull' 		=> 	'false',
-			'allow_read' 		=> 	'',
-			'contact' 			=> 	'',
-			'description' 		=> 	'',
-			'name' 				=> 	'%s', // project name denoted by %s
-			'push_ssl' 			=> 	'false',
-			'style' 			=> 	'',
-		)
-	);
-	
-/*
- * HGRC config which are booleans
- */
-$config['hgrc_bools_arr'] = array(
-		'web' => array(
-			'allowpull',
-			'push_ssl'
-		)
-	);
-	
 /***********************
  * Not recommended to change once deployed beyond this point
  *****************************/
  */
 $config['lock_dir'] = './lock/'; // abs or rel path from admin/index.php, trailing slash required
 $config['lock_ofl_index'] = 'ofl_index.dat';
-//$config['compatability_delimiter'] = '----';
 $config['ofl_disabled'] = false; // highly recommended not to turn the optimistic lock manager off
-
-
-

admin/application/libraries/hg_ini.php

 		$touch_status = $this->_ci->optimisticflock->ofl_touch($hgrc_path, $this->_ofl_lock);
 		if($touch_status == HGPHP_OK)
 		{
-			$blank_hgrc = $this->__blank_hgrc($r_name);
+			$blank_hgrc = $this->__blank_hgrc($r_name, $hgweb);
 			// update touch status for setHGRC return code
-			$touch_status = $this->saveHgRC($r_name, $blank_hgrc);
+			$touch_status = $this->saveHgRC($r_name, $blank_hgrc, $hgweb);
 		}
 		return $touch_status;
 	}
 	 * @return status code
 	 * @unused
 	 */
-	function unlinkHgRC($r_name)
+	function unlinkHgRC($r_name, $hgweb = null)
 	{
 		$hgrc_path = $this->getHgRCPath($r_name, $hgweb) . '/.hg/hgrc';
 		
 	 * @param r_name name of the repository which will own the hgrc file
 	 * @return hgrc reprsented as array
 	 */
-	function __blank_hgrc($r_name)
+	function __blank_hgrc($r_name, $profile = null)
 	{
+		$profile_arr = $this->getInstallConfig($profile);
 		// automatic appending
-		$blank_hgrc = $this->_ci->config->item('hgrc_default_arr');
-		$blank_hgrc['paths']['default'] = sprintf($blank_hgrc['paths']['default'], $r_name);
-		$blank_hgrc['web']['name'] = sprintf($blank_hgrc['web']['name'], $r_name);
+		$hgserve_url = $profile_arr['hgserve_url'];
+		$blank_hgrc = $profile_arr['default_hgrc'];
+		
+		foreach($blank_hgrc as $c_name => $collection)
+		{
+			foreach($collection as $i_name => $i_value)
+			{
+				$blank_hgrc[$c_name][$i_name] = sprintf($i_value, $hgserve_url, $r_name);
+			}
+		}
+//		$blank_hgrc['paths']['default'] = sprintf($blank_hgrc['paths']['default'], $r_name);
+//		$blank_hgrc['web']['name'] = sprintf($blank_hgrc['web']['name'], $r_name);
 		return new ini64($blank_hgrc);
 	}
 	

admin/application/libraries/optimisticflock.php

 	function __construct($config = array())
 	{
 		$this->_ci =& get_instance();
-		if(!empty($config))
-		{
-			$this->initialize($config);
-			$this->_tm_index = $this->_lock_dir . $this->_lock_ofl_index;
-		}
-	}
-	
-	function initialize($config = array())
-	{
-		foreach($config as $key=>$val)
-		{
-			$this->{'_'.$key} = $val;
-		}
+		
+		$this->_ofl_disabled = $this->_ci->config->item('ofl_disabled');
+		$lock_dir = $this->_ci->config->item('lock_dir');
+		$lock_ofl_index = $this->_ci->config->item('lock_ofl_index');
+		$this->_tm_index = $lock_dir . $lock_ofl_index;
 	}
 	
 	/**

admin/application/libraries/phphgadmin.php

 		
 		// retrieves current 
 		$this->_ci->hg_ini->register_OFL($this->_ofl_lock_hgweb);
-		$hgwebrepos_compat = $this->_ci->hg_ini->getRepoList();
+		$hgwebrepos_compat = $this->_ci->hg_ini->getRepoList($webdir);
 				
 		$hgwebrepos = array();
 		if(is_array($hgwebrepos_compat))
 		}
 		
 		$allrepo = $realdir;
-//			$hgwebrepos = array_values($hgwebdir_compat);
 		$allrepo = array_merge($realdir, $hgwebrepos);
 
 
 			}
 		}
 		
-//		foreach($hgwebrepos as $id => $repo)
-//		{
-//			$hgrepos[$repo]['id'] = $id;
-//		}
-		
 		return $hgrepos;
 	}
 	
 	 * @param r_name name of the project whose hgrc to retrieve
 	 * @return array representing hgrc or status code
 	 */
-	function stat_repository($r_id)
+	function stat_repository($r_id, $profile = null)
 	{
 		if(!$this->can_view($r_id))
 		{
 			return HGPHP_ERR_PERM_USR;
 		}
 		$this->_ci->hg_ini->register_OFL($this->_ofl_lock_hgrc);
-		return $this->_ci->hg_ini->loadHgRC($r_id);
+		return $this->_ci->hg_ini->loadHgRC($r_id, $profile);
 	}
 	
-	function create_repository($r_name)
+	function create_repository($r_name, $profile = null)
 	{
 		if(!$this->can_create($r_name))
 		{
 		
 		$create_status = HGPHP_OK;
 		
-		$lsdir = $this->_ci->hg_ini->getRepoList(); 
-//
-//		// simplifies repo list into array where name is both key and value
-//		// this is how hgweb.config wants it
-//		$existingdir = array();
-//		
-//		if(is_array($lsdir))
-//		{
-//			$existingdir = array_keys($lsdir);
-//		}
-//		else
-//		{
-//			// error code
-//			return $lsdir;
-//		}
-//		
-//		$tempexistingdir = array();
-//		foreach($existingdir as $repo_name)
-//		{
-//			$repo_name = base64_decode($repo_name);
-//			$tempexistingdir[$repo_name] = $repo_name;
-//		}
-//		$existingdir = $tempexistingdir;
+		$lsdir = $this->_ci->hg_ini->getRepoList($profile); 
 		
 		// not registered in hgweb.config
-		
 		$hashr_name = base64_encode($r_name);
-//		print_r($lsdir);
-//		echo $hashr_name;
 		if(!isset($lsdir[$hashr_name]))
 		{
 			
 			// edit the directory
 //			$existingdir[$r_name] = $r_name;
 			$this->_ci->hg_ini->register_OFL($this->_ofl_lock_hgweb);
-//			$create_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir);
-			$create_status = $this->_ci->hg_ini->registerRepo($r_name);
+			$create_status = $this->_ci->hg_ini->registerRepo($r_name, $profile);
 			if($create_status == HGPHP_OK)
 			{
 				// then create the repository
-//				$this->_ci->hg_ini->register_OFL($this->_ofl_lock_hgrc);
 				$this->_ci->hg_ini->register_OFL($this->_ofl_lock_hgrc);
 				$create_status = $this->_ci->hg_filesystem->create_repository_dir($r_name);
 				
 				if($create_status == HGPHP_OK)
 				{
 					
-					$create_status = $this->_ci->hg_ini->touchHgRC($r_name);
+					$create_status = $this->_ci->hg_ini->touchHgRC($r_name, $profile);
 				}
 			}
 		}
 		return $create_status;
 	}
 	
-/**
+	/**
 	 * update_repository
 	 * Update repository's hgrc
 	 * @param r_name name of the repository to update hgrc for
 	 * @param hgrc_data array representing new hgrc file
 	 * @return status code
 	 */
-	function update_repository($r_name, $hgrc_data)
+	function update_repository($r_name, $hgrc_data, $profile = null)
 	{
 		if(!$this->can_update($r_name))
 		{
 			return HGPHP_ERR_PERM_USR;
 		}
 		$this->_ci->hg_ini->register_OFL($this->_ofl_lock_hgrc);
-		return $this->_ci->hg_ini->saveHgRC($r_name, $hgrc_data);
+		return $this->_ci->hg_ini->saveHgRC($r_name, $hgrc_data, $profile);
 	}
 	
 	/**
 		}
 		
 		$del_status = HGPHP_OK;
-		$lsdir = $this->_ci->hg_ini->getRepoList();
+		$lsdir = $this->_ci->hg_ini->getRepoList($hgweb);
 		
 		// simplifies repo list into array where name is both key and value
 		// this is how hgweb.config wants it
 //					
 //					if($del_status == HGPHP_OK)
 //					{
-						$del_status = $this->_ci->hg_ini->unregisterRepo($r_key);
+						$del_status = $this->_ci->hg_ini->unregisterRepo($r_key, $hgweb);
 //					}
 //				}
 			}

admin/checkinstall.php

 header('Pragma: no-cache');
 define('BASEPATH', 'system/');
 include 'application/config/config.php';
-include 'application/config/hgphp.php';
+include 'application/config/phphgadmin.php';
 
 $checks = array(
 
 function test_writehgwebdir()
 {
 	global $config;
-	return is_writable($config['hgwebconf_abs_filepath']);
+	return is_writable($config['profile'][$config['default_profile']]['ini']);
 }
 
 function test_writehgrc()
 {
 	global $config;
-	return is_writable($config['repositories_abs_dir']);
+	return is_writable($config['profile'][$config['default_profile']]['default_repo_dir']);
 }
 
 ///////////////////////////////////////////////////////////////////
 	<td width="150"><b>Apache version</b></td>
 	<td><?php echo apache_get_version(); ?></td>
 </tr>
+<tr>
+	<td width="150"><b>Native Python version</b></td>
+	<td><?php echo exec('python --version'); ?></td>
+</tr>
 </table>
 </fieldset>
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.