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.
206
207
208
209
|
# File 'lib/subwrap/svn_command.rb', line 206
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
254
255
256
257
|
# File 'lib/subwrap/svn_command.rb', line 254
def method_missing(subcommand, *args)
svn :exec, subcommand, *args
end
|
Class Method Details
.parse_revision_ranges(revisions_array) ⇒ Object
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
|
# File 'lib/subwrap/svn_command.rb', line 948
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
218
219
220
|
# File 'lib/subwrap/svn_command.rb', line 218
def __debug
$debug = true
end
|
#__dry_run ⇒ Object
221
222
223
|
# File 'lib/subwrap/svn_command.rb', line 221
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
236
237
238
239
240
|
# File 'lib/subwrap/svn_command.rb', line 236
def __except
end
|
#__no_color ⇒ Object
215
216
217
|
# File 'lib/subwrap/svn_command.rb', line 215
def __no_color
Subversion::color = false
end
|
#__print_commands ⇒ Object
Also known as:
__show_commands, _V, __Verbose
225
226
227
|
# File 'lib/subwrap/svn_command.rb', line 225
def __print_commands
Subversion::print_commands = true
end
|
#add(*args) ⇒ Object
310
311
312
313
|
# File 'lib/subwrap/svn_command.rb', line 310
def add(*args)
svn :exec, 'add', *args
end
|
#add_all_unadded ⇒ Object
1357
1358
1359
|
# File 'lib/subwrap/svn_command.rb', line 1357
def add_all_unadded
raise NotImplementedError
end
|
#browse(directory = './') ⇒ Object
1549
1550
1551
1552
|
# File 'lib/subwrap/svn_command.rb', line 1549
def browse(directory = './')
@interactive = true
show_or_browse_revisions(directory)
end
|
#commit(*args) ⇒ Object
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
423
|
# File 'lib/subwrap/svn_command.rb', line 375
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
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
|
# File 'lib/subwrap/svn_command.rb', line 724
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`
259
260
261
|
# File 'lib/subwrap/svn_command.rb', line 259
def default()
svn :exec
end
|
#delete_svn(directory = './') ⇒ Object
Cause a working copy to cease being a working copy
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
|
# File 'lib/subwrap/svn_command.rb', line 1344
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
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
532
|
# File 'lib/subwrap/svn_command.rb', line 507
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)
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
1047
|
# File 'lib/subwrap/svn_command.rb', line 967
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
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
1153
|
# File 'lib/subwrap/svn_command.rb', line 1125
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/
1238
1239
1240
1241
1242
1243
|
# File 'lib/subwrap/svn_command.rb', line 1238
def edit_ignores(directory = './')
svn :system, "propedit svn:ignore #{directory}"
end
|
#edit_message(directory = './') ⇒ Object
1335
1336
1337
|
# File 'lib/subwrap/svn_command.rb', line 1335
def edit_message(directory = './')
edit_revision_property('svn:log', directory)
end
|
#edit_property(property_name, directory = './') ⇒ Object
1339
1340
|
# File 'lib/subwrap/svn_command.rb', line 1339
def edit_property(property_name, directory = './')
end
|
#edit_revision_property(property_name, directory = './') ⇒ Object
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
1327
|
# File 'lib/subwrap/svn_command.rb', line 1302
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
1172
1173
1174
1175
1176
1177
|
# File 'lib/subwrap/svn_command.rb', line 1172
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.
1118
1119
1120
1121
1122
|
# File 'lib/subwrap/svn_command.rb', line 1118
def externals_containers(directory = "./")
puts Subversion.externals_containers(directory).map { |external|
external.container_dir
}
end
|
#externals_items(directory = "./") ⇒ Object
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
1100
|
# File 'lib/subwrap/svn_command.rb', line 1071
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
1109
1110
1111
1112
1113
|
# File 'lib/subwrap/svn_command.rb', line 1109
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
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
476
|
# File 'lib/subwrap/svn_command.rb', line 432
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
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
|
# File 'lib/subwrap/svn_command.rb', line 1255
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
|
1360
1361
1362
|
# File 'lib/subwrap/svn_command.rb', line 1360
def grep
raise NotImplementedError
end
|
#grep_externals ⇒ Object
1363
1364
1365
|
# File 'lib/subwrap/svn_command.rb', line 1363
def grep_externals
raise NotImplementedError
end
|
1366
1367
1368
|
# File 'lib/subwrap/svn_command.rb', line 1366
def grep_log
raise NotImplementedError
end
|
#help(subcommand = nil) ⇒ Object
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
577
|
# File 'lib/subwrap/svn_command.rb', line 542
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("\nSubversion is a tool for version control.\nFor additional information, see http://subversion.tigris.org/\n", '')
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
1232
1233
1234
|
# File 'lib/subwrap/svn_command.rb', line 1232
def ignore(file)
Subversion.ignore(file)
end
|
#import(*args) ⇒ Object
757
758
759
760
|
# File 'lib/subwrap/svn_command.rb', line 757
def import(*args)
p args
svn :exec, 'import', *(args)
end
|
#latest_revision(*args) ⇒ Object
901
902
903
|
# File 'lib/subwrap/svn_command.rb', line 901
def latest_revision(*args)
puts Subversion.latest_revision
end
|
#local_ignore ⇒ Object
Also known as:
dont_commit, pretend_isnt_versioned
1224
1225
1226
|
# File 'lib/subwrap/svn_command.rb', line 1224
def local_ignore
end
|
#log(*args) ⇒ Object
593
594
595
596
|
# File 'lib/subwrap/svn_command.rb', line 593
def log(*args)
puts Subversion.log( prepare_args(args) )
end
|
#mkdir(*directories) ⇒ Object
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
|
# File 'lib/subwrap/svn_command.rb', line 615
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
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
709
|
# File 'lib/subwrap/svn_command.rb', line 663
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
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
292
|
# File 'lib/subwrap/svn_command.rb', line 263
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
1535
1536
1537
1538
|
# File 'lib/subwrap/svn_command.rb', line 1535
def play_revisions(directory = './')
@interactive = false
show_or_browse_revisions(directory)
end
|
#repository_root(*args) ⇒ Object
Returns root repository URL for a working copy
894
895
896
|
# File 'lib/subwrap/svn_command.rb', line 894
def repository_root(*args)
puts Subversion.repository_root(*args)
end
|
#repository_uuid(*args) ⇒ Object
Returns the UUID for a working copy/URL
888
889
890
|
# File 'lib/subwrap/svn_command.rb', line 888
def repository_uuid(*args)
puts Subversion.repository_uuid(*args)
end
|
#set_message(new_message) ⇒ Object
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
|
# File 'lib/subwrap/svn_command.rb', line 1277
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
807
808
809
810
811
812
|
# File 'lib/subwrap/svn_command.rb', line 807
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
876
877
878
|
# File 'lib/subwrap/svn_command.rb', line 876
def under_version_control(*args)
puts Subversion.under_version_control?(*args)
end
|
#update(*args) ⇒ Object
846
847
848
849
850
851
852
853
854
855
|
# File 'lib/subwrap/svn_command.rb', line 846
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
870
871
872
|
# File 'lib/subwrap/svn_command.rb', line 870
def url(*args)
puts Subversion.url(*args)
end
|
#view_commits(path = "./") ⇒ Object
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
|
# File 'lib/subwrap/svn_command.rb', line 929
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
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
|
# File 'lib/subwrap/svn_command.rb', line 1571
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
882
883
884
|
# File 'lib/subwrap/svn_command.rb', line 882
def working_copy_root(*args)
puts Subversion.working_copy_root(*args)
end
|