svn_command_helper 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/svn_command_helper.rb +28 -16
- data/lib/svn_command_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a04d1ffee7008227fc5be923d5bbde0a425a9e8
|
|
4
|
+
data.tar.gz: cebf87d6b3a2b3ca7e00511984b379cd9f97a11e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6264f9c979f7e17a225f0ea5ca99c314a70da37dd27cae624cf2f98849ade586ce93cf69c7c9807e0ceefb7fa8c49a038906319f4ffc5b9e58b063f9f1990ad7
|
|
7
|
+
data.tar.gz: 8fa7b2f1870ece39af35f2e8c13a3185dbe215a07e0ad7587d654b2c3e64fcd31c4f6bd17195b185cf8238950eeaf1a025f19166ef1c23ed822810e6deb8529d
|
data/lib/svn_command_helper.rb
CHANGED
|
@@ -139,12 +139,13 @@ module SvnCommandHelper
|
|
|
139
139
|
# @param [path string like] path target path
|
|
140
140
|
# @param [Integer] depth --set-depth for only new updated dirs
|
|
141
141
|
# @param [Boolean] exist_path_update middle path update flag
|
|
142
|
-
|
|
142
|
+
# @param [String] root working copy root path
|
|
143
|
+
def update_deep(path, depth = nil, exist_path_update = true, root: nil)
|
|
143
144
|
exist_path = path
|
|
144
145
|
until File.exist?(exist_path)
|
|
145
146
|
exist_path = File.dirname(exist_path)
|
|
146
147
|
end
|
|
147
|
-
root = Pathname.new(Svn.working_copy_root_path(exist_path))
|
|
148
|
+
root = Pathname.new(root || Svn.working_copy_root_path(exist_path))
|
|
148
149
|
end_path = Pathname.new(path.to_s).expand_path
|
|
149
150
|
parents = [end_path]
|
|
150
151
|
while parents.first != root
|
|
@@ -164,8 +165,9 @@ module SvnCommandHelper
|
|
|
164
165
|
# @param [Integer] end_rev end revision
|
|
165
166
|
# @param [String] from_uri from uri
|
|
166
167
|
# @param [String] to_path to local path
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
# @param [String] extra extra options
|
|
169
|
+
def merge1(start_rev, end_rev, from_uri, to_path = ".", extra = "")
|
|
170
|
+
safe_merge merge1_command(start_rev, end_rev, from_uri, to_path, extra)
|
|
169
171
|
end
|
|
170
172
|
|
|
171
173
|
# svn merge -r start_rev:end_rev from_uri to_path --dry-run
|
|
@@ -173,8 +175,9 @@ module SvnCommandHelper
|
|
|
173
175
|
# @param [Integer] end_rev end revision
|
|
174
176
|
# @param [String] from_uri from uri
|
|
175
177
|
# @param [String] to_path to local path
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
# @param [String] extra extra options
|
|
179
|
+
def merge1_dry_run(start_rev, end_rev, from_uri, to_path = ".", extra = "")
|
|
180
|
+
merge_dry_run merge1_command(start_rev, end_rev, from_uri, to_path, extra)
|
|
178
181
|
end
|
|
179
182
|
|
|
180
183
|
# "svn merge -r start_rev:end_rev from_uri to_path"
|
|
@@ -182,9 +185,10 @@ module SvnCommandHelper
|
|
|
182
185
|
# @param [Integer] end_rev end revision
|
|
183
186
|
# @param [String] from_uri from uri
|
|
184
187
|
# @param [String] to_path to local path
|
|
188
|
+
# @param [String] extra extra options
|
|
185
189
|
# @param [Boolean] dry_run --dry-run
|
|
186
|
-
def merge1_command(start_rev, end_rev, from_uri, to_path = ".", dry_run: false)
|
|
187
|
-
"svn merge -r #{start_rev}:#{end_rev} #{from_uri} #{to_path} #{dry_run ? "--dry-run" : ""}"
|
|
190
|
+
def merge1_command(start_rev, end_rev, from_uri, to_path = ".", extra = "", dry_run: false)
|
|
191
|
+
"svn merge -r #{start_rev}:#{end_rev} #{from_uri} #{to_path} #{extra} #{dry_run ? "--dry-run" : ""}"
|
|
188
192
|
end
|
|
189
193
|
|
|
190
194
|
# merge after dry-run conflict check
|
|
@@ -203,7 +207,7 @@ module SvnCommandHelper
|
|
|
203
207
|
# @param [String] command svn merge full command
|
|
204
208
|
def merge_dry_run(command)
|
|
205
209
|
cap("#{command} --dry-run")
|
|
206
|
-
.each_line.map(&:chomp).reject {|line| line
|
|
210
|
+
.each_line.map(&:chomp).reject {|line| line[4] != " "}
|
|
207
211
|
.map {|line| OpenStruct.new({status: line[0...4], path: line[5..-1]})}
|
|
208
212
|
end
|
|
209
213
|
|
|
@@ -336,13 +340,17 @@ module SvnCommandHelper
|
|
|
336
340
|
Dir.mktmpdir do |dir|
|
|
337
341
|
Dir.chdir(dir) do
|
|
338
342
|
sys "svn checkout --depth empty #{transaction.to_base} ."
|
|
343
|
+
# なくてもエラーにならないので全部update
|
|
344
|
+
sys "svn update --set-depth infinity #{transactions.map(&:file).join(' ')}"
|
|
339
345
|
unless only_from_transactions.empty?
|
|
340
346
|
sys "svn copy --parents #{only_from_transactions.map(&:from).join(' ')} ."
|
|
341
347
|
end
|
|
342
|
-
sys "svn update --set-depth infinity #{to_exist_transactions.map(&:file).join(' ')}"
|
|
343
348
|
to_exist_transactions.each do |_transaction|
|
|
344
|
-
|
|
345
|
-
|
|
349
|
+
begin
|
|
350
|
+
Svn.merge1(1, "HEAD", _transaction.from, _transaction.file, "--accept theirs-full")
|
|
351
|
+
rescue
|
|
352
|
+
sys "svn export --force #{_transaction.from} #{_transaction.file}"
|
|
353
|
+
end
|
|
346
354
|
end
|
|
347
355
|
Svn.commit(message, ".")
|
|
348
356
|
end
|
|
@@ -361,15 +369,19 @@ module SvnCommandHelper
|
|
|
361
369
|
Dir.mktmpdir do |dir|
|
|
362
370
|
Dir.chdir(dir) do
|
|
363
371
|
sys "svn checkout --depth empty #{base_uri} ."
|
|
372
|
+
root = Svn.working_copy_root_path(".")
|
|
364
373
|
transactions.each do |transaction|
|
|
365
374
|
relative_to = transaction.relative_to(base_uri)
|
|
366
375
|
|
|
367
376
|
if transaction.to_exist? # toがある場合マージ
|
|
368
|
-
Svn.update_deep(relative_to, "empty", false)
|
|
369
|
-
|
|
370
|
-
|
|
377
|
+
Svn.update_deep(relative_to, "empty", false, root: root)
|
|
378
|
+
begin
|
|
379
|
+
Svn.merge1(1, "HEAD", transaction.from, relative_to, "--accept theirs-full")
|
|
380
|
+
rescue
|
|
381
|
+
sys "svn export --force #{transaction.from} #{relative_to}"
|
|
382
|
+
end
|
|
371
383
|
else # toがない場合コピー
|
|
372
|
-
Svn.update_deep(File.dirname(relative_to), "empty", false) # mkpath的な なくてもエラーにはならないので
|
|
384
|
+
Svn.update_deep(File.dirname(relative_to), "empty", false, root: root) # mkpath的な なくてもエラーにはならないので
|
|
373
385
|
sys "svn copy --parents #{transaction.from} #{relative_to}"
|
|
374
386
|
end
|
|
375
387
|
end
|