From 0f45e85ce544c0306f714a0341426236f5090d9f Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 19 Mar 2012 19:19:55 -0700 Subject: [PATCH] Silence Mercurial warning for lastmodified query; minor cleanup Summary: See . Commit data may not be available for unpared commits, but we'll raise a warning about $commit_data in that case (the UI correctly handles missing $commit_data). Also some minor cleanup / UI fixes. Test Plan: Browsed around hg / git repos, including unparsed commits. Reviewers: btrahan, killermonk Reviewed By: btrahan CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1961 --- .../git/DiffusionGitLastModifiedQuery.php | 11 +++++------ .../diffusion/query/lastmodified/git/__init__.php | 1 - .../DiffusionMercurialLastModifiedQuery.php | 12 ++++++------ .../query/lastmodified/mercurial/__init__.php | 1 - .../diffusion/view/base/DiffusionView.php | 5 +++-- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/applications/diffusion/query/lastmodified/git/DiffusionGitLastModifiedQuery.php b/src/applications/diffusion/query/lastmodified/git/DiffusionGitLastModifiedQuery.php index be1113dbc9..ed40cb7364 100644 --- a/src/applications/diffusion/query/lastmodified/git/DiffusionGitLastModifiedQuery.php +++ b/src/applications/diffusion/query/lastmodified/git/DiffusionGitLastModifiedQuery.php @@ -1,7 +1,7 @@ getPath()); $hash = trim($hash); - $commit_data = null; - $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( 'repositoryID = %d AND commitIdentifier = %s', $repository->getID(), $hash); + if ($commit) { - $commit_data = id(new PhabricatorRepositoryCommitData())->loadOneWhere( - 'commitID = %d', - $commit->getID()); + $commit_data = $commit->loadCommitData(); + } else { + $commit_data = null; } return array($commit, $commit_data); diff --git a/src/applications/diffusion/query/lastmodified/git/__init__.php b/src/applications/diffusion/query/lastmodified/git/__init__.php index 0f7241f74a..1a30b1b951 100644 --- a/src/applications/diffusion/query/lastmodified/git/__init__.php +++ b/src/applications/diffusion/query/lastmodified/git/__init__.php @@ -8,7 +8,6 @@ phutil_require_module('phabricator', 'applications/diffusion/query/lastmodified/base'); phutil_require_module('phabricator', 'applications/repository/storage/commit'); -phutil_require_module('phabricator', 'applications/repository/storage/commitdata'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/diffusion/query/lastmodified/mercurial/DiffusionMercurialLastModifiedQuery.php b/src/applications/diffusion/query/lastmodified/mercurial/DiffusionMercurialLastModifiedQuery.php index eb3db5521f..3c55063830 100644 --- a/src/applications/diffusion/query/lastmodified/mercurial/DiffusionMercurialLastModifiedQuery.php +++ b/src/applications/diffusion/query/lastmodified/mercurial/DiffusionMercurialLastModifiedQuery.php @@ -1,7 +1,7 @@ execxLocalCommand( 'log --template %s --limit 1 --branch %s --rev %s:0 -- %s', - '{node}\\n', + '{node}', $drequest->getBranch(), $drequest->getCommit(), nonempty(ltrim($path, '/'), '.')); - $hash = trim($hash); $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( 'repositoryID = %d AND commitIdentifier = %s', $repository->getID(), $hash); + if ($commit) { - $commit_data = id(new PhabricatorRepositoryCommitData())->loadOneWhere( - 'commitID = %d', - $commit->getID()); + $commit_data = $commit->loadCommitData(); + } else { + $commit_data = null; } return array($commit, $commit_data); diff --git a/src/applications/diffusion/query/lastmodified/mercurial/__init__.php b/src/applications/diffusion/query/lastmodified/mercurial/__init__.php index 5a187f77c3..7efb7c9aee 100644 --- a/src/applications/diffusion/query/lastmodified/mercurial/__init__.php +++ b/src/applications/diffusion/query/lastmodified/mercurial/__init__.php @@ -8,7 +8,6 @@ phutil_require_module('phabricator', 'applications/diffusion/query/lastmodified/base'); phutil_require_module('phabricator', 'applications/repository/storage/commit'); -phutil_require_module('phabricator', 'applications/repository/storage/commitdata'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/diffusion/view/base/DiffusionView.php b/src/applications/diffusion/view/base/DiffusionView.php index 05a2101d49..53973f0389 100644 --- a/src/applications/diffusion/view/base/DiffusionView.php +++ b/src/applications/diffusion/view/base/DiffusionView.php @@ -1,7 +1,7 @@ getVersionControlSystem()) { case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: - $commit_name = substr($commit, 0, 16); + case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: + $commit_name = substr($commit, 0, 12); break; default: $commit_name = $commit;