diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index 3ddaf5b..c512d4f 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -287,15 +287,12 @@ class IDF_Scm_Git } /** - * Get commit size. - * - * Get the sum of all the added/removed lines and the number of - * affected files. + * Check if a commit is big. * * @param string Commit ('HEAD') - * @return array array(added, removed, affected) + * @return bool The commit is big */ - public function getCommitSize($commit='HEAD') + public function isCommitLarge($commit='HEAD') { $cmd = sprintf('GIT_DIR=%s git log --numstat -1 --pretty=format:%s %s', escapeshellarg($this->repo), @@ -316,7 +313,7 @@ class IDF_Scm_Git $added+=$a; $removed+=$r; } - return array($added, $removed, $affected); + return ($affected > 100 or ($added + $removed) > 20000); } /** diff --git a/src/IDF/Scm/Mercurial.php b/src/IDF/Scm/Mercurial.php index d25a9d7..c059899 100644 --- a/src/IDF/Scm/Mercurial.php +++ b/src/IDF/Scm/Mercurial.php @@ -306,17 +306,14 @@ class IDF_Scm_Mercurial } /** - * Get commit size. - * - * Get the sum of all the added/removed lines and the number of - * affected files. + * Check if a commit is big. * * @param string Commit ('HEAD') - * @return array array(added, removed, affected) + * @return bool The commit is big */ - public function getCommitSize($commit='HEAD') + public function isCommitLarge($commit='HEAD') { - return array(0, 0, 0); + return false; } /** diff --git a/src/IDF/Scm/Svn.php b/src/IDF/Scm/Svn.php index bf7663f..9abf01b 100644 --- a/src/IDF/Scm/Svn.php +++ b/src/IDF/Scm/Svn.php @@ -290,17 +290,25 @@ class IDF_Scm_Svn } /** - * Get commit size. - * - * Get the sum of all the added/removed lines and the number of - * affected files. + * Check if a commit is big. * * @param string Commit ('HEAD') - * @return array array(added, removed, affected) + * @return bool The commit is big */ - public function getCommitSize($commit='HEAD') + public function isCommitLarge($commit='HEAD') { - return array(0, 0, 0); + if (substr($this->repo, 0, 7) != 'file://') { + return false; + } + // We have a locally hosted repository, we can query it with + // svnlook + $repo = substr($this->repo, 7); + $cmd = sprintf('svnlook changed -r %s %s', + escapeshellarg($commit), + escapeshellarg($repo)); + $out = IDF_Scm::shell_exec($cmd); + $lines = preg_split("/\015\012|\015|\012/", $out); + return (count($lines) > 100); } private function getDiff($rev='HEAD') diff --git a/src/IDF/Views/Source.php b/src/IDF/Views/Source.php index bc27896..b08fa25 100644 --- a/src/IDF/Views/Source.php +++ b/src/IDF/Views/Source.php @@ -225,8 +225,7 @@ class IDF_Views_Source } $title = sprintf(__('%s Commit Details'), (string) $request->project); $page_title = sprintf(__('%s Commit Details - %s'), (string) $request->project, $commit); - $size = $scm->getCommitSize($commit); - $large = ($size[2] > 100 or ($size[0] + $size[1]) > 20000); + $large = $scm->isCommitLarge($commit); $cobject = $scm->getCommit($commit, !$large); $rcommit = IDF_Commit::getOrAdd($cobject, $request->project); $diff = new IDF_Diff($cobject->changes);