aboutsummaryrefslogtreecommitdiff
path: root/src/phorkie/File.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2012-04-17 19:15:54 +0200
committerChristian Weiske <cweiske@cweiske.de>2012-04-17 19:15:54 +0200
commit39bd200baed00b5b63cc62ce947ef708710ac81c (patch)
tree7bd8ca92f8a76f944614cb83246de9efd8a1d2fd /src/phorkie/File.php
parentc5544ea6607e49bd5f3cceecd59903687e8b1654 (diff)
downloadphorkie-39bd200baed00b5b63cc62ce947ef708710ac81c.tar.gz
phorkie-39bd200baed00b5b63cc62ce947ef708710ac81c.zip
revision display support
Diffstat (limited to 'src/phorkie/File.php')
-rw-r--r--src/phorkie/File.php21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/phorkie/File.php b/src/phorkie/File.php
index 53925ee..3c6c56d 100644
--- a/src/phorkie/File.php
+++ b/src/phorkie/File.php
@@ -4,7 +4,7 @@ namespace phorkie;
class File
{
/**
- * Full path to the file
+ * Path to the file, relative to repository work directory
*
* @var string
*/
@@ -17,6 +17,11 @@ class File
*/
public $repo;
+ /**
+ * Commit revision this file is at
+ */
+ public $hash;
+
public function __construct($path, Repository $repo = null)
{
$this->path = $path;
@@ -30,7 +35,7 @@ class File
*/
public function getFilename()
{
- return basename($this->path);
+ return $this->path;
}
/**
@@ -38,9 +43,9 @@ class File
*
* @return string
*/
- public function getPath()
+ public function getFullPath()
{
- return $this->path;
+ return $this->repo->workDir . '/' . $this->path;
}
/**
@@ -55,7 +60,13 @@ class File
public function getContent()
{
- return file_get_contents($this->path);
+ if ($this->repo->hash) {
+ return $this->repo->getVc()->getCommand('show')
+ ->addArgument($this->repo->hash . ':' . $this->path)
+ ->execute();
+ }
+
+ return file_get_contents($this->getFullPath());
}
public function getRenderedContent(Tool_Result $res = null)