svn_command_helper 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ed319daca7d4f6456d4adedafb1f8b8ea01fd85
4
- data.tar.gz: 685413932344a4a488fcf3054ec98942fc3157a9
3
+ metadata.gz: 8a04d1ffee7008227fc5be923d5bbde0a425a9e8
4
+ data.tar.gz: cebf87d6b3a2b3ca7e00511984b379cd9f97a11e
5
5
  SHA512:
6
- metadata.gz: 738a56bbb2526afc473bb3f6d5f1b0b9c07b1d9c5394db8e763a8e9b5b6c8abb36f6159b2225b171dab4c5544372b5530a8a8d3d0bff4f30f35fb4aa0849ba6a
7
- data.tar.gz: ecaed0d02d0e3f097ee315c5fa4b68548addcf8d5f73657fe7be604e3ce15c72f6db2251a8551e001eddf1d6f035b03664b0b4cca67d20b3697d14ec254045bd
6
+ metadata.gz: 6264f9c979f7e17a225f0ea5ca99c314a70da37dd27cae624cf2f98849ade586ce93cf69c7c9807e0ceefb7fa8c49a038906319f4ffc5b9e58b063f9f1990ad7
7
+ data.tar.gz: 8fa7b2f1870ece39af35f2e8c13a3185dbe215a07e0ad7587d654b2c3e64fcd31c4f6bd17195b185cf8238950eeaf1a025f19166ef1c23ed822810e6deb8529d
@@ -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
- def update_deep(path, depth = nil, exist_path_update = true)
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
- def merge1(start_rev, end_rev, from_uri, to_path = ".")
168
- safe_merge merge1_command(start_rev, end_rev, from_uri, to_path)
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
- def merge1_dry_run(start_rev, end_rev, from_uri, to_path = ".")
177
- merge_dry_run merge1_command(start_rev, end_rev, from_uri, to_path)
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.start_with?('-')}
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
- sys "svn export --force #{_transaction.from} #{_transaction.file}"
345
- sys "svn add --force #{_transaction.file}"
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
- sys "svn export --force #{transaction.from} #{relative_to}"
370
- sys "svn add --force #{relative_to}"
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
@@ -1,4 +1,4 @@
1
1
  module SvnCommandHelper
2
2
  # version
3
- VERSION = "1.2.0"
3
+ VERSION = "1.3.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svn_command_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Narazaka