svn-command 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Readme CHANGED
@@ -1,8 +1,8 @@
1
1
  = <i>Enhanced Subversion command</i> -- an +svn+ command wrapper
2
2
 
3
3
  [*Environment*:] Command line
4
- [<b>Home page</b>:] http://svncommand.rubyforge.org/
5
- [<b>Project site</b>:] http://rubyforge.org/projects/svncommand
4
+ [<b>Home page</b>:] http://svn-command.rubyforge.org/
5
+ [<b>Project site</b>:] http://rubyforge.org/projects/svn-command
6
6
  [<b>Wiki</b>:] http://wiki.qualitysmith.com/svn-command
7
7
  [<b>Author</b>:] Tyler Rick
8
8
 
@@ -26,7 +26,7 @@ Currently a _patched_ version of Console::Command is required. The patched vesio
26
26
 
27
27
  You also need to make those files *executable* (once per _system_):
28
28
 
29
- sudo chmod a+x /usr/lib/ruby/gems/1.8/gems/svn-command-0.0.3/bin/*
29
+ sudo chmod a+x /usr/lib/ruby/gems/1.8/gems/svn-command*/bin/*
30
30
 
31
31
  (We can't just set <tt>executables = "svn"</tt> and have it automatically install it to /usr/bin because that would cause it to <b>wipe out</b> the existing executable at <tt>/usr/bin/svn</tt>! If you know of a better, more automatic solution to this, please let the developers know!)
32
32
 
@@ -38,9 +38,9 @@ And for some reason I seem to have to restart my terminal after doing the chmod
38
38
 
39
39
  export PATH=`ls -d /usr/lib/ruby/gems/1.8/gems/svn-command* | tail -n1`/bin:$PATH
40
40
 
41
- Or hard-code the path, if you really want to:
41
+ Or hard-code the path, if you _really_ want to:
42
42
 
43
- export PATH=/usr/lib/ruby/gems/1.8/gems/svn-command-0.0.4/bin:$PATH
43
+ export PATH=/usr/lib/ruby/gems/1.8/gems/svn-command-Version/bin:$PATH
44
44
 
45
45
  (I'm not sure if this is possible to automate with the <tt>gem install</tt> process or not. But in the meantime you need to do it manually.)
46
46
 
@@ -57,6 +57,7 @@ Changes to existing subcommands:
57
57
  * <tt>svn status</tt>
58
58
  ** filters out distracting, useless output about externals (don't worry -- it still shows which files were _modified_)
59
59
  ** the flags (?, M, C, etc.) are in *color*!
60
+ * <tt>svn move</tt> -- it will let you move multiple source files to a destination directory with a single command
60
61
 
61
62
  (* You can pass --no-color to disable colors for a single command...useful if you want to pipe the output to another command or something. Eventually maybe we could make this a per-user option via .svn-command?)
62
63
 
@@ -73,7 +74,7 @@ New subcommands:
73
74
 
74
75
  == Usage
75
76
 
76
- === <tt>svn st</tt>
77
+ === <tt>st</tt>
77
78
 
78
79
  _Without_ this gem installed (really long):
79
80
 
@@ -113,7 +114,7 @@ _Without_ this gem installed (really long):
113
114
  A gemables/subversion/bin/svn
114
115
  M applications/underlord/vendor/plugins/rails_smith/tasks/shared/base.rake
115
116
 
116
- === <tt>svn each_unadded</tt>
117
+ === <tt>each_unadded</tt>
117
118
 
118
119
  My personal favorite. This command is useful for keeping your working copies clean -- getting rid of all those accumulated temp files (or *ignoring* or *adding* them if they're something that _all_ users of this repository should be aware of).
119
120
 
@@ -139,7 +140,7 @@ It simply goes through each "unadded" file (each file reporting a status of <tt>
139
140
 
140
141
  For *files*, it will show a preview of the _contents_ of that file (limited to the first 3000 characters); for *directories*, it will show a _directory_ _listing_. By looking at the preview, you should hopefully be able to decide whether you want to _keep_ the file or _junk_ it.
141
142
 
142
- ===externalize / externals / edit_externals
143
+ ===<tt>externalize</tt> / <tt>externals</tt> / <tt>edit_externals</tt>
143
144
 
144
145
  Shortcut for creating an svn:external...
145
146
 
@@ -175,7 +176,7 @@ You can also pass a directory name to edit_externals to edit the svn:externals p
175
176
 
176
177
  > svn edit-externals vendor/plugins
177
178
 
178
- ===get_message / set_message / edit_message
179
+ ===<tt>get_message</tt> / <tt>set_message</tt> / <tt>edit_message</tt>
179
180
 
180
181
  <b>Pre-requisite for set_message/edit_message</b>: Your repository must have a <tt>pre-revprop-change</tt> hook file.
181
182
 
@@ -194,6 +195,15 @@ You can do this:
194
195
  or just this:
195
196
  svn edit_message
196
197
 
198
+ === <tt>move</tt>
199
+
200
+ You can now do commands like this:
201
+
202
+ svn mv file1 file2 dir
203
+ svn mv dir1/* dir
204
+
205
+ (The standard svn command only accepts a single source and a single destination.)
206
+
197
207
  ===Help
198
208
 
199
209
  You can, of course, get a lits of the custom commands that have been added by using <tt>svn help</tt>. They will be listed at the end.
@@ -205,7 +215,7 @@ You can, of course, get a lits of the custom commands that have been added by us
205
215
  * --show-commands (prints out the /usr/bin/svn commands before executing them)
206
216
  * --debug (sets $debug = true)
207
217
 
208
- ==colordiff
218
+ ==<tt>colordiff</tt>
209
219
 
210
220
  +colordiff+ is used to colorize <tt>svn diff</tt> commands (+ lines are blue; - lines are red)
211
221
 
data/lib/subversion.rb CHANGED
@@ -11,7 +11,7 @@ require 'facets/core/kernel/require_local'
11
11
  require 'facets/core/enumerable/uniq_by'
12
12
  require 'facets/core/kernel/silence_stream'
13
13
 
14
- require_gem 'our_extensions', '>=0.0.2'
14
+ require_gem 'qualitysmith_extensions', '>=0.0.3'
15
15
  require 'capture_output'
16
16
 
17
17
  # Had a lot of trouble getting ActiveSupport to load without giving errors! Eventually gave up on that idea since I only needed it for mattr_accessor and Facets supplies that.
@@ -144,8 +144,8 @@ module Subversion
144
144
 
145
145
  # Returns an array of external *items*
146
146
  # Example:
147
- # gemables/our_extensions/tasks/shared
148
- # gemables/our_extensions/doc_include/template
147
+ # gemables/extensions/tasks/shared
148
+ # gemables/extensions/doc_include/template
149
149
  def self.externals_items(path = './')
150
150
  status = status_the_section_before_externals(path)
151
151
  return [] if status.nil?
@@ -15,6 +15,7 @@ class String
15
15
  self.gsub(/^ *\?/) { $&.yellow.bold}.
16
16
  gsub(/^ *A/) { $&.green.bold}.
17
17
  gsub(/^ *M/) { $&.green.bold}.
18
+ gsub(/^ *D/) { $&.magenta.bold}.
18
19
  gsub(/^ *C/) { $&.red.bold}.
19
20
  gsub(/^ *~/) { $&.red.bold}.
20
21
  gsub(/^ *!/) { $&.red.bold}
data/lib/svn_command.rb CHANGED
@@ -6,10 +6,11 @@ require 'facets/core/string/margin'
6
6
  require 'facets/core/kernel/require_local'
7
7
  require 'facets/core/array/select' # select!
8
8
 
9
- require_gem 'our_extensions', '>=0.0.2'
10
- require 'enumerable/enum'
11
- require 'array/expand_ranges'
12
- require 'array/shell_escape'
9
+ require_gem 'qualitysmith_extensions', '>=0.0.3'
10
+ require 'qualitysmith_extensions/enumerable/enum'
11
+ require 'qualitysmith_extensions/array/expand_ranges'
12
+ require 'qualitysmith_extensions/array/shell_escape'
13
+ require 'qualitysmith_extensions/file_test/binary_file'
13
14
 
14
15
  require 'extensions/symbol' # to_proc
15
16
  require 'pp'
@@ -37,6 +38,13 @@ rescue RuntimeError => exception # Necessary for automated testing.
37
38
  end
38
39
  end
39
40
 
41
+ class String
42
+ # Makes the first character bold and underlined. Makes the whole string of the given color.
43
+ def menu_item(color = :white)
44
+ self[0..0].send(color).bold.underline + self[1..-1].send(color)
45
+ end
46
+ end
47
+
40
48
  Subversion.extend(Subversion::Extensions)
41
49
  Subversion::color = true
42
50
 
@@ -285,6 +293,39 @@ End
285
293
  # Ideas:
286
294
  # Just pass a number (5) and it will be treated as --limit 5 (unless File.exists?('5'))
287
295
 
296
+ #-----------------------------------------------------------------------------------------------------------------------------
297
+ module Move
298
+ Console::Command.pass_through({
299
+ [:_r, :__revision] => 1, # :todo: support "{" DATE "}" format
300
+ [:_q, :__quiet] => 0,
301
+ [:__force] => 0,
302
+ [:_m, :__message] => 1,
303
+ [:_F, :__file] => 1,
304
+ [:__force_log] => 0,
305
+ [:__editor_cmd] => 1,
306
+ [:__encoding] => 1,
307
+ }.merge(SvnCommand::standard_remote_command_options), self
308
+ )
309
+ end
310
+
311
+ # Unlike the built-in move, this one lets you list multiple source files
312
+ # Source... DestinationDir
313
+ # or
314
+ # Source Destination
315
+ def move(*args)
316
+ if args.length >= 3
317
+ destination = args.pop
318
+ sources = args
319
+
320
+ sources.each do |source|
321
+ puts svn(:capture, 'move', source, destination)
322
+ end
323
+ else
324
+ svn :exec, 'move', *args
325
+ end
326
+ end
327
+ alias_subcommand :mv => :move
328
+
288
329
  #-----------------------------------------------------------------------------------------------------------------------------
289
330
  module Status
290
331
  Console::Command.pass_through({
@@ -406,12 +447,16 @@ End
406
447
  raise "#{file} doesn't seem to exist -- even though it was reported by svn status"
407
448
  end
408
449
  if File.file?(file)
409
- puts "File contents:"
410
- # Only show the first x bytes so that we don't accidentally dump the contens of some 20 GB log file to screen...
411
- contents = File.read(file, 3000) || ''
412
- print contents
413
- puts if contents[-1] && contents[-1].chr != "\n" # Make sure we end with a newline character
414
- puts "..." if contents.length >= 3000 # So they know that there may be more to the file than what's shown
450
+ if FileTest.binary_file?(file)
451
+ puts "(Binary file -- cannot show preview)".bold
452
+ else
453
+ puts "File contents:"
454
+ # Only show the first x bytes so that we don't accidentally dump the contens of some 20 GB log file to screen...
455
+ contents = File.read(file, 3000) || ''
456
+ print contents
457
+ puts if contents[-1] && contents[-1].chr != "\n" # Make sure we end with a newline character
458
+ puts "..." if contents.length >= 3000 # So they know that there may be *more* to the file than what's shown
459
+ end
415
460
  elsif File.directory?(file)
416
461
  puts "Directory contains:"
417
462
  Dir.new(file).reject {|f| ['.','..'].include? f}.each do |f|
@@ -422,9 +467,9 @@ End
422
467
  end
423
468
  end
424
469
  print(
425
- "" + "A".green.bold.underline + "dd, ".green +
426
- "".red + "D".red.bold.underline + "elete".red + ", " +
427
- "add to " + "svn:".yellow + "I".yellow.bold.underline + "gnore".yellow + " property, " +
470
+ "Add".menu_item(:green) + ", " +
471
+ "Delete".menu_item(:red) + ", " +
472
+ "add to " + "svn:".yellow + "Ignore".menu_item(:yellow) + " property, " +
428
473
  "or [" + "Enter".white.bold + "] to do nothing > "
429
474
  )
430
475
  response = ""
@@ -443,7 +488,10 @@ End
443
488
 
444
489
  response = ""
445
490
  if File.directory?(file)
446
- print "Are you pretty much *SURE* you want to 'rm -rf #{file}'? (y)es, (n)o > "
491
+ print "Are you pretty much " + "SURE".bold + " you want to '" + "rm -rf #{file}".red.bold + "'? " +
492
+ "Yes".menu_item(:red) + ", " +
493
+ "No".menu_item(:green) +
494
+ " > "
447
495
  response = $stdin.getc.chr while !['y', 'n', "\n"].include?(begin response.downcase!; response end)
448
496
  else
449
497
  response = "y"
@@ -4,7 +4,7 @@ require_local '../lib/svn_command.rb'
4
4
  require 'facets/core/string/to_re'
5
5
  require 'yaml'
6
6
 
7
- Subversion.color = false # Makes testing simpler. We can just test that the *colorization* features are working via *manual* tests.
7
+ Subversion.color = false # Makes testing simpler. We can test that the *colorization* features are working via *manual* testing (they're not as critical).
8
8
 
9
9
  module Subversion
10
10
  class BaseSvnCommandTest < Test::Unit::TestCase
@@ -200,28 +200,23 @@ end
200
200
  # another character from stdin but you didn't supply one!
201
201
 
202
202
  class SvnEachUnaddedTest < BaseSvnCommandTest
203
- def stub_status_1
204
- Subversion.stubs(:status).returns("
205
- M gemables/calculator/test/calculator_test.rb
206
- X gemables/calculator/tasks/shared
207
- ? gemables/calculator/lib/unused.rb
208
- ")
209
- end
210
203
  def setup
211
204
  super
212
- FileUtils.mkdir_p('gemables/calculator/lib/')
213
- # file = 'gemables/calculator/lib/useless_directory'
214
- # FileUtils.rmdir(file) if File.exist?(file)
215
- File.open(@filename = 'gemables/calculator/lib/unused.rb', 'w') { |file| file.puts "line 1 of unused.rb" }
205
+ FileUtils.rm_rf('temp_dir/')
206
+ FileUtils.mkdir_p('temp_dir/calculator/lib/')
207
+ File.open(@filename = 'temp_dir/calculator/lib/unused.rb', 'w') { |file| file.puts "line 1 of unused.rb" }
216
208
  end
217
209
  def teardown
218
- file = 'gemables/calculator/lib/unused.rb'
219
- FileUtils.rm(file) if File.exist?(file)
220
- FileUtils.rmdir('gemables/calculator/lib/')
221
- FileUtils.rmdir('gemables/calculator/')
222
- FileUtils.rmdir('gemables/')
210
+ FileUtils.rm_rf('temp_dir/')
223
211
  end
224
212
 
213
+ def stub_status_1
214
+ Subversion.stubs(:status).returns("
215
+ M temp_dir/calculator/test/calculator_test.rb
216
+ X temp_dir/calculator/tasks/shared
217
+ ? temp_dir/calculator/lib/unused.rb
218
+ ")
219
+ end
225
220
  def test_add
226
221
  stub_status_1
227
222
  output = simulate_input('a') do
@@ -229,7 +224,7 @@ X gemables/calculator/tasks/shared
229
224
  end
230
225
  assert_match /What do you want to do with .*unused\.rb/, output
231
226
  assert_match /Adding/, output
232
- assert_equal "svn add gemables/calculator/lib/unused.rb", Subversion.executed.join
227
+ assert_equal "svn add temp_dir/calculator/lib/unused.rb", Subversion.executed.join
233
228
  end
234
229
  def test_ignore
235
230
  stub_status_1
@@ -239,8 +234,8 @@ X gemables/calculator/tasks/shared
239
234
  assert_match /What do you want to do with .*unused\.rb/, output
240
235
  assert_match /Ignoring/, output
241
236
  assert_equal [
242
- "svn propget svn:ignore gemables/calculator/lib",
243
- "svn propset svn:ignore 'unused.rb' gemables/calculator/lib"
237
+ "svn propget svn:ignore temp_dir/calculator/lib",
238
+ "svn propset svn:ignore 'unused.rb' temp_dir/calculator/lib"
244
239
  ], Subversion.executed
245
240
  end
246
241
  def test_preview_is_now_automatic
@@ -257,13 +252,13 @@ X gemables/calculator/tasks/shared
257
252
  end
258
253
  def test_delete
259
254
  Subversion.stubs(:status).returns("
260
- M gemables/calculator/test/calculator_test.rb
261
- X gemables/calculator/tasks/shared
262
- ? gemables/calculator/lib/unused.rb
263
- ? gemables/calculator/lib/useless_directory
255
+ M temp_dir/calculator/test/calculator_test.rb
256
+ X temp_dir/calculator/tasks/shared
257
+ ? temp_dir/calculator/lib/unused.rb
258
+ ? temp_dir/calculator/lib/useless_directory
264
259
  ")
265
- FileUtils.mkdir_p(@dirname = 'gemables/calculator/lib/useless_directory')
266
- File.open( 'gemables/calculator/lib/useless_directory/foo', 'w') { |file| file.puts "line 1 of foo" }
260
+ FileUtils.mkdir_p(@dirname = 'temp_dir/calculator/lib/useless_directory')
261
+ File.open( 'temp_dir/calculator/lib/useless_directory/foo', 'w') { |file| file.puts "line 1 of foo" }
267
262
 
268
263
  assert File.exist?( @dirname )
269
264
  assert File.exist?( @filename )
data/test/test_helper.rb CHANGED
@@ -6,9 +6,11 @@ require 'facets/core/kernel/load_local'
6
6
  require 'stubba'
7
7
  $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
8
8
  require_local "shared/test_helper"
9
- require_local '../../our_extensions/lib/test/assert_exception.rb'
10
- require_local '../../our_extensions/lib/capture_output.rb'
11
- require_local '../../our_extensions/lib/simulate_input.rb'
9
+
10
+ require_gem 'qualitysmith_extensions', '>=0.0.3'
11
+ require 'test/assert_exception.rb'
12
+ require 'capture_output.rb'
13
+ require 'simulate_input.rb'
12
14
 
13
15
  require 'subversion'
14
16
  if $mock_subversion
metadata CHANGED
@@ -3,13 +3,13 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: svn-command
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.5
6
+ version: 0.0.6
7
7
  date: 2007-03-15 00:00:00 -07:00
8
8
  summary: A nifty wrapper command for Subversion's command-line svn client
9
9
  require_paths:
10
10
  - lib
11
11
  email: rubyforge.org@tylerrick.com
12
- homepage: http://svncommand.rubyforge.org/
12
+ homepage: http://svn-command.rubyforge.org/
13
13
  rubyforge_project: svn-command
14
14
  description: This is a wrapper command for Subversion's command-line svn client that adds a few new subcommands.
15
15
  autorequire:
@@ -32,7 +32,6 @@ files:
32
32
  - lib/subversion.rb
33
33
  - lib/attribute_accessors.rb
34
34
  - lib/subversion_extensions.rb
35
- - lib/my_wrapper.rb
36
35
  - test/test_helper.rb
37
36
  - test/subversion_extensions_test.rb
38
37
  - test/subversion_test.rb
@@ -78,7 +77,25 @@ dependencies:
78
77
  version_requirement:
79
78
  version_requirements: !ruby/object:Gem::Version::Requirement
80
79
  requirements:
81
- - - ">"
80
+ - - ">="
82
81
  - !ruby/object:Gem::Version
83
- version: 0.0.0
82
+ version: 1.0.0
83
+ version:
84
+ - !ruby/object:Gem::Dependency
85
+ name: facets
86
+ version_requirement:
87
+ version_requirements: !ruby/object:Gem::Version::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: 1.8.51
92
+ version:
93
+ - !ruby/object:Gem::Dependency
94
+ name: qualitysmith_extensions
95
+ version_requirement:
96
+ version_requirements: !ruby/object:Gem::Version::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 0.0.3
84
101
  version:
data/lib/my_wrapper.rb DELETED
@@ -1,72 +0,0 @@
1
- require 'rubygems'
2
- require_gem 'facets', '>=1.8.51'
3
- require 'facets/more/command'
4
- require 'pp'
5
- require 'stringio'
6
-
7
- class MyWrapperCommand < Console::Command
8
-
9
- def initialize(*args)
10
- @missing_options = []
11
- super
12
- end
13
-
14
- #-----------------------------------------------------------------------------------------------------------------------------
15
- # Default/dynamic behavior
16
-
17
- # Any subcommands that we haven't implemented here will simply be passed on to the built-in svn command.
18
- # def method_missing(subcommand, *args)
19
- # puts "in method_missing(#{subcommand}, #{args.inspect})"
20
- # p options
21
- # exec subcommand, *args
22
- # end
23
-
24
- def option_missing(option_name, args)
25
- puts "in option_missing (#{option_name.inspect}, #{args.inspect})"
26
-
27
- # The following hackery is necessary because we really don't know the arity (how many subsequent tokens it should eat) of the option -- we don't know anything about the options, in fact; that's why we've landed in option_missing.
28
- # This is kind of a hokey solution, but for any unrecognized options/args (which will be *all* of them unless we list the available options in the subcommand module), we just eat all of the args, store them in @missing_options, and later we will add them back on.
29
- # What's annoying about it this solution is that *everything* after the first unrecognized option comes in as args, even if they are args for the subcommand and not for the *option*!
30
- # But...it seems to work to just pretend they're options.
31
- # It seems like this is mostly a problem for *wrappers* that try to use Console::Command. Sometimes you just want to *pass through all args and options* unchanged and just filter the output somehow.
32
- # Command doesn't make that super-easy though. If an option (--whatever) isn't defined, then the only way to catch it is in option_missing. And since we can't the arity unless we enumerate all options, we have to hokily treat the first option as having unlimited arity.
33
- # Alternatives considered:
34
- # * Assume arity of 0. Then I'm afraid it would extract out all the option flags and leave the args that were meant for the args dangling there out of order ("-r 1 -m 'hi'" => "-r -m", "1 'hi'")
35
- # * Assume arity of 1. Then if it was really 0, it would pick up an extra arg that really wasn't supposed to be an arg for the *option*.
36
- # Solution for wrappers:?
37
- # pass_through :some_built_in_subcommand
38
- # Tells Command to not parse options out of args -- just pass *all* args (options and all) on to the subcommand's method(*args).
39
- # Ideally, we wouldn't be using option_missing at all because all options would be listed in the respective subcommand module...but we're too lazy to list them all out, so this is just seemed like the easiest way to do things....
40
-
41
- @missing_options << "#{option_name}" << args
42
- @missing_options.flatten!
43
-
44
- return arity = args.size
45
- end
46
-
47
- #-----------------------------------------------------------------------------------------------------------------------------
48
- module Diff
49
- def __color
50
- @diff_command = 'colordiff'
51
- end
52
- end
53
- def diff(*args)
54
- puts "in diff (#{args.inspect})"
55
- args << '--diff-cmd' << @diff_command if @diff_command
56
- exec 'diff', *args
57
- end
58
-
59
- #-----------------------------------------------------------------------------------------------------------------------------
60
- # Helpers
61
-
62
- private
63
- def exec(*args)
64
- args = ['svn'] + args + @missing_options
65
- # options comes last because once the options parsing starts, it eats all args up to the very end
66
- puts "This is the command we would execute at this point, if this weren't just a demonstration"
67
- p args
68
- end
69
-
70
-
71
- end
72
- MyWrapperCommand.execute