From 7aaa538fd9cb34b88c037a7d03a5351c1e2c852e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 12 Apr 2008 17:13:17 +0000 Subject: [PATCH] Fixed: error when browsing an empty Mercurial repository (#1046). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1343 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/repository/mercurial.rb | 4 +++- lib/redmine/scm/adapters/mercurial_adapter.rb | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb index b183c15a73..18cbc9495a 100644 --- a/app/models/repository/mercurial.rb +++ b/app/models/repository/mercurial.rb @@ -58,7 +58,9 @@ class Repository::Mercurial < Repository # latest revision found in database db_revision = latest_changeset ? latest_changeset.revision.to_i : -1 # latest revision in the repository - scm_revision = scm_info.lastrev.identifier.to_i + latest_revision = scm_info.lastrev + return if latest_revision.nil? + scm_revision = latest_revision.identifier.to_i if db_revision < scm_revision logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug? identifier_from = db_revision + 1 diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index b92c88646e..72db723ba9 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -105,7 +105,8 @@ module Redmine line_feeds += 1 if line.chomp.empty? end end - revisions << build_revision_from_changeset(changeset) + # Add the last changeset if there is one left + revisions << build_revision_from_changeset(changeset) if changeset[:date] end return nil if $? && $?.exitstatus != 0 revisions