@url http://wiki.erazor-zone.de/wiki:projects:php:dokuwiki:plugins:darcs @date 2006.03.19 */ class Darcs_Repository { var $patch_list=array(); var $patch_count=0; var $darcs_bin='darcs'; var $last_ec; var $last_cmd; var $repos_dir; var $stdout=array(); function set_repository($path) { if (!is_dir($path)) { $this->last_ec=-1; return -1; } $this->repos_dir=$path; } function get_patches() { $retval=0; $this->stdout=array(); /* $ darcs pull --dry-run --all -quiet 0:Would pull the following changes: 1:Sat Aug 27 17:48:13 UTC 2005 Andreas Gohr 2: * index lookup function added 4: description 5: 6:Making no changes: this is a dry run. */ chdir($this->repos_dir); $this->last_cmd=$this->darcs_bin.' pull --dry-run --all --quiet 2>&1'; exec($this->last_cmd,&$this->stdout,&$this->retval); reset($this->stdout); next($this->stdout); $this->patch_count=0; $this->patch_list=array(); $stdoutStr=implode("\n",$this->stdout); $myRegEx='/((\w+ \w+ [ 0-9]{1,2} [0-9]{2}:[0-9]{2}:[0-9]{2} \w{2,4} [0-9]{4}) (.+)\n'. '( \* (.+)\n)?'. '( .+(\n .+)*)?)+/'; preg_match_all($myRegEx,$stdoutStr,$found,PREG_SET_ORDER); foreach($found as $item) { $cPatch=&$this->patch_list[$this->patch_count]; $cPatch['date']=$item[2]; $cPatch['author']=$item[3]; $cPatch['name']=$item[5]; $cPatch['description']=$item[6]; $this->patch_count++; } return $this->retval; } function apply_patches() { $this->stdout=array(); chdir($this->repos_dir); $this->last_cmd=$this->darcs_bin.' pull --all --quiet 2>&1'; exec($this->last_cmd,&$this->stdout,&$this->retval); return $this->retval; } function darcs_check($options='') { $this->stdout=array(); chdir($this->repos_dir); $this->last_cmd=$this->darcs_bin.' check 2>&1'; exec($this->last_cmd,&$this->stdout,&$this->retval); return $this->retval; } function darcs_get($options='') { $this->stdout=array(); chdir($this->repos_dir); $this->last_cmd=$this->darcs_bin.' get '.$options.' 2>&1'; exec($this->last_cmd,&$this->stdout,&$this->retval); return $this->retval; } }