Class: Subversion::SvnCommand
- Inherits:
-
Console::Command
- Object
- Console::Command
- Subversion::SvnCommand
show all
- Defined in:
- lib/subwrap/svn_command.rb,
lib/subwrap/svn_command.rb,
lib/subwrap/svn_command.rb
Defined Under Namespace
Modules: Add, Browse, Commit, Copy, Diff, EditMessage, EditRevisionProperty, Externalize, ExternalsItems, GetMessage, Help, Import, LocalIgnore, Log, Mkdir, Move, Revisions, SetMessage, ShowOrBrowseRevisions, Status, Update, ViewCommits, WhatsNew
Constant Summary
collapse
- @@user_preferences =
{}
- @@subcommand_list =
This shouldn’t be necessary. Console::Command should allow introspection. But until such time…
[
'each_unadded',
'externals_items', 'externals_outline', 'externals_containers', 'edit_externals', 'externalize',
'ignore', 'edit_ignores',
'revisions',
'get_message', 'set_message', 'edit_message',
'view_commits',
'url',
'repository_root', 'working_copy_root', 'repository_uuid',
'latest_revision',
'delete_svn',
'fix_out_of_date_commit_state'
]
Class Method Summary
collapse
Instance Method Summary
collapse
-
#__debug ⇒ Object
-
#__dry_run ⇒ Object
-
#__except ⇒ Object
(also: #__exclude)
Usually most Subversion commands are recursive and all-inclusive.
-
#__no_color ⇒ Object
-
#__print_commands ⇒ Object
(also: #__show_commands, #_V, #__Verbose)
-
#add(*args) ⇒ Object
-
#add_all_unadded ⇒ Object
—————————————————————————————————————————–.
-
#browse(directory = './') ⇒ Object
-
#commit(*args) ⇒ Object
-
#copy(*args) ⇒ Object
-
#default ⇒ Object
This is here solely to allow subcommandless commands like ‘svn –version`.
-
#delete_svn(directory = './') ⇒ Object
—————————————————————————————————————————– Cause a working copy to cease being a working copy.
-
#diff(*directories) ⇒ Object
-
#each_unadded(*args) ⇒ Object
—————————————————————————————————————————– Goes through each “unadded” file (each file reporting a status of ?
) reported by svn status
and asks you what you want to do with them (add, delete, or ignore).
-
#edit_externals(directory = nil) ⇒ Object
-
#edit_ignores(directory = './') ⇒ Object
Example: svn edit_ignores tmp/sessions/.
-
#edit_message(directory = './') ⇒ Object
-
#edit_property(property_name, directory = './') ⇒ Object
-
#edit_revision_property(property_name, directory = './') ⇒ Object
-
#externalize(repo_path, as_arg = nil) ⇒ Object
-
#externals_containers(directory = "./") ⇒ Object
Lists directories that have the svn:externals property set.
-
#externals_items(directory = "./") ⇒ Object
-
#externals_outline(directory = "./") ⇒ Object
For every directory that has the svn:externals property set, this prints out the container name and then lists the contents of its svn:externals property (dir, URL) as a bulleted list.
-
#fix_out_of_date_commit_state(dir) ⇒ Object
A fix for this annoying problem that I seem to come across all too frequentrly: svn: Commit failed (details follow): svn: Your file or directory ‘whatever.rb’ is probably out-of-date.
-
#get_message ⇒ Object
-
#grep ⇒ Object
-
#grep_externals ⇒ Object
-
#grep_log ⇒ Object
-
#help(subcommand = nil) ⇒ Object
-
#ignore(file) ⇒ Object
—————————————————————————————————————————–.
-
#import(*args) ⇒ Object
-
#initialize(*args) ⇒ SvnCommand
constructor
A new instance of SvnCommand.
-
#latest_revision(*args) ⇒ Object
—————————————————————————————————————————–.
-
#local_ignore ⇒ Object
(also: #dont_commit, #pretend_isnt_versioned)
-
#log(*args) ⇒ Object
-
#method_missing(subcommand, *args) ⇒ Object
Any subcommands that we haven’t implemented here will simply be passed on to the built-in svn command.
-
#mkdir(*directories) ⇒ Object
-
#move(*args) ⇒ Object
-
#option_missing(option_name, args) ⇒ Object
-
#play_revisions(directory = './') ⇒ Object
-
#repository_root(*args) ⇒ Object
Returns root repository URL for a working copy.
-
#repository_uuid(*args) ⇒ Object
Returns the UUID for a working copy/URL.
-
#set_message(new_message) ⇒ Object
-
#status(*args) ⇒ Object
-
#under_version_control(*args) ⇒ Object
—————————————————————————————————————————–.
-
#update(*args) ⇒ Object
-
#url(*args) ⇒ Object
—————————————————————————————————————————–.
-
#view_commits(path = "./") ⇒ Object
-
#whats_new(directory = './') ⇒ Object
-
#working_copy_root(*args) ⇒ Object
Returns root/base path for a working copy.
Constructor Details
#initialize(*args) ⇒ SvnCommand
Returns a new instance of SvnCommand.
205
206
207
208
|
# File 'lib/subwrap/svn_command.rb', line 205
def initialize(*args)
@passthrough_options = []
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(subcommand, *args) ⇒ Object
Any subcommands that we haven’t implemented here will simply be passed on to the built-in svn command. :todo: Distinguish between subcommand_missing and method_missing !
Currently, for example, if as isn't defined, this: puts Subversion.externalize(repo_path, {:as => as })
will call method_missing and try to run `svn as`, which of course will fail (without a sensible relevant error)...
I think we should probably just have a separate subcommand_missing, like we already have a separate option_missing !!!
Even a simple type (sss instead of ss) causes trouble... *this* was causing a call to "/usr/bin/svn new_messsage" -- what huh??
def set_message(new_message = nil)
args << new_messsage if new_message
253
254
255
256
|
# File 'lib/subwrap/svn_command.rb', line 253
def method_missing(subcommand, *args)
svn :exec, subcommand, *args
end
|
Class Method Details
.parse_revision_ranges(revisions_array) ⇒ Object
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
|
# File 'lib/subwrap/svn_command.rb', line 947
def SvnCommand.parse_revision_ranges(revisions_array)
revisions_array.map do |item|
case item
when /(\d+):(\d+)/
($1.to_i .. $2.to_i)
when /(\d+)-(\d+)/
($1.to_i .. $2.to_i)
when /(\d+)\.\.(\d+)/
($1.to_i .. $2.to_i)
when /\d+/
item.to_i
else
raise "Item in revisions_array had an unrecognized format: #{item}"
end
end.expand_ranges
end
|
Instance Method Details
217
218
219
|
# File 'lib/subwrap/svn_command.rb', line 217
def __debug
$debug = true
end
|
#__dry_run ⇒ Object
220
221
222
|
# File 'lib/subwrap/svn_command.rb', line 220
def __dry_run
Subversion::dry_run = true
end
|
#__except ⇒ Object
Also known as:
__exclude
Usually most Subversion commands are recursive and all-inclusive. This option adds file exclusion to most of Subversion’s commands. Use this if you want to commit (/add/etc.) everything but a certain file or set of files
svn commit dir1 dir2 --except dir1/not_ready_yet.rb
235
236
237
238
239
|
# File 'lib/subwrap/svn_command.rb', line 235
def __except
end
|
#__no_color ⇒ Object
214
215
216
|
# File 'lib/subwrap/svn_command.rb', line 214
def __no_color
Subversion::color = false
end
|
#__print_commands ⇒ Object
Also known as:
__show_commands, _V, __Verbose
224
225
226
|
# File 'lib/subwrap/svn_command.rb', line 224
def __print_commands
Subversion::print_commands = true
end
|
#add(*args) ⇒ Object
309
310
311
312
|
# File 'lib/subwrap/svn_command.rb', line 309
def add(*args)
svn :exec, 'add', *args
end
|
#add_all_unadded ⇒ Object
1356
1357
1358
|
# File 'lib/subwrap/svn_command.rb', line 1356
def add_all_unadded
raise NotImplementedError
end
|
#browse(directory = './') ⇒ Object
1548
1549
1550
1551
|
# File 'lib/subwrap/svn_command.rb', line 1548
def browse(directory = './')
@interactive = true
show_or_browse_revisions(directory)
end
|
#commit(*args) ⇒ Object
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
# File 'lib/subwrap/svn_command.rb', line 374
def commit(*args)
directory = args.first || './' if @broken || @skip_notification
latest_rev_before_commit = Subversion.latest_revision(directory)
repository_root = Subversion.repository_root(directory)
end
Subversion.print_commands! do
puts svn(:capture, "propset svn:skip_commit_notification_for_next_commit true --revprop -r #{latest_rev_before_commit} #{repository_root}", :prepare_args => false)
end if @skip_notification
svn(:system, 'commit', *(['--force-log'] + args))
puts ''.add_exit_code_error
return if !exit_code.success?
Subversion.print_commands! do
puts svn(:capture, "propset code:broken true --revprop -r #{latest_rev_before_commit + 1}", :prepare_args => false)
end if @broken
if @include_externals
end
end
|
#copy(*args) ⇒ Object
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
|
# File 'lib/subwrap/svn_command.rb', line 723
def copy(*args)
destination = args.pop
if args.length >= 2
sources = args
sources.each do |source|
puts filtered_svn('copy', source, destination)
end
else
svn :exec, 'copy', *(args + [destination])
end
end
|
This is here solely to allow subcommandless commands like ‘svn –version`
258
259
260
|
# File 'lib/subwrap/svn_command.rb', line 258
def default()
svn :exec
end
|
#delete_svn(directory = './') ⇒ Object
Cause a working copy to cease being a working copy
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
|
# File 'lib/subwrap/svn_command.rb', line 1343
def delete_svn(directory = './')
puts "If you continue, all of the following directories/files will be deleted:"
system("find #{directory} -name .svn -type d | xargs -n1 echo")
response = confirm("Do you wish to continue?")
puts
if response == 'y'
system("find #{directory} -name .svn -type d | xargs -n1 rm -r")
end
end
|
#diff(*directories) ⇒ Object
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
|
# File 'lib/subwrap/svn_command.rb', line 506
def diff(*directories)
directories = ['./'] if directories.empty?
puts Subversion.colorized_diff(*(prepare_args(directories)))
begin output = StringIO.new
directories.each do |path|
(Subversion.externals_items(path) || []).each do |item|
diff_output = Subversion.colorized_diff(item).strip
unless diff_output == ""
output.puts item.ljust(100).yellow_on_red.bold
output.puts diff_output
end
end
end
unless output.string == ""
puts (' '*100).yellow.underline
puts " Diff of externals (**don't forget to commit these too!**):".ljust(100, ' ').yellow_on_red.bold.underline
puts output.string
end
end unless @ignore_externals || @non_recursive
end
|
#each_unadded(*args) ⇒ Object
Goes through each “unadded” file (each file reporting a status of ?
) reported by svn status
and asks you what you want to do with them (add, delete, or ignore)
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
|
# File 'lib/subwrap/svn_command.rb', line 966
def each_unadded(*args)
catch :exit do
$ignore_dry_run_option = true
Subversion.each_unadded( Subversion.status(*args) ) do |file|
$ignore_dry_run_option = false
begin
puts( ('-'*100).green )
puts "What do you want to do with '#{file.white.underline}'?".white.bold
begin
if !File.exist?(file)
raise "#{file} doesn't seem to exist -- even though it was reported by svn status"
end
if File.file?(file)
if FileTest.binary_file?(file)
puts "(Binary file -- cannot show preview)".bold
else
puts "File contents:"
contents = File.read(file, bytes_threshold = 5000) || ''
max_lines = 55
contents.lines[0..max_lines].each {|line| puts line}
puts "..." if contents.length >= bytes_threshold end
elsif File.directory?(file)
puts "Directory contains:"
Dir.new(file).reject {|f| ['.','..'].include? f}.each do |f|
puts f
end
else
raise "#{file} is not a file or directory -- what *is* it then???"
end
end
print(
"Add".(:green) + ", " +
"Delete".(:red) + ", " +
"add to " + "svn:".yellow + "Ignore".(:yellow) + " property, " +
"ignore ".yellow + "Contents".(:yellow) + " of directory, " +
"or " + "any other key".white.bold + " to do nothing > "
)
response = ""
response = $stdin.getch.downcase
case response
when 'a'
print "\nAdding... "
Subversion.add file
puts
when 'd'
puts
response = ""
if File.directory?(file)
response = confirm("Are you pretty much " + "SURE".bold + " you want to '" + "rm -rf #{file}".red.bold + "'? ")
else
response = "y"
end
if response == 'y'
print "\nDeleting... "
FileUtils.rm_rf file
puts
else
puts "\nI figured as much!"
end
when 'i'
print "\nIgnoring... "
Subversion.ignore file
puts
else
puts " (Skipping...)"
end
rescue Interrupt
puts "\nGoodbye!"
throw :exit
end
end
end end
|
#edit_externals(directory = nil) ⇒ Object
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
|
# File 'lib/subwrap/svn_command.rb', line 1124
def edit_externals(directory = nil)
catch :exit do
if directory.nil? || !Subversion::ExternalsContainer.new(directory).has_entries?
if directory.nil?
puts "No directory specified. Editing externals for *all* externals dirs..."
directory = "./"
else
puts "Editing externals for *all* externals dirs..."
end
Subversion.externals_containers(directory).each do |external|
puts external.to_s
command = "propedit svn:externals #{external.container_dir}"
begin
response = confirm("Do you want to edit svn:externals for this directory?".black_on_white)
svn :system, command if response == 'y'
rescue Interrupt
puts "\nGoodbye!"
throw :exit
ensure
puts
end
end
puts 'Done'
else
svn :system, "propedit svn:externals #{directory}"
end
end end
|
#edit_ignores(directory = './') ⇒ Object
Example:
svn edit_ignores tmp/sessions/
1237
1238
1239
1240
1241
1242
|
# File 'lib/subwrap/svn_command.rb', line 1237
def edit_ignores(directory = './')
svn :system, "propedit svn:ignore #{directory}"
end
|
#edit_message(directory = './') ⇒ Object
1334
1335
1336
|
# File 'lib/subwrap/svn_command.rb', line 1334
def edit_message(directory = './')
edit_revision_property('svn:log', directory)
end
|
#edit_property(property_name, directory = './') ⇒ Object
1338
1339
|
# File 'lib/subwrap/svn_command.rb', line 1338
def edit_property(property_name, directory = './')
end
|
#edit_revision_property(property_name, directory = './') ⇒ Object
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
|
# File 'lib/subwrap/svn_command.rb', line 1301
def edit_revision_property(property_name, directory = './')
args = ['propedit', '--revprop', property_name, directory]
rev = @revision ? @revision : 'head'
args.concat ['-r', rev]
Subversion.print_commands! do
svn :system, *args
end
value = Subversion::get_revision_property(property_name, rev)
p value
if value == ''
puts
response = confirm("Are you sure you want to delete property #{property_name}".red.bold + "'? ")
puts
if response == 'y'
Subversion.print_commands! do
Subversion::delete_revision_property(property_name, rev)
end
end
end
end
|
#externalize(repo_path, as_arg = nil) ⇒ Object
1171
1172
1173
1174
1175
1176
|
# File 'lib/subwrap/svn_command.rb', line 1171
def externalize(repo_path, as_arg = nil)
Subversion.externalize(repo_path, {:as => as || as_arg})
end
|
#externals_containers(directory = "./") ⇒ Object
Lists directories that have the svn:externals property set.
1117
1118
1119
1120
1121
|
# File 'lib/subwrap/svn_command.rb', line 1117
def externals_containers(directory = "./")
puts Subversion.externals_containers(directory).map { |external|
external.container_dir
}
end
|
#externals_items(directory = "./") ⇒ Object
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
|
# File 'lib/subwrap/svn_command.rb', line 1070
def externals_items(directory = "./")
longest_path_name = 25
externals_structs = Subversion.externals_containers(directory).map do |external|
returning(
external.entries_structs.map do |entry|
Struct.new(:path, :repository_path).new(
File.join(external.container_dir, entry.name).relativize_path,
entry.repository_path
)
end
) do |entries_structs|
longest_path_name =
[
longest_path_name,
entries_structs.map { |entry|
entry.path.size
}.max.to_i
].max
end
end
puts externals_structs.map { |entries_structs|
entries_structs.map { |entry|
entry.path.ljust(longest_path_name + 1) +
(@omit_repository_path ? '' : entry.repository_path)
}
}
puts "(Tip: Also consider using svn externals_outline. Or use the -o/--omit-repository-path option if you just want a list of the paths that are externalled (without the repository URLs that they come from)".magenta unless @omit_repository_path
end
|
#externals_outline(directory = "./") ⇒ Object
For every directory that has the svn:externals property set, this prints out the container name and then lists the contents of its svn:externals property (dir, URL) as a bulleted list
1108
1109
1110
1111
1112
|
# File 'lib/subwrap/svn_command.rb', line 1108
def externals_outline(directory = "./")
puts Subversion.externals_containers(directory).map { |external|
external.to_s.relativize_path
}
end
|
#fix_out_of_date_commit_state(dir) ⇒ Object
A fix for this annoying problem that I seem to come across all too frequentrly:
svn: Commit failed (details follow):
svn: Your file or directory 'whatever.rb' is probably out-of-date
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
# File 'lib/subwrap/svn_command.rb', line 431
def fix_out_of_date_commit_state(dir)
dir = $1 if dir =~ %r|^(.*)/$|
puts Subversion.export("#{dir}", "#{dir}.new"). add_exit_code_error
return if !exit_code.success?
system("mv #{dir} #{dir}.backup") puts ''.add_exit_code_error
return if !exit_code.success?
puts "Restoring #{dir}..."
Subversion.update dir
system("cp -R #{dir}.new/. #{dir}/")
puts Subversion.colorized_diff(dir)
puts "Please check the output of " + "svn st #{dir}.backup".blue.bold + " to check if any files were scheduled for addition. You will need to manually re-add these, as the export will have caused those files to lost their scheduling."
Subversion.print_commands! do
print Subversion.status_lines_filter( Subversion.status("#{dir}.backup") )
print Subversion.status_lines_filter( Subversion.status("#{dir}") )
end
puts
response = confirm("Are you ready to try the commit again now?")
puts
if response == 'y'
puts "Great! Go for it. (I'd do it for you but I don't know what commit command you were trying to execute when the problem occurred.)"
end
puts "Don't forget to " + "rm -rf #{dir}.backup #{dir}.new".blue.bold + " when you are done!"
puts
end
|
#get_message ⇒ Object
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
|
# File 'lib/subwrap/svn_command.rb', line 1254
def get_message()
args = ['propget', '--revprop', 'svn:log']
args.concat ['-r', (revision = @revision ? @revision : 'head')]
puts "Message for r#{Subversion.latest_revision} :" if revision == 'head'
$ignore_dry_run_option = true
puts filtered_svn(*args)
$ignore_dry_run_option = false
end
|
1359
1360
1361
|
# File 'lib/subwrap/svn_command.rb', line 1359
def grep
raise NotImplementedError
end
|
#grep_externals ⇒ Object
1362
1363
1364
|
# File 'lib/subwrap/svn_command.rb', line 1362
def grep_externals
raise NotImplementedError
end
|
1365
1366
1367
|
# File 'lib/subwrap/svn_command.rb', line 1365
def grep_log
raise NotImplementedError
end
|
#help(subcommand = nil) ⇒ Object
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
|
# File 'lib/subwrap/svn_command.rb', line 541
def help(subcommand = nil)
case subcommand
when "externals"
puts %Q{
| externals (ext): Lists all externals in the given working directory.
| usage: externals [PATH]
}.margin
when nil
puts "You are using " +
's'.green.bold + 'u'.cyan.bold + 'b'.magenta.bold + 'w'.white.bold + 'r'.red.bold + 'a'.blue.bold + 'p'.yellow.bold + ' version ' + Project::Version
", a colorful, useful replacement/wrapper for the standard svn command."
puts "subwrap is installed at: " + $0.bold
puts "You may bypass this wrapper by using the full path to svn: " + Subversion.executable.bold
puts
puts Subversion.help(subcommand).gsub(<<End, '')
Subversion is a tool for version control.
For additional information, see http://subversion.tigris.org/
End
puts
puts 'Subcommands added by subwrap (refer to '.green.underline + 'http://subwrap.rubyforge.org/'.white.underline + ' for usage details):'.green.underline
@@subcommand_list.each do |subcommand|
aliases_list = subcommand_aliases_list(subcommand.option_methodize.to_sym)
aliases_list = aliases_list.empty? ? '' : ' (' + aliases_list.join(', ') + ')'
puts ' ' + subcommand + aliases_list
end
else
puts Subversion.help(subcommand)
end
end
|
#ignore(file) ⇒ Object
1231
1232
1233
|
# File 'lib/subwrap/svn_command.rb', line 1231
def ignore(file)
Subversion.ignore(file)
end
|
#import(*args) ⇒ Object
756
757
758
759
|
# File 'lib/subwrap/svn_command.rb', line 756
def import(*args)
p args
svn :exec, 'import', *(args)
end
|
#latest_revision(*args) ⇒ Object
#local_ignore ⇒ Object
Also known as:
dont_commit, pretend_isnt_versioned
1223
1224
1225
|
# File 'lib/subwrap/svn_command.rb', line 1223
def local_ignore
end
|
#log(*args) ⇒ Object
592
593
594
595
|
# File 'lib/subwrap/svn_command.rb', line 592
def log(*args)
puts Subversion.log( prepare_args(args) )
end
|
#mkdir(*directories) ⇒ Object
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
|
# File 'lib/subwrap/svn_command.rb', line 614
def mkdir(*directories)
if @create_parents
directories.each do |directory|
loop do
puts "Creating '#{directory}'"
FileUtils.mkdir_p directory if Subversion.under_version_control?(File.dirname(directory))
svn :system, 'add', *directory
break
else
directory = File.dirname(directory)
end
end
end
else
svn :system, 'mkdir', *directories
end
end
|
#move(*args) ⇒ Object
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
|
# File 'lib/subwrap/svn_command.rb', line 662
def move(*args)
destination = args.pop
if destination[-1..-1] == '/'
if !File.exist?(destination[0..-2])
puts "Notice: It appears that the '" + destination.bold + "' directory doesn't exist. Would you like to create it now? Good..."
self.mkdir destination elsif !File.directory?(destination[0..-2])
puts "Error".red.bold + ": It appears that '" + destination.bold + "' already exists but is not actually a directory. " +
"The " + 'destination'.bold + " must either be the path to a " + 'file'.underline + " that does " + 'not'.underline + " yet exist or the path to a " + 'directory'.underline + " (which may or may not yet exist)."
return
end
end
if @create_parents and !Subversion.under_version_control?(destination_dir = File.dirname(destination))
puts "Creating parent directory '#{destination_dir}'..."
self.mkdir destination_dir end
if args.length >= 2
sources = args
sources.each do |source|
puts filtered_svn('move', source, destination)
end
else
svn :exec, 'move', *(args + [destination])
end
end
|
#option_missing(option_name, args) ⇒ Object
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
# File 'lib/subwrap/svn_command.rb', line 262
def option_missing(option_name, args)
if !@subcommand_is_defined
else
raise UnknownOptionError.new(option_name)
end
@passthrough_options << "#{option_name}" << args.shell_escape
@passthrough_options.flatten!
return arity = args.size end
|
#play_revisions(directory = './') ⇒ Object
1534
1535
1536
1537
|
# File 'lib/subwrap/svn_command.rb', line 1534
def play_revisions(directory = './')
@interactive = false
show_or_browse_revisions(directory)
end
|
#repository_root(*args) ⇒ Object
Returns root repository URL for a working copy
893
894
895
|
# File 'lib/subwrap/svn_command.rb', line 893
def repository_root(*args)
puts Subversion.repository_root(*args)
end
|
#repository_uuid(*args) ⇒ Object
Returns the UUID for a working copy/URL
887
888
889
|
# File 'lib/subwrap/svn_command.rb', line 887
def repository_uuid(*args)
puts Subversion.repository_uuid(*args)
end
|
#set_message(new_message) ⇒ Object
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
|
# File 'lib/subwrap/svn_command.rb', line 1276
def set_message(new_message)
puts "Message before changing:"
get_message
args = ['propset', '--revprop', 'svn:log']
args.concat ['-r', @revision ? @revision : 'head']
args << new_message if new_message
if @filename
contents = File.readlines(@filename).join.strip
puts "Read file '#{@filename}':"
print contents
puts
args << contents
end
svn :exec, *args
end
|
#status(*args) ⇒ Object
806
807
808
809
810
811
|
# File 'lib/subwrap/svn_command.rb', line 806
def status(*args)
options = {}
options[:only_statuses] = @only_statuses
options[:files_only] = @files_only
print Subversion.status_lines_filter( Subversion.status(*(prepare_args(args))), options )
end
|
#under_version_control(*args) ⇒ Object
#update(*args) ⇒ Object
845
846
847
848
849
850
851
852
853
854
|
# File 'lib/subwrap/svn_command.rb', line 845
def update(*args)
directory = (args[0] ||= './')
revision_of_directory = Subversion.latest_revision_for_path(directory)
puts "(Note: The working copy '#{directory.white.bold}' was at #{('r' + revision_of_directory.to_s).magenta.bold} before updating...)"
@passthrough_options << '--ignore-externals' if ignore_externals?
Subversion.print_commands! do puts Subversion.update_lines_filter( Subversion.update(*prepare_args(args)) )
end
end
|
#url(*args) ⇒ Object
869
870
871
|
# File 'lib/subwrap/svn_command.rb', line 869
def url(*args)
puts Subversion.url(*args)
end
|
#view_commits(path = "./") ⇒ Object
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
|
# File 'lib/subwrap/svn_command.rb', line 928
def view_commits(path = "./")
if @revisions.nil?
raise "-r (revisions) option is mandatory"
end
$ignore_dry_run_option = true
base_url = Subversion.base_url(path)
$ignore_dry_run_option = false
revisions = self.class.parse_revision_ranges(@revisions)
revisions.each do |revision|
puts Subversion.log("-r #{revision} -v #{base_url}")
end
puts Subversion.diff("-r #{revisions.first}:#{revisions.last} #{path}")
end
|
#whats_new(directory = './') ⇒ Object
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
|
# File 'lib/subwrap/svn_command.rb', line 1570
def whats_new(directory = './')
revision_of_directory = Subversion.latest_revision_for_path(directory)
@first_revision_default = revision_of_directory.to_s
@last_revision_default = 'head'
@oldest_first_default = true
@interactive = false
show_or_browse_revisions(directory)
end
|
#working_copy_root(*args) ⇒ Object
Returns root/base path for a working copy