perforce2svn 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +38 -0
- data/LICENSE +23 -0
- data/README.markdown +66 -0
- data/Rakefile +24 -0
- data/bin/perforce2svn +11 -0
- data/lib/VERSION.yml +6 -0
- data/lib/perforce2svn/cli.rb +117 -0
- data/lib/perforce2svn/environment.rb +66 -0
- data/lib/perforce2svn/errors.rb +16 -0
- data/lib/perforce2svn/logging.rb +35 -0
- data/lib/perforce2svn/mapping/analyzer.rb +30 -0
- data/lib/perforce2svn/mapping/branch_mapping.rb +32 -0
- data/lib/perforce2svn/mapping/commands.rb +75 -0
- data/lib/perforce2svn/mapping/help.txt +139 -0
- data/lib/perforce2svn/mapping/lexer.rb +101 -0
- data/lib/perforce2svn/mapping/mapping_file.rb +65 -0
- data/lib/perforce2svn/mapping/operation.rb +8 -0
- data/lib/perforce2svn/mapping/parser.rb +145 -0
- data/lib/perforce2svn/migrator.rb +71 -0
- data/lib/perforce2svn/perforce/commit_builder.rb +159 -0
- data/lib/perforce2svn/perforce/p4_depot.rb +69 -0
- data/lib/perforce2svn/perforce/perforce_file.rb +81 -0
- data/lib/perforce2svn/subversion/svn_repo.rb +156 -0
- data/lib/perforce2svn/subversion/svn_transaction.rb +136 -0
- data/lib/perforce2svn/version_range.rb +43 -0
- data/mjt.map +7 -0
- data/perforce2svn.gemspec +49 -0
- data/spec/integration/hamlet.txt +7067 -0
- data/spec/integration/madmen_icon_bigger.jpg +0 -0
- data/spec/integration/perforce/p4_depot_spec.rb +16 -0
- data/spec/integration/perforce/perforce_file.yml +4 -0
- data/spec/integration/perforce/perforce_file_spec.rb +19 -0
- data/spec/integration/subversion/svn_repo_spec.rb +93 -0
- data/spec/integration/subversion/svn_transaction_spec.rb +112 -0
- data/spec/perforce2svn/cli_spec.rb +61 -0
- data/spec/perforce2svn/mapping/analyzer_spec.rb +41 -0
- data/spec/perforce2svn/mapping/branch_mapping_spec.rb +40 -0
- data/spec/perforce2svn/mapping/lexer_spec.rb +43 -0
- data/spec/perforce2svn/mapping/parser_spec.rb +140 -0
- data/spec/perforce2svn/perforce/commit_builder_spec.rb +74 -0
- data/spec/perforce2svn/version_range_spec.rb +42 -0
- data/spec/spec_helpers.rb +44 -0
- metadata +230 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helpers'
|
2
|
+
require 'perforce2svn/perforce/commit_builder'
|
3
|
+
require 'perforce2svn/mapping/commands'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
module Perforce2Svn::Perforce
|
7
|
+
describe CommitBuilder do
|
8
|
+
before :each do
|
9
|
+
o = OpenStruct.new
|
10
|
+
o.line = 1
|
11
|
+
@mappings = [Perforce2Svn::Mapping::BranchMapping.new(o, "//some/path", "/trunk/project")]
|
12
|
+
@builder = CommitBuilder.new(@mappings)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when building commit objects" do
|
16
|
+
before :each do
|
17
|
+
@commit = @builder.build_from({'change' => 1,
|
18
|
+
'user' => 'gabe',
|
19
|
+
'desc' => "A log\r\ngoes here",
|
20
|
+
'depotFile' => ['//some/path/1', '//no/match'],
|
21
|
+
'action' => ['edit', 'create'],
|
22
|
+
'type' => ['text', 'binary'],
|
23
|
+
'time' => '1266433914',
|
24
|
+
'rev' => ['10', '2']})
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should retrieve the correct time" do
|
28
|
+
@commit.time.to_svn_format.should eql('2010-02-17T19:11:54.000000Z')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should reitrieve the user" do
|
32
|
+
@commit.author.should eql('gabe')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should retrieve the revision" do
|
36
|
+
@commit.revision.should eql(1)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should fix the log message" do
|
40
|
+
@commit.message.should eql("A log\ngoes here")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should filter out the unnecessary files" do
|
44
|
+
@commit.files.size.should eql(1)
|
45
|
+
end
|
46
|
+
|
47
|
+
context "and filling in child file information" do
|
48
|
+
before :each do
|
49
|
+
@file = @commit.files[0]
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should set the file revision" do
|
53
|
+
@file.revision.should eql(10)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should set the file source" do
|
57
|
+
@file.src.should eql('//some/path/1')
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should set the destination" do
|
61
|
+
@file.dest.should eql('/trunk/project/1')
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should set the type" do
|
65
|
+
@file.type.should eql('text')
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should set the action" do
|
69
|
+
@file.action.should eql('edit')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'perforce2svn/version_range'
|
2
|
+
require 'spec_helpers'
|
3
|
+
|
4
|
+
module Perforce2Svn
|
5
|
+
describe "Version Range information" do
|
6
|
+
it "should sync to head when not given a max." do
|
7
|
+
v1 = VersionRange.new(5)
|
8
|
+
v1.should be_synced_to_head
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be able to reset to HEAD, once it is known" do
|
12
|
+
v1 = VersionRange.new(5)
|
13
|
+
v1.reset_to_head(1234)
|
14
|
+
v1.max.should eql(1234)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "can parse the #-# pair from the command line version information" do
|
18
|
+
v1 = VersionRange.build("234:2345")
|
19
|
+
v1.min.should eql(234)
|
20
|
+
v1.max.should eql(2345)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can parse HEAD from the command line version version information" do
|
24
|
+
v1 = VersionRange.build("1234:HEAD")
|
25
|
+
v1.min.should eql(1234)
|
26
|
+
v1.max.should eql(-1)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should fail on weird version input" do
|
30
|
+
attempting { VersionRange.build("a:123")}.should raise_error(Choosy::ValidationError)
|
31
|
+
attempting { VersionRange.build("123:b")}.should raise_error(Choosy::ValidationError)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should not allow negative numbers for the min revision" do
|
35
|
+
attempting { VersionRange.build("-1:123")}.should raise_error(Choosy::ValidationError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not allow negative numbers for the max revision" do
|
39
|
+
attempting { VersionRange.build("1:-4")}.should raise_error(Choosy::ValidationError)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
ENV['RSPEC_RUNNING'] = 'true'
|
5
|
+
|
6
|
+
def attempting(&block)
|
7
|
+
lambda &block
|
8
|
+
end
|
9
|
+
|
10
|
+
def attempting_to(&block)
|
11
|
+
lambda &block
|
12
|
+
end
|
13
|
+
|
14
|
+
class StringIO
|
15
|
+
def readpartial(len)
|
16
|
+
read(len)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module CommitHelper
|
21
|
+
def write(path, text, binary = false)
|
22
|
+
@repo.transaction('gabe', Time.now, "Committing to : #{path}") do |txn|
|
23
|
+
contents = StringIO.new(text)
|
24
|
+
txn.update(path, contents, binary)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
def delete(path)
|
28
|
+
@repo.transaction('gabe', Time.now, "Deleting: #{path}") do |txn|
|
29
|
+
txn.delete(path)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
def symlink(src, dest)
|
33
|
+
@repo.transaction('gabe', Time.now, "Symlinking: #{src} to #{dest}") do |txn|
|
34
|
+
txn.symlink(src, dest)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
def read_in(local_path, mode = nil)
|
38
|
+
mode ||= 'r'
|
39
|
+
f = open(local_path, mode)
|
40
|
+
contents = f.read
|
41
|
+
f.close
|
42
|
+
contents
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,230 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: perforce2svn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 3
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
- 0
|
10
|
+
version: 0.7.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Gabe McArthur
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-03 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: log4r
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 29
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 1
|
33
|
+
- 7
|
34
|
+
version: 1.1.7
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: choosy
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 31
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 4
|
49
|
+
- 8
|
50
|
+
version: 0.4.8
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: mocha
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: autotest
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
type: :development
|
94
|
+
version_requirements: *id005
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: autotest-notification
|
97
|
+
prerelease: false
|
98
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
type: :development
|
108
|
+
version_requirements: *id006
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: ZenTest
|
111
|
+
prerelease: false
|
112
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
hash: 3
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
version: "0"
|
121
|
+
type: :development
|
122
|
+
version_requirements: *id007
|
123
|
+
description: It loads each revision in a Perforce repository sequentially and commits each change into an exist or new or existing Subversion repository. It also handles more complicated operations that may occur after a migration, like adding, deleting, copy, or updating files to make the entire migration functional.
|
124
|
+
email:
|
125
|
+
- madeonamac@gmail.com
|
126
|
+
executables:
|
127
|
+
- perforce2svn
|
128
|
+
extensions: []
|
129
|
+
|
130
|
+
extra_rdoc_files: []
|
131
|
+
|
132
|
+
files:
|
133
|
+
- LICENSE
|
134
|
+
- perforce2svn.gemspec
|
135
|
+
- Rakefile
|
136
|
+
- mjt.map
|
137
|
+
- Gemfile
|
138
|
+
- bin/perforce2svn
|
139
|
+
- README.markdown
|
140
|
+
- lib/perforce2svn/environment.rb
|
141
|
+
- lib/perforce2svn/cli.rb
|
142
|
+
- lib/perforce2svn/version_range.rb
|
143
|
+
- lib/perforce2svn/logging.rb
|
144
|
+
- lib/perforce2svn/migrator.rb
|
145
|
+
- lib/perforce2svn/errors.rb
|
146
|
+
- lib/perforce2svn/perforce/p4_depot.rb
|
147
|
+
- lib/perforce2svn/perforce/commit_builder.rb
|
148
|
+
- lib/perforce2svn/perforce/perforce_file.rb
|
149
|
+
- lib/perforce2svn/mapping/mapping_file.rb
|
150
|
+
- lib/perforce2svn/mapping/commands.rb
|
151
|
+
- lib/perforce2svn/mapping/lexer.rb
|
152
|
+
- lib/perforce2svn/mapping/parser.rb
|
153
|
+
- lib/perforce2svn/mapping/operation.rb
|
154
|
+
- lib/perforce2svn/mapping/analyzer.rb
|
155
|
+
- lib/perforce2svn/mapping/branch_mapping.rb
|
156
|
+
- lib/perforce2svn/mapping/help.txt
|
157
|
+
- lib/perforce2svn/subversion/svn_repo.rb
|
158
|
+
- lib/perforce2svn/subversion/svn_transaction.rb
|
159
|
+
- lib/VERSION.yml
|
160
|
+
- Gemfile.lock
|
161
|
+
- spec/integration/hamlet.txt
|
162
|
+
- spec/integration/perforce/p4_depot_spec.rb
|
163
|
+
- spec/integration/perforce/perforce_file_spec.rb
|
164
|
+
- spec/integration/perforce/perforce_file.yml
|
165
|
+
- spec/integration/madmen_icon_bigger.jpg
|
166
|
+
- spec/integration/subversion/svn_transaction_spec.rb
|
167
|
+
- spec/integration/subversion/svn_repo_spec.rb
|
168
|
+
- spec/perforce2svn/cli_spec.rb
|
169
|
+
- spec/perforce2svn/perforce/commit_builder_spec.rb
|
170
|
+
- spec/perforce2svn/version_range_spec.rb
|
171
|
+
- spec/perforce2svn/mapping/lexer_spec.rb
|
172
|
+
- spec/perforce2svn/mapping/analyzer_spec.rb
|
173
|
+
- spec/perforce2svn/mapping/branch_mapping_spec.rb
|
174
|
+
- spec/perforce2svn/mapping/parser_spec.rb
|
175
|
+
- spec/spec_helpers.rb
|
176
|
+
has_rdoc: true
|
177
|
+
homepage: http://github.com/gabemc/perforce2svn
|
178
|
+
licenses: []
|
179
|
+
|
180
|
+
post_install_message: |
|
181
|
+
Please be sure to install the p4ruby gem (>= 1.0.9).
|
182
|
+
The gem currently doesn't seem to build without
|
183
|
+
manual intervention. For instance, I had to run:
|
184
|
+
|
185
|
+
ruby install.rb --version 10.2 --platform linux26x86
|
186
|
+
|
187
|
+
Your supported platform may vary.
|
188
|
+
|
189
|
+
Additionally, you will need to install the subversion
|
190
|
+
bindings that come with your platform. On Ubuntu, for
|
191
|
+
instance, you can run:
|
192
|
+
|
193
|
+
apt-get install libsvn-ruby
|
194
|
+
|
195
|
+
The runtime will check that both of these are installed
|
196
|
+
before proceeding.
|
197
|
+
|
198
|
+
rdoc_options: []
|
199
|
+
|
200
|
+
require_paths:
|
201
|
+
- lib
|
202
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
203
|
+
none: false
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
hash: 3
|
208
|
+
segments:
|
209
|
+
- 0
|
210
|
+
version: "0"
|
211
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
|
+
none: false
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
hash: 23
|
217
|
+
segments:
|
218
|
+
- 1
|
219
|
+
- 3
|
220
|
+
- 6
|
221
|
+
version: 1.3.6
|
222
|
+
requirements: []
|
223
|
+
|
224
|
+
rubyforge_project:
|
225
|
+
rubygems_version: 1.6.2
|
226
|
+
signing_key:
|
227
|
+
specification_version: 3
|
228
|
+
summary: Converts a Perforce repository into a Subversion repository
|
229
|
+
test_files: []
|
230
|
+
|