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