pvn 0.0.11 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/bin/pvn +1 -1
  3. data/lib/pvn/app/runner.rb +18 -17
  4. data/lib/pvn/command/clargs.rb +3 -1
  5. data/lib/pvn/command/color_option.rb +2 -2
  6. data/lib/pvn/command/command.rb +6 -5
  7. data/lib/pvn/command/doc.rb +43 -23
  8. data/lib/pvn/command/options.rb +4 -4
  9. data/lib/pvn/diff/change.rb +2 -5
  10. data/lib/pvn/diff/changed_paths.rb +7 -6
  11. data/lib/pvn/diff/command.rb +9 -5
  12. data/lib/pvn/diff/diffcmd.rb +52 -0
  13. data/lib/pvn/diff/differ.rb +2 -1
  14. data/lib/pvn/diff/diffset.rb +36 -0
  15. data/lib/pvn/diff/local_path.rb +13 -14
  16. data/lib/pvn/diff/log_path.rb +24 -34
  17. data/lib/pvn/diff/log_paths.rb +5 -3
  18. data/lib/pvn/diff/options.rb +1 -1
  19. data/lib/pvn/diff/path.rb +12 -48
  20. data/lib/pvn/diff/paths.rb +6 -3
  21. data/lib/pvn/diff/repository_differ.rb +4 -1
  22. data/lib/pvn/diff/status_paths.rb +7 -4
  23. data/lib/pvn/doc.rb +2 -4
  24. data/lib/pvn/io/element.rb +27 -85
  25. data/lib/pvn/io/fselement.rb +8 -2
  26. data/lib/pvn/log/command.rb +2 -2
  27. data/lib/pvn/log/entries.rb +13 -27
  28. data/lib/pvn/log/formatter/date_formatter.rb +16 -0
  29. data/lib/pvn/log/formatter/entry_formatter.rb +0 -12
  30. data/lib/pvn/log/formatter/message_formatter.rb +1 -1
  31. data/lib/pvn/log/formatter/summary_formatter.rb +8 -1
  32. data/lib/pvn/log/options.rb +4 -4
  33. data/lib/pvn/log/user_entries.rb +4 -5
  34. data/lib/pvn/pct/command.rb +9 -9
  35. data/lib/pvn/pct/differ.rb +2 -3
  36. data/lib/pvn/pct/local_differ.rb +4 -5
  37. data/lib/pvn/pct/repository_differ.rb +35 -24
  38. data/lib/pvn/revision/argument.rb +2 -1
  39. data/lib/pvn/revision/base_option.rb +5 -10
  40. data/lib/pvn/revision/range.rb +2 -1
  41. data/lib/pvn/seek/command.rb +9 -14
  42. data/lib/pvn/seek/match.rb +65 -0
  43. data/lib/pvn/seek/options.rb +3 -3
  44. data/lib/pvn/seek/path.rb +31 -115
  45. data/lib/pvn/seek/seeker.rb +88 -0
  46. data/lib/pvn/status/command.rb +2 -1
  47. data/lib/pvn/status/formatter/entries_formatter.rb +0 -1
  48. data/lib/pvn/util/color_formatter.rb +9 -3
  49. data/lib/pvn/util/textlines.rb +2 -2
  50. data/lib/pvn.rb +1 -1
  51. data/test/integration/pvn/diff/changed_paths_test.rb +3 -3
  52. data/test/integration/pvn/diff/local_differ_test.rb +0 -2
  53. data/test/integration/pvn/diff/log_paths_test.rb +13 -4
  54. data/test/integration/pvn/diff/repository_differ_test.rb +6 -0
  55. data/test/integration/pvn/diff/status_paths_test.rb +12 -7
  56. data/test/integration/pvn/log/command_test.rb +62 -5
  57. data/test/integration/pvn/pct/local_differ_test.rb +2 -5
  58. data/test/integration/pvn/pct/repository_differ_test.rb +4 -6
  59. data/test/integration/pvn/seek/command_test.rb +106 -0
  60. data/test/integration/pvn/status/command_test.rb +2 -6
  61. data/test/unit/pvn/app_test.rb +1 -1
  62. data/test/unit/pvn/diff/change_test.rb +0 -0
  63. data/test/unit/pvn/diff/path_test.rb +0 -0
  64. data/test/unit/pvn/io/element/log/log_test.rb +0 -0
  65. data/test/unit/pvn/log/formatter/entry_formatter_test.rb +9 -12
  66. data/test/unit/pvn/log/options_test.rb +0 -0
  67. data/test/unit/pvn/revision/argument_test.rb +0 -0
  68. data/test/unit/pvn/revision/multiple_revisions_option_test.rb +1 -1
  69. data/test/unit/pvn/revision/range_test.rb +0 -0
  70. data/test/unit/pvn/revision/revision_option_test.rb +0 -0
  71. data/test/unit/pvn/revision/revision_regexp_option_test.rb +0 -0
  72. metadata +156 -195
  73. data/README.markdown +0 -43
  74. data/bin/quote.rb +0 -218
  75. data/bin/quotes.orig.txt +0 -145
  76. data/bin/quotes.txt +0 -64
  77. data/lib/pvn/app.rb +0 -7
  78. data/lib/pvn/cmddoc.rb +0 -77
  79. data/lib/pvn/diff/name.rb +0 -23
  80. data/lib/svnx/action.rb +0 -47
  81. data/lib/svnx/cat/command.rb +0 -63
  82. data/lib/svnx/command.rb +0 -77
  83. data/lib/svnx/entries.rb +0 -67
  84. data/lib/svnx/entry.rb +0 -58
  85. data/lib/svnx/info/command.rb +0 -42
  86. data/lib/svnx/info/entries.rb +0 -19
  87. data/lib/svnx/info/entry.rb +0 -38
  88. data/lib/svnx/log/command.rb +0 -81
  89. data/lib/svnx/log/entries.rb +0 -18
  90. data/lib/svnx/log/entry.rb +0 -53
  91. data/lib/svnx/status/command.rb +0 -28
  92. data/lib/svnx/status/entries.rb +0 -17
  93. data/lib/svnx/status/entry.rb +0 -53
  94. data/lib/synoption/base_option.rb +0 -132
  95. data/lib/synoption/boolean_option.rb +0 -21
  96. data/lib/synoption/doc.rb +0 -81
  97. data/lib/synoption/exception.rb +0 -12
  98. data/lib/synoption/fixnum_option.rb +0 -13
  99. data/lib/synoption/match.rb +0 -47
  100. data/lib/synoption/matchers.rb +0 -22
  101. data/lib/synoption/option.rb +0 -10
  102. data/lib/synoption/optionable.rb +0 -66
  103. data/lib/synoption/set.rb +0 -145
  104. data/lib/system/command/arg.rb +0 -12
  105. data/lib/system/command/cachefile.rb +0 -53
  106. data/lib/system/command/caching.rb +0 -36
  107. data/lib/system/command/line.rb +0 -47
  108. data/test/integration/pvn/diff/command_test.rb +0 -20
  109. data/test/unit/svnx/action_test.rb +0 -38
  110. data/test/unit/svnx/info/entries_test.rb +0 -22
  111. data/test/unit/svnx/info/entry_test.rb +0 -22
  112. data/test/unit/svnx/log/cmargs_test.rb +0 -22
  113. data/test/unit/svnx/log/entries_test.rb +0 -90
  114. data/test/unit/svnx/log/entry_test.rb +0 -17
  115. data/test/unit/svnx/status/entries_test.rb +0 -21
  116. data/test/unit/svnx/status/entry_test.rb +0 -16
  117. data/test/unit/synoption/base_option_test.rb +0 -182
  118. data/test/unit/synoption/match_test.rb +0 -61
  119. data/test/unit/synoption/option_test.rb +0 -15
  120. data/test/unit/synoption/set_test.rb +0 -53
  121. data/test/unit/system/command/cachefile_test.rb +0 -53
  122. data/test/unit/system/command/caching_test.rb +0 -88
  123. data/test/unit/system/command/line_test.rb +0 -33
@@ -1,63 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/command'
5
-
6
- module SVNx
7
- module CatCmdLine
8
- # this can be either an Array (for which to_a returns itself), or
9
- # a CommandArgs, which also has to_a.
10
- def initialize args = Array.new
11
- info "args: #{args}"
12
- super "cat", args.to_a
13
- end
14
-
15
- def uses_xml?
16
- false
17
- end
18
- end
19
-
20
- class CatCommandLine < CommandLine
21
- include CatCmdLine
22
- end
23
-
24
- class CatCommandLineCaching < CachingCommandLine
25
- include CatCmdLine
26
- end
27
-
28
- class CatCommandArgs < CommandArgs
29
- attr_reader :revision
30
- attr_reader :use_cache
31
-
32
- def initialize args = Hash.new
33
- @use_cache = args[:use_cache].nil? || args[:use_cache]
34
- @revision = args[:revision]
35
- super
36
- end
37
-
38
- def to_a
39
- ary = Array.new
40
- if @revision
41
- @revision.each do |rev|
42
- ary << "-r#{rev}"
43
- end
44
- end
45
-
46
- if @path
47
- ary << @path
48
- end
49
- end
50
- end
51
-
52
- class CatCommand < Command
53
- def initialize args
54
- @use_cache = args.use_cache
55
- super
56
- end
57
-
58
- def command_line
59
- cls = @use_cache ? CatCommandLineCaching : CatCommandLine
60
- cls.new @args
61
- end
62
- end
63
- end
data/lib/svnx/command.rb DELETED
@@ -1,77 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'rubygems'
5
- require 'riel'
6
- require 'system/command/line'
7
-
8
- # this replaces svnx/lib/command/svncommand.
9
-
10
- module SVNx
11
- DEFAULT_CACHE_DIR = '/tmp/svnx'
12
- TMP_DIR_ENV_VARNAME = 'SVNX_TMP_DIR'
13
-
14
- module CmdLine
15
- include Loggable
16
-
17
- def initialize subcmd, args
18
- info "args: #{args}"
19
- cmdargs = [ 'svn', subcmd ]
20
- cmdargs << '--xml' if uses_xml?
21
- info "cmdargs: #{cmdargs}"
22
- cmdargs.concat args
23
- info "cmdargs: #{cmdargs}"
24
- super cmdargs
25
- end
26
-
27
- def uses_xml?
28
- true
29
- end
30
-
31
- def cache_dir
32
- ENV[TMP_DIR_ENV_VARNAME] || DEFAULT_CACHE_DIR
33
- end
34
- end
35
-
36
- class CommandLine < System::CommandLine
37
- include CmdLine
38
- end
39
-
40
- class CachingCommandLine < System::CachingCommandLine
41
- include CmdLine
42
- end
43
-
44
- class CommandArgs
45
- include Loggable
46
-
47
- attr_accessor :path
48
-
49
- def initialize args = Hash.new
50
- @path = args[:path]
51
- end
52
-
53
- def to_a
54
- [ @path ].compact
55
- end
56
- end
57
-
58
- class Command
59
- include Loggable
60
-
61
- attr_reader :output
62
-
63
- def initialize args
64
- @args = args
65
- end
66
-
67
- def command_line
68
- raise "must be implemented"
69
- end
70
-
71
- def execute
72
- cmdline = command_line
73
- cmdline.execute
74
- @output = cmdline.output
75
- end
76
- end
77
- end
data/lib/svnx/entries.rb DELETED
@@ -1,67 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'rexml/document'
5
-
6
- module SVNx
7
- # this is a parse/process on-demand list of entries, acting like an
8
- # Enumerable.
9
-
10
- class Entries
11
- include Loggable, Enumerable
12
-
13
- attr_reader :size
14
-
15
- def initialize args = Hash.new
16
- # it's a hash, but indexed with integers, for non-sequential access:
17
- @entries = Hash.new
18
-
19
- if xmllines = args[:xmllines]
20
- if xmllines.kind_of? Array
21
- xmllines = xmllines.join ''
22
- end
23
-
24
- doc = REXML::Document.new xmllines
25
-
26
- @elements = get_elements doc
27
- @size = @elements.size
28
- elsif xmlentries = args[:xmlentries]
29
- raise "argument xmlentries is no longer supported"
30
- end
31
- end
32
-
33
- def get_elements doc
34
- raise "get_elements must be implemented for: #{self.class}"
35
- end
36
-
37
- def create_entry xmlelement
38
- raise "create_entry must be implemented for: #{self.class}"
39
- end
40
-
41
- # this doesn't handle negative indices
42
- def [] idx
43
- if entry = @entries[idx]
44
- return entry
45
- end
46
- if idx < 0 && idx >= size
47
- raise "error: index #{idx} is not in range(0 .. #{size})"
48
- end
49
- @entries[idx] = create_entry(@elements[idx + 1])
50
- end
51
-
52
- def each(&blk)
53
- # all elements must be processed before each can run:
54
- if @elements
55
- # a little confusing here: REXML does each_with_index with idx
56
- # zero-based, but elements[0] is invalid.
57
- @elements.each_with_index do |element, idx|
58
- @entries[idx] ||= create_entry(element)
59
- end
60
-
61
- @elements = nil
62
- end
63
-
64
- @entries.keys.sort.collect { |idx| @entries[idx] }.each(&blk)
65
- end
66
- end
67
- end
data/lib/svnx/entry.rb DELETED
@@ -1,58 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'rubygems'
5
- require 'riel'
6
- require 'rexml/document'
7
-
8
- module SVNx
9
- class Entry
10
- include Loggable
11
-
12
- def initialize args = Hash.new
13
- if xmllines = args[:xmllines]
14
- if xmllines.kind_of? Array
15
- xmllines = xmllines.join ''
16
- end
17
-
18
- doc = REXML::Document.new xmllines
19
-
20
- set_from_xml doc
21
- elsif elmt = args[:xmlelement]
22
- set_from_element elmt
23
- else
24
- raise "must be initialized with xmllines or xmlelement"
25
- end
26
- end
27
-
28
- def set_from_xml xmldoc
29
- raise "must be implemented"
30
- end
31
-
32
- def set_from_element elmt
33
- raise "must be implemented"
34
- end
35
-
36
- def get_attribute xmlelement, attrname
37
- xmlelement.attributes[attrname]
38
- end
39
-
40
- def get_element_text xmlelement, elmtname
41
- elmt = xmlelement.elements[elmtname]
42
- # in my test svn repository, revision 1 doesn't have an author element:
43
- (elmt && elmt.text) || ""
44
- end
45
-
46
- def set_attr_var xmlelement, varname
47
- set_var varname, get_attribute(xmlelement, varname)
48
- end
49
-
50
- def set_elmt_var xmlelement, varname
51
- set_var varname, get_element_text(xmlelement, varname)
52
- end
53
-
54
- def set_var varname, value
55
- instance_variable_set '@' + varname, value
56
- end
57
- end
58
- end
@@ -1,42 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/command'
5
-
6
- module SVNx
7
- class InfoCommandLine < CommandLine
8
- def initialize args = Array.new
9
- super "info", args.to_a
10
- end
11
- end
12
-
13
- class InfoCommandArgs < CommandArgs
14
- attr_reader :revision
15
-
16
- def initialize args = Hash.new
17
- @revision = args[:revision]
18
- super
19
- end
20
-
21
- def to_a
22
- ary = Array.new
23
-
24
- if @revision
25
- @revision.each do |rev|
26
- ary << "-r#{rev}"
27
- end
28
- end
29
-
30
- if @path
31
- ary << @path
32
- end
33
- ary
34
- end
35
- end
36
-
37
- class InfoCommand < Command
38
- def command_line
39
- InfoCommandLine.new @args
40
- end
41
- end
42
- end
@@ -1,19 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/info/entry'
5
- require 'svnx/entries'
6
-
7
- module SVNx::Info
8
- class Entries < SVNx::Entries
9
- include Loggable
10
-
11
- def get_elements doc
12
- doc.elements['info'].elements
13
- end
14
-
15
- def create_entry xmlelement
16
- Entry.new :xmlelement => xmlelement
17
- end
18
- end
19
- end
@@ -1,38 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/entry'
5
-
6
- module SVNx; module Info; end; end
7
-
8
- module SVNx::Info
9
- class Entry < SVNx::Entry
10
- attr_reader :url
11
- attr_reader :root
12
- attr_reader :kind
13
- attr_reader :path
14
- attr_reader :revision
15
-
16
- def set_from_xml xmldoc
17
- entry = xmldoc.elements['info/entry']
18
-
19
- set_attr_var entry, 'kind'
20
- set_attr_var entry, 'path'
21
- set_attr_var entry, 'revision'
22
- set_elmt_var entry, 'url'
23
-
24
- repo = entry.elements['repository']
25
- set_elmt_var repo, 'root'
26
- end
27
-
28
- def set_from_element elmt
29
- set_attr_var elmt, 'kind'
30
- set_attr_var elmt, 'path'
31
- set_attr_var elmt, 'revision'
32
- set_elmt_var elmt, 'url'
33
-
34
- repo = elmt.elements['repository']
35
- set_elmt_var repo, 'root'
36
- end
37
- end
38
- end
@@ -1,81 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'system/command/line'
5
- require 'system/command/caching'
6
- require 'svnx/command'
7
-
8
- module SVNx
9
- module LogCmdLine
10
- # this can be either an Array (for which to_a returns itself), or
11
- # a CommandArgs, which also has to_a.
12
- def initialize args = Array.new
13
- info "args: #{args}"
14
- super "log", args.to_a
15
- end
16
- end
17
-
18
- class LogCommandLine < CommandLine
19
- include LogCmdLine
20
- end
21
-
22
- class LogCommandLineCaching < CachingCommandLine
23
- include LogCmdLine
24
- end
25
-
26
- class LogCommandArgs < CommandArgs
27
- include Loggable
28
-
29
- attr_reader :limit
30
- attr_reader :verbose
31
- attr_reader :revision
32
- attr_reader :use_cache
33
-
34
- def initialize args = Hash.new
35
- @limit = args[:limit]
36
- @verbose = args[:verbose]
37
- @use_cache = args[:use_cache].nil? || args[:use_cache]
38
- @revision = args[:revision]
39
- info "args : #{args}"
40
- info "@limit : #{@limit}"
41
- info "@verbose : #{@verbose}"
42
- info "@use_cache: #{@use_cache}"
43
- info "@revision : #{@revision}"
44
- super
45
- end
46
-
47
- def to_a
48
- ary = Array.new
49
- if @limit
50
- ary << '--limit' << @limit
51
- end
52
- if @verbose
53
- ary << '-v'
54
- end
55
-
56
- if @revision
57
- @revision.each do |rev|
58
- ary << "-r#{rev}"
59
- end
60
- end
61
-
62
- if @path
63
- ary << @path
64
- end
65
-
66
- ary.compact
67
- end
68
- end
69
-
70
- class LogCommand < Command
71
- def initialize args
72
- @use_cache = args.use_cache
73
- super
74
- end
75
-
76
- def command_line
77
- cls = @use_cache ? LogCommandLineCaching : LogCommandLine
78
- cls.new @args
79
- end
80
- end
81
- end
@@ -1,18 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/entries'
5
- require 'svnx/log/entry'
6
-
7
- module SVNx::Log
8
- class Entries < SVNx::Entries
9
-
10
- def get_elements doc
11
- doc.elements['log'].elements
12
- end
13
-
14
- def create_entry xmlelement
15
- Entry.new :xmlelement => xmlelement
16
- end
17
- end
18
- end
@@ -1,53 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/entry'
5
-
6
- module SVNx; module Log; end; end
7
-
8
- module SVNx::Log
9
- class Entry < SVNx::Entry
10
-
11
- attr_reader :revision, :author, :date, :paths, :msg
12
-
13
- def set_from_element elmt
14
- set_attr_var elmt, 'revision'
15
-
16
- %w{ author date msg }.each do |field|
17
- set_elmt_var elmt, field
18
- end
19
-
20
- @paths = Array.new
21
-
22
- elmt.elements.each('paths/path') do |pe|
23
- kind = get_attribute pe, 'kind'
24
- action = get_attribute pe, 'action'
25
- name = pe.text
26
-
27
- @paths << LogEntryPath.new(:kind => kind, :action => action, :name => name)
28
- end
29
- end
30
-
31
- def message
32
- @msg
33
- end
34
-
35
- def to_s
36
- [ @revision, @author, @date, @msg, @paths ].collect { |x| x.to_s }.join " "
37
- end
38
- end
39
-
40
- class LogEntryPath
41
- attr_reader :kind, :action, :name
42
-
43
- def initialize args = Hash.new
44
- @kind = args[:kind]
45
- @action = args[:action]
46
- @name = args[:name]
47
- end
48
-
49
- def to_s
50
- @name
51
- end
52
- end
53
- end
@@ -1,28 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/command'
5
-
6
- module SVNx
7
- class StatusCommandLine < CommandLine
8
- def initialize args = Array.new
9
- super "status", args.to_a
10
- end
11
- end
12
-
13
- class StatusCommandArgs < CommandArgs
14
- def to_a
15
- ary = Array.new
16
- if @path
17
- ary << @path
18
- end
19
- ary
20
- end
21
- end
22
-
23
- class StatusCommand < Command
24
- def command_line
25
- StatusCommandLine.new @args
26
- end
27
- end
28
- end
@@ -1,17 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/status/entry'
5
- require 'svnx/entries'
6
-
7
- module SVNx::Status
8
- class Entries < SVNx::Entries
9
- def get_elements doc
10
- doc.elements['status'].elements['target'].elements
11
- end
12
-
13
- def create_entry xmlelement
14
- Entry.new :xmlelement => xmlelement
15
- end
16
- end
17
- end
@@ -1,53 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/entry'
5
- require 'svnx/action'
6
-
7
- module SVNx; module Status; end; end
8
-
9
- module SVNx::Status
10
- class Entry < SVNx::Entry
11
-
12
- attr_reader :status
13
- attr_reader :path
14
- attr_reader :status_revision
15
- attr_reader :action
16
-
17
- def initialize args = Hash.new
18
- super
19
- @action = SVNx::Action.new @status
20
- end
21
-
22
- def set_from_xml xmldoc
23
- stelmt = xmldoc.elements['status']
24
- tgt = stelmt.elements['target']
25
-
26
- set_attr_var tgt, 'path'
27
-
28
- if entry = tgt.elements['entry']
29
- set_from_element entry
30
- else
31
- @status = "unchanged"
32
- end
33
- end
34
-
35
- def set_from_element elmt
36
- set_attr_var elmt, 'path'
37
-
38
- wcstatus = elmt.elements['wc-status']
39
- @status = wcstatus.attributes['item']
40
- @status_revision = wcstatus.attributes['revision']
41
-
42
- if commit = wcstatus.elements['commit']
43
- @commit_revision = commit.attributes['revision']
44
- else
45
- @commit_revision = nil
46
- end
47
- end
48
-
49
- def to_s
50
- "path: #{@path}; status: #{@status}"
51
- end
52
- end
53
- end