pvn 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. data/README.markdown +38 -0
  2. data/bin/pvn +12 -0
  3. data/bin/pvndiff +10 -0
  4. data/lib/pvn/app.rb +144 -0
  5. data/lib/pvn/base/textlines.rb +35 -0
  6. data/lib/pvn/base/util.rb +14 -0
  7. data/lib/pvn/cmddoc.rb +77 -0
  8. data/lib/pvn/config.rb +65 -0
  9. data/lib/pvn/describe.rb +40 -0
  10. data/lib/pvn/diff/diffcmd.rb +49 -0
  11. data/lib/pvn/diff/differ.rb +67 -0
  12. data/lib/pvn/diff/diffopts.rb +58 -0
  13. data/lib/pvn/doc.rb +34 -0
  14. data/lib/pvn/io/element.rb +113 -0
  15. data/lib/pvn/io/fselement.rb +22 -0
  16. data/lib/pvn/log/formatter/color_formatter.rb +29 -0
  17. data/lib/pvn/log/formatter/entries_formatter.rb +33 -0
  18. data/lib/pvn/log/formatter/entry_formatter.rb +57 -0
  19. data/lib/pvn/log/formatter/log_formatter.rb +59 -0
  20. data/lib/pvn/log/formatter/message_formatter.rb +19 -0
  21. data/lib/pvn/log/formatter/path_formatter.rb +41 -0
  22. data/lib/pvn/log/formatter/summary_formatter.rb +49 -0
  23. data/lib/pvn/log/logcmd.rb +136 -0
  24. data/lib/pvn/log/logentry.rb +116 -0
  25. data/lib/pvn/log/logfactory.rb +101 -0
  26. data/lib/pvn/log/logoptions.rb +43 -0
  27. data/lib/pvn/pct/linecount.rb +33 -0
  28. data/lib/pvn/pct/pctcmd.rb +204 -0
  29. data/lib/pvn/pct/statcmd.rb +13 -0
  30. data/lib/pvn/revision/entry.rb +94 -0
  31. data/lib/pvn/revision.rb +119 -0
  32. data/lib/pvn/subcommands/base/clargs.rb +53 -0
  33. data/lib/pvn/subcommands/base/command.rb +60 -0
  34. data/lib/pvn/subcommands/base/doc.rb +94 -0
  35. data/lib/pvn/subcommands/base/options.rb +22 -0
  36. data/lib/pvn/subcommands/log/command.rb +70 -0
  37. data/lib/pvn/subcommands/log/options.rb +43 -0
  38. data/lib/pvn/subcommands/pct/clargs.rb +33 -0
  39. data/lib/pvn/subcommands/pct/command.rb +57 -0
  40. data/lib/pvn/subcommands/revision/multiple_revisions_option.rb +43 -0
  41. data/lib/pvn/subcommands/revision/revision_option.rb +74 -0
  42. data/lib/pvn/subcommands/revision/revision_regexp_option.rb +39 -0
  43. data/lib/pvn/svn/command/svncmd.rb +39 -0
  44. data/lib/pvn/svn/environment.rb +23 -0
  45. data/lib/pvn/svn/svnelement.rb +89 -0
  46. data/lib/pvn/svn/svninfo.rb +42 -0
  47. data/lib/pvn/svn/svnroot.rb +29 -0
  48. data/lib/pvn/upp/uppcmd.rb +112 -0
  49. data/lib/pvn/wherecmd.rb +55 -0
  50. data/lib/pvn.rb +8 -0
  51. data/lib/svnx/command.rb +60 -0
  52. data/lib/svnx/entry.rb +34 -0
  53. data/lib/svnx/info/command.rb +21 -0
  54. data/lib/svnx/info/entries.rb +27 -0
  55. data/lib/svnx/info/entry.rb +34 -0
  56. data/lib/svnx/log/command.rb +93 -0
  57. data/lib/svnx/log/entries.rb +57 -0
  58. data/lib/svnx/log/entry.rb +54 -0
  59. data/lib/svnx/status/command.rb +21 -0
  60. data/lib/svnx/status/entries.rb +22 -0
  61. data/lib/svnx/status/entry.rb +33 -0
  62. data/lib/synoption/base_option.rb +149 -0
  63. data/lib/synoption/boolean_option.rb +21 -0
  64. data/lib/synoption/doc.rb +81 -0
  65. data/lib/synoption/fixnum_option.rb +13 -0
  66. data/lib/synoption/match.rb +47 -0
  67. data/lib/synoption/option.rb +10 -0
  68. data/lib/synoption/optionable.rb +66 -0
  69. data/lib/synoption/set.rb +114 -0
  70. data/lib/system/cachecmd.rb +65 -0
  71. data/lib/system/cmdexec.rb +13 -0
  72. data/lib/system/cmdline.rb +70 -0
  73. data/lib/system/command/arg.rb +12 -0
  74. data/lib/system/command/cachefile.rb +39 -0
  75. data/lib/system/command/caching.rb +36 -0
  76. data/lib/system/command/line.rb +47 -0
  77. data/lib/system/command.rb +72 -0
  78. data/test/integration/svnx/log/test.rb +43 -0
  79. data/test/unit/pvn/app_test.rb +22 -0
  80. data/test/unit/pvn/io/element/log/log_test.rb +35 -0
  81. data/test/unit/pvn/log/formatter/entry_formatter_test.rb +90 -0
  82. data/test/unit/pvn/revision/entry_test.rb +123 -0
  83. data/test/unit/pvn/subcommands/log/command_test.rb +22 -0
  84. data/test/unit/pvn/subcommands/log/options_test.rb +85 -0
  85. data/test/unit/pvn/subcommands/revision/multiple_revisions_option_test.rb +67 -0
  86. data/test/unit/pvn/subcommands/revision/revision_option_test.rb +57 -0
  87. data/test/unit/pvn/subcommands/revision/revision_regexp_option_test.rb +69 -0
  88. data/test/unit/svnx/info/entry_test.rb +52 -0
  89. data/test/unit/svnx/log/cmargs_test.rb +22 -0
  90. data/test/unit/svnx/log/entries_test.rb +73 -0
  91. data/test/unit/svnx/log/entry_test.rb +21 -0
  92. data/test/unit/svnx/status/entry_test.rb +39 -0
  93. data/test/unit/synoption/base_option_test.rb +182 -0
  94. data/test/unit/synoption/match_test.rb +61 -0
  95. data/test/unit/synoption/option_test.rb +15 -0
  96. data/test/unit/synoption/set_test.rb +37 -0
  97. data/test/unit/system/command/caching_test.rb +97 -0
  98. data/test/unit/system/command/line_test.rb +33 -0
  99. metadata +199 -0
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/subcommands/base/doc'
5
+
6
+ module PVN; module Subcommands; module Base; end; end; end
7
+
8
+ module PVN::Subcommands::Base
9
+ class Command
10
+ include Loggable
11
+
12
+ @@doc_for_class = Hash.new { |h, k| h[k] = PVN::Subcommands::Documentation.new }
13
+
14
+ class << self
15
+ def getdoc
16
+ @@doc_for_class[self]
17
+ end
18
+
19
+ def subcommands sc
20
+ getdoc.subcommands = sc
21
+ end
22
+
23
+ def description desc
24
+ getdoc.description = desc
25
+ end
26
+
27
+ def usage usg
28
+ getdoc.usage = usg
29
+ end
30
+
31
+ def summary smry
32
+ getdoc.summary = smry
33
+ end
34
+
35
+ def options opts
36
+ getdoc.options.concat opts
37
+ end
38
+
39
+ def optscls
40
+ optmodule = self.to_s.sub %r{::\w+$}, ''
41
+ optcls = optmodule + '::OptionSet'
42
+ optset = instance_eval optcls + '.new'
43
+ getdoc.options.concat optset.options
44
+ end
45
+
46
+ def example *ex
47
+ getdoc.examples << ex
48
+ end
49
+ end
50
+
51
+ def to_doc io
52
+ doc = self.class.getdoc
53
+ doc.write io
54
+ end
55
+
56
+ def show_help
57
+ to_doc $stdout
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'rubygems'
5
+ require 'riel'
6
+
7
+ module PVN; module Subcommands; module Base; end; end; end
8
+
9
+ # this is the same as in pvn/cmddoc.rb
10
+
11
+ module PVN::Subcommands
12
+ class Documentation
13
+ attr_accessor :description
14
+ attr_accessor :usage
15
+ attr_accessor :summary
16
+
17
+ attr_reader :examples
18
+ attr_reader :options
19
+
20
+ def initialize(&blk)
21
+ @subcommands = nil
22
+ @description = nil
23
+ @usage = nil
24
+ @summary = nil
25
+ @options = Array.new
26
+ @examples = Array.new
27
+ if blk
28
+ blk.call
29
+ end
30
+ end
31
+
32
+ def subcommands args = nil
33
+ if args
34
+ @subcommands = args
35
+ end
36
+ @subcommands
37
+ end
38
+
39
+ def subcommands= args
40
+ @subcommands = args
41
+ end
42
+
43
+ def write io = $stdout
44
+ doc = Array.new
45
+
46
+ subcmds = @subcommands
47
+
48
+ subcmdstr = subcmds[0].dup
49
+ if subcmds.size > 1
50
+ subcmdstr << " (" << subcmds[1 .. -1].join(" ") << ")"
51
+ end
52
+
53
+ io.puts subcmdstr + ": " + @description
54
+ io.puts "usage: " + subcmds[0] + " " + @usage
55
+ io.puts ""
56
+ io.puts @summary.collect { |line| " " + line }
57
+
58
+ write_section "options", @options, io do |opt, io|
59
+ option_to_doc opt, io
60
+ end
61
+
62
+ write_section "examples", @examples, io do |ex, io|
63
+ example_to_doc ex, io
64
+ end
65
+ end
66
+
67
+ def write_section name, section, io
68
+ if section.length > 0
69
+ io.puts ""
70
+ io.puts "#{name.capitalize}:"
71
+ io.puts ""
72
+
73
+ section.each do |opt|
74
+ yield opt, io
75
+ end
76
+ end
77
+ end
78
+
79
+ def example_to_doc ex, io
80
+ ex.each_with_index do |line, idx|
81
+ if idx == 0
82
+ io.puts " % #{line}"
83
+ else
84
+ io.puts " #{line}"
85
+ end
86
+ end
87
+ io.puts
88
+ end
89
+
90
+ def option_to_doc opt, io
91
+ opt.to_doc io
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'synoption/set'
5
+ require 'synoption/option'
6
+ require 'synoption/boolean_option'
7
+
8
+ module PVN; module Subcommands; end; end
9
+
10
+ module PVN::Subcommands::Base
11
+ class HelpOption < PVN::BooleanOption
12
+ def initialize args = Hash.new
13
+ super :help, '-h', "display help", nil
14
+ end
15
+ end
16
+
17
+ class OptionSet < PVN::OptionSet
18
+ def paths
19
+ unprocessed
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/io/element'
5
+ require 'pvn/log/formatter/entries_formatter'
6
+ require 'pvn/subcommands/base/doc'
7
+ require 'pvn/subcommands/log/options'
8
+ require 'pvn/subcommands/base/command'
9
+
10
+ module PVN::Subcommands::Log
11
+ class Command < PVN::Subcommands::Base::Command
12
+ include Loggable
13
+
14
+ DEFAULT_LIMIT = 15
15
+
16
+ description "this is a description of log"
17
+ subcommands [ "log" ]
18
+ description "Print log messages for the given files."
19
+ usage "[OPTIONS] FILE..."
20
+ summary [ "Prints the log entries for the given files, with colorized",
21
+ "output. Unlike 'svn log', which prints all log entries, ",
22
+ "'pvn log' prints #{DEFAULT_LIMIT} entries by default.",
23
+ "As with other pvn subcommands, 'pvn log' accepts relative ",
24
+ "revisions."
25
+ ]
26
+
27
+ optscls
28
+
29
+ example "pvn log foo.rb", "Prints the latest #{DEFAULT_LIMIT} log entries for foo.rb."
30
+ example "pvn log -l 25 foo.rb", "Prints 25 log entries for the file."
31
+ example "pvn log -3 foo.rb", "Prints the log entry for revision (HEAD - 3)."
32
+ example "pvn log +3 foo.rb", "Prints the 3rd log entry."
33
+ example "pvn log -l 10 -F", "Prints the latest 10 entries, uncolorized."
34
+ example "pvn log -r 122 -v", "Prints log entry for revision 122, with the files in that change."
35
+
36
+ def initialize args
37
+ options = PVN::Subcommands::Log::OptionSet.new
38
+ options.process args
39
+
40
+ return show_help if options.help
41
+
42
+ path = options.paths[0] || "."
43
+ cmdargs = Hash.new
44
+ cmdargs[:path] = path
45
+
46
+ [ :limit, :verbose, :revision ].each do |field|
47
+ cmdargs[field] = options.send field
48
+ end
49
+
50
+ # we can't cache this, because we don't know if there has been an svn
51
+ # update since the previous run:
52
+ cmdargs[:use_cache] = false
53
+
54
+ logargs = SVNx::LogCommandArgs.new cmdargs
55
+ elmt = PVN::IO::Element.new :local => path || '.'
56
+ log = elmt.log logargs
57
+ nentries = log.entries.size
58
+
59
+ # this should be refined to options.revision.head? && options.limit
60
+ from_head = !options.revision
61
+ from_tail = !options.limit && !options.revision
62
+
63
+ # this dictates whether to show +N and/or -1:
64
+ totalentries = options.limit || options.revision ? nil : nentries
65
+
66
+ ef = PVN::Log::EntriesFormatter.new options.format, log.entries, from_head, from_tail
67
+ puts ef.format
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'synoption/set'
5
+ require 'synoption/option'
6
+ require 'synoption/fixnum_option'
7
+ require 'synoption/boolean_option'
8
+ require 'pvn/subcommands/revision/multiple_revisions_option'
9
+ require 'pvn/subcommands/base/options'
10
+
11
+ module PVN::Subcommands::Log
12
+ DEFAULT_LIMIT = 5
13
+
14
+ class LimitOption < PVN::FixnumOption
15
+ def initialize lmtargs = Hash.new
16
+ super :limit, '-l', "the number of log entries", DEFAULT_LIMIT, :negate => [ %r{^--no-?limit} ]
17
+ end
18
+ end
19
+
20
+ class VerboseOption < PVN::BooleanOption
21
+ def initialize optargs = Hash.new
22
+ super :verbose, '-v', [ "include the files in the change" ], false
23
+ end
24
+ end
25
+
26
+ class FormatOption < PVN::BooleanOption
27
+ def initialize optargs = Hash.new
28
+ super :format, '-f', "use the custom (colorized) format", true, :negate => [ '-F', %r{^--no-?format} ], :as_cmdline_option => nil
29
+ end
30
+ end
31
+
32
+ class OptionSet < PVN::Subcommands::Base::OptionSet
33
+ has_option :revision, PVN::MultipleRevisionsRegexpOption, [ :unsets => :limit ]
34
+ has_option :format, FormatOption
35
+ has_option :help, PVN::Subcommands::Base::HelpOption
36
+ has_option :limit, LimitOption
37
+ has_option :verbose, PVN::BooleanOption, [ :verbose, '-v', [ "include the files in the change" ], false ]
38
+
39
+ def paths
40
+ unprocessed
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'rubygems'
5
+ require 'riel'
6
+ require 'pvn/subcommand/base/clargs'
7
+
8
+ module PVN; module App; module Pct; end; end; end
9
+
10
+ module PVN::App::Pct
11
+ class CmdLineArgs < Subcommand::CmdLineArgs
12
+ include Loggable
13
+
14
+ attr_reader :revision
15
+ attr_reader :path
16
+
17
+ def initialize args
18
+ @limit = nil
19
+ while !args.empty?
20
+ arg = args.shift
21
+ info "arg: #{arg}".cyan
22
+ case arg
23
+ when %r{-r(.*)}
24
+ md = Regexp.last_match
25
+ info "md: #{md}".on_yellow
26
+ @revision = Revision.new :value => md[1]
27
+ else
28
+ @path = arg
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ module PVN; module App; end; end
5
+
6
+ module PVN::App::Pct
7
+ class Command
8
+ include Loggable
9
+
10
+ def initialize args
11
+ clargs = PVN::App::Pct::CmdLineArgs.new args
12
+ info "clargs: #{clargs}"
13
+
14
+ elmt = PVN::IO::Element.new :local => clargs.path || '.'
15
+ info "elmt: #{elmt}".red
16
+
17
+ stats = { :modified => 0, :added => 0, :deleted => 0 }
18
+
19
+ if elmt.directory?
20
+ info "elmt.directory?: #{elmt.directory?}"
21
+
22
+ # $$$ todo: recurse even when local has been removed (this is the
23
+ # awaited "pvn find").
24
+
25
+ changed = Array.new
26
+ elmt.local.find do |fd|
27
+ info "fd: #{fd}; #{fd.class}"
28
+ Find.prune if fd.rootname.to_s == '.svn'
29
+ if fd.file?
30
+ subelmt = PVN::IO::Element.new :local => fd.to_s
31
+ info "subelmt: #{subelmt}"
32
+ status = subelmt.status
33
+ info "status: #{status}".red
34
+ end
35
+ end
36
+
37
+ # info "changed: #{changed}"
38
+ elsif elmt.file?
39
+ info "elmt.local: #{elmt.local}".cyan
40
+
41
+ status = elmt.status
42
+ info "status: #{status}"
43
+
44
+ case status
45
+ when "added"
46
+ info "elmt: #{elmt}".green
47
+ when "modified"
48
+ info "elmt: #{elmt}".yellow
49
+ when "deleted"
50
+ info "elmt: #{elmt}".red
51
+ else
52
+ info "elmt: #{elmt}".cyan
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/subcommands/revision/revision_regexp_option'
5
+
6
+ module PVN
7
+ # A revision option with multiple values.
8
+ class MultipleRevisionsRegexpOption < RevisionRegexpOption
9
+ REVISION_DESCRIPTION = [ "revision to apply.",
10
+ "ARG can be relative, of the form:",
11
+ " +N : N revisions from the BASE",
12
+ " -N : N revisions from the HEAD,",
13
+ " when -1 is the previous revision" ,
14
+ "Multiple revisions can be specified." ,
15
+ ]
16
+
17
+ def set_value val
18
+ currval = value
19
+ if currval
20
+ super [ currval, val ].flatten
21
+ else
22
+ super [ val ]
23
+ end
24
+ end
25
+
26
+ def resolve_value optset, unprocessed
27
+ newvalues = Array.new
28
+ currvalues = value
29
+
30
+ currvalues.each do |currval|
31
+ md = TAG_RE.match currval
32
+ if md
33
+ convval = md[2] ? md[3] : relative_to_absolute(currval, unprocessed[0])
34
+ newvalues << convval
35
+ else
36
+ newvalues << currval
37
+ end
38
+ end
39
+
40
+ @value = newvalues
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'riel'
5
+ require 'rubygems'
6
+ require 'synoption/option'
7
+ require 'svnx/log/command'
8
+ require 'pvn/revision/entry'
9
+
10
+ module PVN
11
+ class RevisionOption < Option
12
+ attr_accessor :fromdate
13
+ attr_accessor :todate
14
+
15
+ REVISION_DESCRIPTION = [ "revision to apply.",
16
+ "ARG can be relative, of the form:",
17
+ " +N : N revisions from the BASE",
18
+ " -N : N revisions from the HEAD,",
19
+ " when -1 is the previous revision" ,
20
+ ]
21
+
22
+ POS_NEG_NUMERIC_RE = Regexp.new('^[\-\+]\d+$')
23
+
24
+ def initialize revargs = Hash.new
25
+ @fromdate = nil
26
+ @todate = nil
27
+ super :revision, '-r', REVISION_DESCRIPTION, nil, revargs
28
+ end
29
+
30
+ def to_svn_revision_date date
31
+ '{' + date.to_s + '}'
32
+ end
33
+
34
+ def value
35
+ val = nil
36
+ if @fromdate
37
+ val = to_svn_revision_date @fromdate
38
+ end
39
+
40
+ if @todate
41
+ val = val ? val + ':' : ''
42
+ val += to_svn_revision_date @todate
43
+ end
44
+
45
+ if val
46
+ val
47
+ else
48
+ super
49
+ end
50
+ end
51
+
52
+ def head?
53
+ value.nil? || value == 'HEAD'
54
+ end
55
+
56
+ def resolve_value optset, unprocessed
57
+ val = value
58
+ if POS_NEG_NUMERIC_RE.match val
59
+ @value = relative_to_absolute val, unprocessed[0]
60
+ end
61
+ end
62
+
63
+ def relative_to_absolute rel, path
64
+ logforrev = SVNx::LogCommandLine.new path
65
+ logforrev.execute
66
+
67
+ xmllines = logforrev.output
68
+
69
+ reventry = PVN::Revision::Entry.new :value => rel, :xmllines => xmllines
70
+ revval = reventry.value.to_s
71
+ revval
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/subcommands/revision/revision_option'
5
+
6
+ module PVN
7
+ # A revision that is also set by -N and +N.
8
+ class RevisionRegexpOption < PVN::RevisionOption
9
+ TAG_RE = Regexp.new('^(?:([\-\+]\d+)|(-r(.+)))$')
10
+
11
+ REVISION_DESCRIPTION = [ "revision to apply.",
12
+ "ARG can be relative, of the form:",
13
+ " +N : N revisions from the BASE",
14
+ " -N : N revisions from the HEAD,",
15
+ " when -1 is the previous revision" ,
16
+ ]
17
+
18
+ def initialize revargs = Hash.new
19
+ # info "revargs: #{revargs}"
20
+ revargs[:regexp] = TAG_RE
21
+ super
22
+ end
23
+
24
+ def resolve_value optset, unprocessed
25
+ val = value
26
+ # info "val: #{val}"
27
+
28
+ md = TAG_RE.match val
29
+ # info "md: #{md.inspect}"
30
+
31
+ if md && md[3]
32
+ # info "md[3]: #{md[3]}"
33
+ @value = md[3]
34
+ end
35
+
36
+ super
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'riel'
5
+ require 'rubygems'
6
+ require 'system/cachecmd'
7
+
8
+ module PVN
9
+ # A command that is a simple pass-through (more or less)
10
+ # to a svn command.
11
+ class SVNCommand < CachableCommand
12
+ def self.revision_from_args optset, cmdargs
13
+ require 'pvn/revision'
14
+ Revision.revision_from_args optset, cmdargs
15
+ end
16
+
17
+ def initialize args = Hash.new
18
+ super
19
+ info "self: #{self}"
20
+ end
21
+
22
+ def to_svn_command fullcmdargs
23
+ [ "svn", self.class::COMMAND ] + fullcmdargs
24
+ end
25
+
26
+ def command
27
+ @svncmd.join " "
28
+ end
29
+
30
+ def execute
31
+ cmdline = options.as_command_line
32
+ @svncmd = to_svn_command cmdline
33
+ info "@svncmd: #{@svncmd}"
34
+ cmd = @svncmd.join(" ")
35
+ sysexec cmd
36
+ # @output = IO.popen(cmd).readlines
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'rubygems'
5
+ require 'riel'
6
+ require 'singleton'
7
+
8
+ module PVN
9
+ class Environment
10
+ include Singleton
11
+
12
+ DEFAULT_CACHE_DIR = '/tmp/pvn_testing_cache_dir'
13
+
14
+ attr_accessor :cache_dir
15
+
16
+ def initialize
17
+ super
18
+
19
+ @cache_dir = DEFAULT_CACHE_DIR
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'rubygems'
5
+ require 'riel'
6
+ require 'pvn/base/util'
7
+ require 'pvn/svn/svninfo'
8
+
9
+ module PVN
10
+ class SVNElement
11
+ include Loggable
12
+ attr_reader :name
13
+
14
+ require 'pvn/svn/svnroot'
15
+
16
+ def initialize args
17
+ RIEL::Log.info "args: #{args}"
18
+
19
+ # $$$ this should handle local paths and full urls.
20
+
21
+ # technically, name is what svn info calls "URL"
22
+ name = args[:name]
23
+ if name.nil? && (fname = args[:filename])
24
+ name = fname
25
+
26
+ if false
27
+ debug "fname : #{fname}"
28
+
29
+ fullpath = Pathname.new(fname).expand_path
30
+ debug "fullpath: #{fullpath}".yellow
31
+
32
+ svnroot = SVNRootElement.new
33
+ debug "svnroot: #{svnroot}"
34
+ sri = svnroot.info
35
+ debug "svnroot.info[:url]: #{sri[:url]}"
36
+ debug "svnroot.info[:path]: #{sri[:path]}"
37
+ name = svnroot.info[:url] + '/' + fname
38
+ debug "name: #{name}"
39
+ end
40
+ end
41
+
42
+ @name = name
43
+ RIEL::Log.info "@name: #{@name}".green
44
+ end
45
+
46
+ def to_command subcmd, revcl, *args
47
+ cmd = "svn #{subcmd}"
48
+ debug "cmd: #{cmd}"
49
+ debug "args: #{args}"
50
+ args = args.flatten
51
+
52
+ # revcl is [ -r, 3484 ]
53
+ if revcl
54
+ cmd << " -r #{revcl}"
55
+ end
56
+ cmd << " " << Util::quote_list(args)
57
+ debug "cmd: #{cmd}".cyan
58
+ cmd
59
+ end
60
+
61
+ def info
62
+ SVN::Info.new :name => @name
63
+ end
64
+
65
+ def line_count revision = nil
66
+ lc = nil
67
+
68
+ cmd = to_command "cat", revision, @name
69
+ ::IO.popen cmd do |io|
70
+ lc = io.readlines.size
71
+ debug "lc: #{lc.inspect}"
72
+ end
73
+
74
+ lc
75
+ end
76
+
77
+ def to_s
78
+ @name.to_s
79
+ end
80
+
81
+ def inspect
82
+ @name
83
+ end
84
+
85
+ def <=>(other)
86
+ @name <=> other.name
87
+ end
88
+ end
89
+ end