<?php
require_once 'remotedir.php';
require_once 'localdir.php';
class Mercurial
{
protected $remote;
protected $local;
public function __construct($server, $tip, $destination)
{
$this->remote = new RemoteDir ($server, $tip = 'tip');
$this->local = new LocalDir($destination);
}
public function GetLocal ()
{
return $this->local;
}
public function GetRemote ()
{
return $this->remote;
}
public function chdir ($dir)
{
$this->local->chdir($dir);
$this->remote->chdir($dir);
}
public function download ($file)
{
$data = $this->remote->get_content($file);
return $data !== false && $this->local->set_content($file, $data);
}
public function install ($directory)
{
$directories = array('/');
while (count ($directories))
{
$dir = array_pop ($directories);
$this->remote->chdir ($dir);
$files = $this->remote->list_dir ();
foreach ($files as $file)
{
if ($file == '..')
{
continue;
}
if ($this->remote->isDir($file))
{
array_push($directories, $dir . $file);
echo 'DIR : ' . $file . '<br />';
}
else
{
echo 'FILE : ' . $file . '<br />';
}
}
}
}
}