Mercurial > public > src > phphgadmin
diff admin/application/libraries/hgphp.php @ 44:46961a5f545c
Pulled the OFL out of hgphp and hgconf2ini method signatures in favor of 'transaction' order of method calls
author | joshjcarrier |
---|---|
date | Wed, 09 Jun 2010 00:59:15 -0700 |
parents | 2cf4300b3541 |
children |
line wrap: on
line diff
--- a/admin/application/libraries/hgphp.php Tue Jun 08 23:32:05 2010 -0700 +++ b/admin/application/libraries/hgphp.php Wed Jun 09 00:59:15 2010 -0700 @@ -18,6 +18,8 @@ class HgPHP { private $_ci; + private $_ofl_lock_hgweb; + private $_ofl_lock_hgrc; function __construct($config = array()) { @@ -50,17 +52,36 @@ */ /** + * Associates OFL locks + */ + function start_transaction(&$ofl_lock_hgweb, &$ofl_lock_hgrc) + { + $this->_ofl_lock_hgweb = &$ofl_lock_hgweb; + $this->_ofl_lock_hgrc = &$ofl_lock_hgrc; + } + + /** + * Disassociates OFL locks + */ + function end_transaction() + { + $dummy = ''; + $this->_ofl_lock_hgweb = &$dummy; + $this->_ofl_lock_hgrc = &$dummy; + } + + /** * Returns a list of available repositories. * Will show up if: detected in repo directory * Will have status "enabled" if: detected in hgweb.config * - * @param ofl_lock_hgwebconf (updated by reference) the current optimistic file lock value * @return an array of 0 or more detected repositories */ - function lsdir(&$ofl_lock_hgwebconf) + function lsdir() { $realdir = $this->__realdirscan(); - $hgwebdir_compat = $this->_ci->hgconf2ini->getHgWebDirCollections($ofl_lock_hgwebconf); + $this->_ci->hgconf2ini->register_OFL($this->_ofl_lock_hgweb); + $hgwebdir_compat = $this->_ci->hgconf2ini->getHgWebDirCollections(); $allrepo = $realdir; if(!is_integer($hgwebdir_compat)) @@ -100,11 +121,9 @@ * - adding an entry in hgrc if not present * - creating a bare repository if not present * @param r_name name of the new repository to create, used as folder name - * @param hg_lock_hgwebconf (updated by reference) the last known optimistic file lock value of hgwebconf - * @param hg_lock_hgrc (updated by reference) value of hgrc's lock value * @return status code */ - function create_repository($r_name, &$ofl_lock_hgwebconf, &$hg_lock_hgrc) + function create_repository($r_name) { if(!$this->can_create($r_name)) { @@ -112,8 +131,8 @@ } $create_status = HGPHP_OK; - $ofl_dummylock_hgwebconf = ''; - $lsdir = $this->_ci->hgconf2ini->getHgWebDirCollections($ofl_dummylock_hgwebconf); // don't want to update the lock yet + + $lsdir = $this->_ci->hgconf2ini->getHgWebDirCollections(); // simplifies repo list into array where name is both key and value // this is how hgweb.config wants it @@ -141,11 +160,13 @@ { // edit the directory $existingdir[$r_name] = $r_name; - $create_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir, $ofl_lock_hgwebconf); + $this->_ci->hgconf2ini->register_OFL($this->_ofl_lock_hgweb); + $create_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir); if($create_status == HGPHP_OK) { // then create the repository - $create_status = $this->create_repository_dir($r_name, $hg_lock_hgrc); + $this->_ci->hgconf2ini->register_OFL($this->_ofl_lock_hgrc); + $create_status = $this->create_repository_dir($r_name); } } else @@ -161,27 +182,25 @@ * Update repository's hgrc * @param r_name name of the repository to update hgrc for * @param hgrc_data array representing new hgrc file - * @param ofl_lock_hgrc (updated by reference) the current optimistic file lock value * @return status code */ - function update_repository($r_name, $hgrc_data, &$ofl_lock_hgrc) + function update_repository($r_name, $hgrc_data) { if(!$this->can_update($r_name)) { return HGPHP_ERR_PERM_USR; } - - return $this->_ci->hgconf2ini->setHGRC($r_name, $hgrc_data, $ofl_lock_hgrc); + $this->_ci->hgconf2ini->register_OFL($this->_ofl_lock_hgrc); + return $this->_ci->hgconf2ini->setHGRC($r_name, $hgrc_data); } /** * delete_repository * Deletes a repository from the file system and unregisters it from hgweb.config * @param r_name name of the repo to delete permanently - * @param $ofl_lock_hgwebconf (updated by reference) the current optimistic file lock value * @return status code */ - function delete_repository($r_name, &$ofl_lock_hgwebconf) + function delete_repository($r_name) { if(!$this->can_delete($r_name)) { @@ -189,8 +208,7 @@ } $del_status = HGPHP_OK; - $ofl_dummylock_hgwebconf = ''; - $lsdir = $this->_ci->hgconf2ini->getHgWebDirCollections($ofl_dummylock_hgwebconf); // don't want to update lock yet + $lsdir = $this->_ci->hgconf2ini->getHgWebDirCollections(); // simplifies repo list into array where name is both key and value // this is how hgweb.config wants it @@ -207,7 +225,8 @@ // edit the directory unset($existingdir[$r_name]); // remove hgweb.config - $del_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir, $ofl_lock_hgwebconf); + $this->_ci->hgconf2ini->register_OFL($this->_ofl_lock_hgweb); + $del_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir); // remove from hgweb.config if($del_status == HGPHP_OK) @@ -216,6 +235,7 @@ if($lsdir[$r_name]['status'] != HGPHP_REPO_STATUS_MISSING) { // unregister hgrc from transaction manager to keep index small + $this->_ci->hgconf2ini->register_OFL($this->_ofl_lock_hgrc); $del_status = $this->_ci->hgconf2ini->unlinkHGRC($r_name); if($del_status == HGPHP_OK) @@ -236,17 +256,16 @@ * stat_repository * Returns the HGRC represented as an array for the specified repository * @param r_name name of the project whose hgrc to retrieve - * @param ofl_lock_hgrc (updated by reference) the current optimistic file lock value will be updated * @return array representing hgrc or status code */ - function stat_repository($r_name, &$ofl_lock_hgrc) + function stat_repository($r_name) { if(!$this->can_view($r_name)) { return HGPHP_ERR_PERM_USR; } - - return $this->_ci->hgconf2ini->getHGRC($r_name, $ofl_lock_hgrc); + $this->_ci->hgconf2ini->register_OFL($this->_ofl_lock_hgrc); + return $this->_ci->hgconf2ini->getHGRC($r_name); } @@ -301,10 +320,9 @@ * create_repository_dir * Creates a whole repository directory, with hgrc * @param r_name name of repository to create directory for - * @param ofl_lock_hgrc (updated by reference) the current optimistic file lock value will be updated * @return status code */ - function create_repository_dir($r_name, &$ofl_lock_hgrc) + function create_repository_dir($r_name) { if(!$this->can_create($r_name)) { @@ -317,7 +335,8 @@ if($create_status == TRUE) { // create hgrc - $create_status = $this->_ci->hgconf2ini->touchHGRC($r_name, $ofl_lock); + $this->_ci->hgconf2ini->register_OFL($this->_ofl_lock_hgrc); + $create_status = $this->_ci->hgconf2ini->touchHGRC($r_name); } else {