@@ -51,29 +51,35 class Repository::Mercurial < Repository | |||
|
51 | 51 | scm_info = scm.info |
|
52 | 52 | if scm_info |
|
53 | 53 | # latest revision found in database |
|
54 |
db_revision = latest_changeset ? latest_changeset.revision : |
|
|
54 | db_revision = latest_changeset ? latest_changeset.revision.to_i : -1 | |
|
55 | 55 | # latest revision in the repository |
|
56 | 56 | scm_revision = scm_info.lastrev.identifier.to_i |
|
57 | ||
|
58 | unless changesets.find_by_revision(scm_revision) | |
|
59 | revisions = scm.revisions('', db_revision, nil) | |
|
60 | transaction do | |
|
61 | revisions.reverse_each do |revision| | |
|
62 | changeset = Changeset.create(:repository => self, | |
|
63 | :revision => revision.identifier, | |
|
64 | :scmid => revision.scmid, | |
|
65 | :committer => revision.author, | |
|
66 | :committed_on => revision.time, | |
|
67 |
|
|
|
68 | ||
|
69 | revision.paths.each do |change| | |
|
70 | Change.create(:changeset => changeset, | |
|
71 |
: |
|
|
72 | :path => change[:path], | |
|
73 | :from_path => change[:from_path], | |
|
74 | :from_revision => change[:from_revision]) | |
|
57 | if db_revision < scm_revision | |
|
58 | logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug? | |
|
59 | identifier_from = db_revision + 1 | |
|
60 | while (identifier_from <= scm_revision) | |
|
61 | # loads changesets by batches of 100 | |
|
62 | identifier_to = [identifier_from + 99, scm_revision].min | |
|
63 | revisions = scm.revisions('', identifier_from, identifier_to, :with_paths => true) | |
|
64 | transaction do | |
|
65 | revisions.each do |revision| | |
|
66 | changeset = Changeset.create(:repository => self, | |
|
67 | :revision => revision.identifier, | |
|
68 | :scmid => revision.scmid, | |
|
69 | :committer => revision.author, | |
|
70 | :committed_on => revision.time, | |
|
71 | :comments => revision.message) | |
|
72 | ||
|
73 | revision.paths.each do |change| | |
|
74 | Change.create(:changeset => changeset, | |
|
75 | :action => change[:action], | |
|
76 | :path => change[:path], | |
|
77 | :from_path => change[:from_path], | |
|
78 | :from_revision => change[:from_revision]) | |
|
79 | end | |
|
75 | 80 | end |
|
76 | end | |
|
81 | end unless revisions.nil? | |
|
82 | identifier_from = identifier_to + 1 | |
|
77 | 83 | end |
|
78 | 84 | end |
|
79 | 85 | end |
@@ -71,7 +71,11 module Redmine | |||
|
71 | 71 | def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) |
|
72 | 72 | revisions = Revisions.new |
|
73 | 73 | cmd = "#{HG_BIN} -v -R #{target('')} log" |
|
74 | cmd << " -r #{identifier_from.to_i}:" if identifier_from | |
|
74 | if identifier_from && identifier_to | |
|
75 | cmd << " -r #{identifier_from.to_i}:#{identifier_to.to_i}" | |
|
76 | elsif identifier_from | |
|
77 | cmd << " -r #{identifier_from.to_i}:" | |
|
78 | end | |
|
75 | 79 | cmd << " --limit #{options[:limit].to_i}" if options[:limit] |
|
76 | 80 | shellout(cmd) do |io| |
|
77 | 81 | changeset = {} |
General Comments 0
You need to be logged in to leave comments.
Login now