From 3b53ceedcd60fe116e3f2844b0b5b7fd3b0eaa60 Mon Sep 17 00:00:00 2001 From: Thomas Keller Date: Sat, 1 May 2010 01:05:54 +0200 Subject: [PATCH] * Monotone.php (IDF_Scm_Monotone): basic_io values need to be unescaped; implement getChangeLog() * Monotone.php (IDF_Scm_Monotone_Stdio): add support for multiple, equally named options * Source.php, commit.html: split-off the global commit template (which had some separate code already for SVN) and adapt the left blocks for mtn to shorten branch and tag names just like we do everywhere else --- src/IDF/Scm/Monotone.php | 73 +++++++++++++++++-- src/IDF/Views/Source.php | 2 +- src/IDF/templates/idf/source/commit.html | 27 ------- src/IDF/templates/idf/source/git/commit.html | 18 +++++ .../idf/source/mercurial/commit.html | 18 +++++ src/IDF/templates/idf/source/mtn/commit.html | 26 +++++++ src/IDF/templates/idf/source/svn/commit.html | 11 +++ 7 files changed, 142 insertions(+), 33 deletions(-) create mode 100644 src/IDF/templates/idf/source/git/commit.html create mode 100644 src/IDF/templates/idf/source/mercurial/commit.html create mode 100644 src/IDF/templates/idf/source/mtn/commit.html create mode 100644 src/IDF/templates/idf/source/svn/commit.html diff --git a/src/IDF/Scm/Monotone.php b/src/IDF/Scm/Monotone.php index 02287d2..b35c6b4 100644 --- a/src/IDF/Scm/Monotone.php +++ b/src/IDF/Scm/Monotone.php @@ -109,10 +109,16 @@ class IDF_Scm_Monotone_Stdio if (count($options) > 0) { $cmd = "o"; - foreach ($options as $k => $v) + foreach ($options as $k => $vals) { - $cmd .= strlen((string)$k) . ":" . (string)$k; - $cmd .= strlen((string)$v) . ":" . (string)$v; + if (!is_array($vals)) + $vals = array($vals); + + foreach ($vals as $v) + { + $cmd .= strlen((string)$k) . ":" . (string)$k; + $cmd .= strlen((string)$v) . ":" . (string)$v; + } } $cmd .= "e "; } @@ -409,6 +415,15 @@ class IDF_Scm_Monotone extends IDF_Scm ++$valCount; } } + + for ($i = 0; $i <= $valCount; $i++) + { + $stanzaLine['values'][$i] = str_replace( + array("\\\\", "\\\""), + array("\\", "\""), + $stanzaLine['values'][$i] + ); + } } $stanza[] = $stanzaLine; @@ -795,7 +810,7 @@ class IDF_Scm_Monotone extends IDF_Scm return $this->stdio->exec( array("content_diff"), - array("r" => $sources[0], "r" => $targets[0]) + array("r" => array($sources[0], $targets[0])) ); } @@ -873,6 +888,54 @@ class IDF_Scm_Monotone extends IDF_Scm */ public function getChangeLog($commit=null, $n=10) { - throw new Pluf_Exception_NotImplemented(); + $horizont = $this->_resolveSelector($commit); + $initialBranches = array(); + $logs = array(); + + while (!empty($horizont) && $n > 0) + { + if (count($horizont) > 1) + { + $out = $this->stdio->exec(array("toposort") + $horizont); + $horizont = preg_split("/\n/", $out, -1, PREG_SPLIT_NO_EMPTY); + } + + $rev = array_shift($horizont); + $certs = $this->_getCerts($rev); + + // read in the initial branches we should follow + if (count($initialBranches) == 0) + { + $initialBranches = $certs['branch']; + } + + // only add it to our log if it is on one of the initial branches + if (count(array_intersect($initialBranches, $certs['branch'])) > 0) + { + --$n; + + $log = array(); + $log['author'] = implode(", ", $certs['author']); + + $dates = array(); + foreach ($certs['date'] as $date) + $dates[] = gmdate('Y-m-d H:i:s', strtotime($date)); + $log['date'] = implode(', ', $dates); + + $combinedChangelog = implode("\n---\n", $certs['changelog']); + $split = preg_split("/[\n\r]/", $combinedChangelog, 2); + $log['title'] = $split[0]; + $log['full_message'] = (isset($split[1])) ? trim($split[1]) : ''; + + $log['commit'] = $rev; + + $logs[] = (object)$log; + } + + $out = $this->stdio->exec(array("parents", $rev)); + $horizont += preg_split("/\n/", $out, -1, PREG_SPLIT_NO_EMPTY); + } + + return $logs; } } diff --git a/src/IDF/Views/Source.php b/src/IDF/Views/Source.php index 9a4791f..37d9ca9 100644 --- a/src/IDF/Views/Source.php +++ b/src/IDF/Views/Source.php @@ -308,7 +308,7 @@ class IDF_Views_Source $in_branches = $scm->inBranches($cobject->commit, ''); $tags = $scm->getTags(); $in_tags = $scm->inTags($cobject->commit, ''); - return Pluf_Shortcuts_RenderToResponse('idf/source/commit.html', + return Pluf_Shortcuts_RenderToResponse('idf/source/'.$scmConf.'/commit.html', array( 'page_title' => $page_title, 'title' => $title, diff --git a/src/IDF/templates/idf/source/commit.html b/src/IDF/templates/idf/source/commit.html index a3c0f51..c9c1051 100644 --- a/src/IDF/templates/idf/source/commit.html +++ b/src/IDF/templates/idf/source/commit.html @@ -37,33 +37,6 @@ {/if} {/block} -{block context} -{if $scm != 'svn'} -

{trans 'Branches:'}
-{foreach $branches as $branch => $path} -{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)} -{$branch}
-{/foreach} -

-{if $tags} -

{trans 'Tags:'}
-{foreach $tags as $tag => $path} -{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $tag)} -{if $path}{$path}{else}{$tag}{/if}
-{/foreach} -

-{/if} -{else} -
-

{trans 'Revision:'} {$commit}

-

- - -

-
-{/if} -{/block} - {block javascript}