From 70e8d1242032c410aa3033b34cbd2f5cac3376c0 Mon Sep 17 00:00:00 2001 From: Thomas Keller Date: Wed, 17 Nov 2010 01:53:17 +0100 Subject: [PATCH] Output the branch a particular commit is on; this is easy for mercurial and monotone, but slightly harder till impossible to do properly for git and svn. Please review and eventually adapt the code to make it work better (partially fixes issue 450) --- src/IDF/Scm/Git.php | 2 ++ src/IDF/Scm/Mercurial.php | 3 +++ src/IDF/Scm/Monotone.php | 12 +++++++----- src/IDF/Scm/Svn.php | 1 + src/IDF/templates/idf/source/commit.html | 3 +++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index 8cae0be..83a29b0 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -436,6 +436,8 @@ class IDF_Scm_Git extends IDF_Scm $out = self::parseLog($out); $out[0]->changes = ''; } + + $out[0]['branch'] = $this->inBranches($commit, null); return $out[0]; } diff --git a/src/IDF/Scm/Mercurial.php b/src/IDF/Scm/Mercurial.php index 4e51bc2..ad2f383 100644 --- a/src/IDF/Scm/Mercurial.php +++ b/src/IDF/Scm/Mercurial.php @@ -429,6 +429,8 @@ class IDF_Scm_Mercurial extends IDF_Scm $c['author'] = $match[2]; } elseif ($match[1] == 'summary') { $c['title'] = $match[2]; + } elseif ($match[1] == 'branch') { + $c['branch'] = $match[2]; } else { $c[$match[1]] = trim($match[2]); } @@ -443,6 +445,7 @@ class IDF_Scm_Mercurial extends IDF_Scm } } $c['tree'] = !empty($c['commit']) ? trim($c['commit']) : ''; + $c['branch'] = empty($c['branch']) ? 'default' : $c['branch']; $c['full_message'] = !empty($c['full_message']) ? trim($c['full_message']) : ''; $res[] = (object) $c; return $res; diff --git a/src/IDF/Scm/Monotone.php b/src/IDF/Scm/Monotone.php index c48b613..f001236 100644 --- a/src/IDF/Scm/Monotone.php +++ b/src/IDF/Scm/Monotone.php @@ -141,12 +141,12 @@ class IDF_Scm_Monotone extends IDF_Scm public function getArchiveStream($commit, $prefix='repository/') { $revs = $this->_resolveSelector($commit); - // sanity: this should actually not happen, because the + // sanity: this should actually not happen, because the // revision is validated before already if (count($revs) == 0) { return new Pluf_HTTP_Response_NotFound(); } - return new IDF_Scm_Monotone_ZipRender($this->stdio, $revs[0]); + return new IDF_Scm_Monotone_ZipRender($this->stdio, $revs[0]); } /** @@ -174,7 +174,7 @@ class IDF_Scm_Monotone extends IDF_Scm $cache = Pluf_Cache::factory(); $cachekey = 'mtn-plugin-certs-for-rev-' . $rev; $certs = $cache->get($cachekey); - + if ($certs === null) { $out = $this->stdio->exec(array('certs', $rev)); @@ -545,7 +545,7 @@ class IDF_Scm_Monotone extends IDF_Scm if ($stanza[0]['values'][0] != $file) continue; - + $file = $this->_fillFileEntry($stanza); return (object) $file; } @@ -623,7 +623,9 @@ class IDF_Scm_Monotone extends IDF_Scm $res['title'] = $split[0]; $res['full_message'] = (isset($split[1])) ? trim($split[1]) : ''; + $res['branch'] = implode(', ', $certs['branch']); $res['commit'] = $revs[0]; + $res['changes'] = ($getdiff) ? $this->_getDiff($revs[0]) : ''; return (object) $res; @@ -682,7 +684,7 @@ class IDF_Scm_Monotone extends IDF_Scm __("revision %s has no branch cert - cannot start ". "logging from this revision"), $rev )); - } + } $initialBranches = $certs['branch']; } diff --git a/src/IDF/Scm/Svn.php b/src/IDF/Scm/Svn.php index fdbc340..fb770b8 100644 --- a/src/IDF/Scm/Svn.php +++ b/src/IDF/Scm/Svn.php @@ -415,6 +415,7 @@ class IDF_Scm_Svn extends IDF_Scm $res['commit'] = (string) $xml->logentry['revision']; $res['changes'] = ($getdiff) ? $this->getDiff($commit) : ''; $res['tree'] = ''; + $res['branch'] = ''; return (object) $res; } diff --git a/src/IDF/templates/idf/source/commit.html b/src/IDF/templates/idf/source/commit.html index c9c1051..c04ab80 100644 --- a/src/IDF/templates/idf/source/commit.html +++ b/src/IDF/templates/idf/source/commit.html @@ -10,6 +10,9 @@ {trans 'Author:'}{showuser $rcommit.get_author(), $request, $cobject.author} +{trans 'Branch:'}{$cobject.branch} + + {trans 'Commit:'}{$cobject.commit}