##// END OF EJS Templates
scm: subversion: code clean up model....
Toshi MARUYAMA -
r5633:fa5f4ff77a7c
parent child
Show More
@@ -1,16 +1,16
1 # redMine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -91,23 +91,23 class Repository::Cvs < Repository
91 # convert rev to revision. CVS can't handle changesets here
91 # convert rev to revision. CVS can't handle changesets here
92 diff=[]
92 diff=[]
93 changeset_from = changesets.find_by_revision(rev)
93 changeset_from = changesets.find_by_revision(rev)
94 if rev_to.to_i > 0
94 if rev_to.to_i > 0
95 changeset_to = changesets.find_by_revision(rev_to)
95 changeset_to = changesets.find_by_revision(rev_to)
96 end
96 end
97 changeset_from.changes.each() do |change_from|
97 changeset_from.changes.each() do |change_from|
98 revision_from = nil
98 revision_from = nil
99 revision_to = nil
99 revision_to = nil
100 if path.nil? || (change_from.path.starts_with? scm.with_leading_slash(path))
100 if path.nil? || (change_from.path.starts_with? scm.with_leading_slash(path))
101 revision_from = change_from.revision
101 revision_from = change_from.revision
102 end
102 end
103 if revision_from
103 if revision_from
104 if changeset_to
104 if changeset_to
105 changeset_to.changes.each() do |change_to|
105 changeset_to.changes.each() do |change_to|
106 revision_to=change_to.revision if change_to.path==change_from.path
106 revision_to = change_to.revision if change_to.path == change_from.path
107 end
107 end
108 end
108 end
109 unless revision_to
109 unless revision_to
110 revision_to=scm.get_previous_revision(revision_from)
110 revision_to = scm.get_previous_revision(revision_from)
111 end
111 end
112 file_diff = scm.diff(change_from.path, revision_from, revision_to)
112 file_diff = scm.diff(change_from.path, revision_from, revision_to)
113 diff = diff + file_diff unless file_diff.nil?
113 diff = diff + file_diff unless file_diff.nil?
@@ -121,8 +121,8 class Repository::Cvs < Repository
121 # natively cvs doesn't provide any kind of changesets,
121 # natively cvs doesn't provide any kind of changesets,
122 # there is only a revision per file.
122 # there is only a revision per file.
123 # we now take a guess using the author, the commitlog and the commit-date.
123 # we now take a guess using the author, the commitlog and the commit-date.
124
124
125 # last one is the next step to take. the commit-date is not equal for all
125 # last one is the next step to take. the commit-date is not equal for all
126 # commits in one changeset. cvs update the commit-date when the *,v file was touched. so
126 # commits in one changeset. cvs update the commit-date when the *,v file was touched. so
127 # we use a small delta here, to merge all changes belonging to _one_ changeset
127 # we use a small delta here, to merge all changes belonging to _one_ changeset
128 time_delta = 10.seconds
128 time_delta = 10.seconds
@@ -131,7 +131,7 class Repository::Cvs < Repository
131 tmp_rev_num = 1
131 tmp_rev_num = 1
132 scm.revisions('', fetch_since, nil, :log_encoding => repo_log_encoding) do |revision|
132 scm.revisions('', fetch_since, nil, :log_encoding => repo_log_encoding) do |revision|
133 # only add the change to the database, if it doen't exists. the cvs log
133 # only add the change to the database, if it doen't exists. the cvs log
134 # is not exclusive at all.
134 # is not exclusive at all.
135 tmp_time = revision.time.clone
135 tmp_time = revision.time.clone
136 unless changes.find_by_path_and_revision(
136 unless changes.find_by_path_and_revision(
137 scm.with_leading_slash(revision.paths[0][:path]),
137 scm.with_leading_slash(revision.paths[0][:path]),
@@ -147,7 +147,7 class Repository::Cvs < Repository
147 :comments => cmt
147 :comments => cmt
148 }
148 }
149 )
149 )
150 # create a new changeset....
150 # create a new changeset....
151 unless cs
151 unless cs
152 # we use a temporaray revision number here (just for inserting)
152 # we use a temporaray revision number here (just for inserting)
153 # later on, we calculate a continous positive number
153 # later on, we calculate a continous positive number
@@ -157,7 +157,7 class Repository::Cvs < Repository
157 cs = Changeset.create(:repository => self,
157 cs = Changeset.create(:repository => self,
158 :revision => "tmp#{tmp_rev_num}",
158 :revision => "tmp#{tmp_rev_num}",
159 :scmid => scmid,
159 :scmid => scmid,
160 :committer => revision.author,
160 :committer => revision.author,
161 :committed_on => tmp_time,
161 :committed_on => tmp_time,
162 :comments => revision.message)
162 :comments => revision.message)
163 tmp_rev_num += 1
163 tmp_rev_num += 1
@@ -179,7 +179,7 class Repository::Cvs < Repository
179 )
179 )
180 end
180 end
181 end
181 end
182
182
183 # Renumber new changesets in chronological order
183 # Renumber new changesets in chronological order
184 changesets.find(
184 changesets.find(
185 :all,
185 :all,
General Comments 0
You need to be logged in to leave comments. Login now