rscm-accurev 0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/Rakefile +7 -76
  2. data/TODO +3 -17
  3. data/lib/rscm/accurev.rb +1 -13
  4. data/lib/rscm/scm/accurev/#command.rb# +95 -0
  5. data/lib/rscm/scm/accurev/api.rb +77 -258
  6. data/lib/rscm/scm/accurev/command.rb +40 -97
  7. data/lib/rscm/scm/accurev/filterio.rb +4 -6
  8. data/lib/rscm/scm/accurev/xml.rb +11 -199
  9. data/test/t_command.rb +11 -59
  10. data/test/t_load.rb +0 -1
  11. data/test/t_scrubio.rb +6 -1
  12. data/{apitest.rb → test.rb} +0 -1
  13. data/{test/eg/update-newwksp.xml → testing.log} +138 -0
  14. metadata +15 -57
  15. data/STATUS +0 -63
  16. data/bumprelease.sh +0 -13
  17. data/lib/rscm/scm/accurev/api.rb.mine +0 -382
  18. data/lib/rscm/scm/accurev/api.rb.r263 +0 -364
  19. data/lib/rscm/scm/accurev/api.rb.r265 +0 -393
  20. data/lib/rscm/scm/accurev/exception.rb +0 -38
  21. data/lib/test/unit/ui/xml/testrunner.rb +0 -165
  22. data/lib/test/unit/ui/xml/xmltestrunner.xslt +0 -79
  23. data/test/coverage/analyzer.rb +0 -127
  24. data/test/coverage/c_loader.rb +0 -34
  25. data/test/coverage/cover.rb +0 -91
  26. data/test/coverage/coverage_loader.rb +0 -21
  27. data/test/coverage/coveragetask.rb +0 -38
  28. data/test/coverage/index_tmpl.html +0 -42
  29. data/test/coverage/template.html +0 -36
  30. data/test/eg/ac-files.xml +0 -172
  31. data/test/eg/ac-pop.txt +0 -195
  32. data/test/eg/files-various-states.xml +0 -188
  33. data/test/eg/hist-oneweek-all.xml +0 -1483
  34. data/test/eg/hist-oneweek-external.xml +0 -246
  35. data/test/eg/hist-oneweek-promotes.xml +0 -1092
  36. data/test/eg/info.txt +0 -14
  37. data/test/eg/stat-a-various.xml +0 -1789
  38. data/test/eg/stat-m.xml +0 -13
  39. data/test/eg/stat-overlap.xml +0 -13
  40. data/test/eg/stat-x.xml +0 -20
  41. data/test/eg/update-i-mods-and-updates-and-overlap.xml +0 -73
  42. data/test/eg/update-i-nochanges.xml +0 -8
  43. data/test/eg/update-i-stale.xml +0 -0
  44. data/test/eg/update-i-updates.xml +0 -125
  45. data/test/eg/update-nochanges.xml +0 -7
  46. data/test/eg/update-stale.xml +0 -12
  47. data/test/eg/update-updates.xml +0 -147
  48. data/test/t_api.rb +0 -163
  49. data/test/t_xmlmapper.rb +0 -75
data/Rakefile CHANGED
@@ -5,9 +5,8 @@ require 'rake/testtask'
5
5
  require 'rake/rdoctask'
6
6
  require 'rake/packagetask'
7
7
  require 'rake/gempackagetask'
8
- require 'tracer'
9
8
 
10
- # this rakefile originally borrowed shamelessly from rscm
9
+ # rakefile borrowed shamelessly from rscm
11
10
 
12
11
  PKG_NAME = 'rscm-accurev'
13
12
  PKG_BUILD = ENV['PKG_BUILD'] ? '.'+ENV['PKG_BUILD'] : ''
@@ -18,68 +17,20 @@ PKG_SUMMARY = 'RSCM::Accurev - RSCM API for Accurev'
18
17
  desc "Default Task"
19
18
  task :default => [ :test, :gem ]
20
19
 
21
- RAKEVERSION =~ /^(\d+)\.(\d+).(.*)/
22
- rake_maj,rake_min,rake_patch = $1,$2,$3
23
- if rake_maj.to_f < 1 and rake_min.to_f <= 5 and rake_patch.to_f <= 4
24
- # use this for rake <= 0.5.4:
25
- task :test => [ :plaintest ]
26
- HAVEXMLTEST = false
27
- else
28
- # rake 0.5.4.6+ (0.5.5)
29
- task :test => [ :backup_testresults, :xmltest ]
30
- HAVEXMLTEST = true
31
- end
32
-
33
- # define a task(s) to run tests
34
-
35
- test_files = FileList.new( "test/**/t_*.rb" )
36
- TEST_OUTPUT = "html/test"
37
-
38
- Rake::TestTask.new( :plaintest ) do |t|
20
+ # define a task to run tests
21
+ Rake::TestTask.new do |t|
39
22
  t.libs << "test"
40
- t.test_files = test_files
23
+ t.test_files = FileList.new( "test/**/t_*.rb" )
41
24
  t.verbose = true
42
25
  end
43
26
 
44
- if HAVEXMLTEST
45
- # rake<0.5.5 requires a patch to rake_test_loader.rb to exclude options
46
- # rake<0.5.5 requires a patch to rake/testtask.rb to support ruby_opts
47
- # (see doc/patches)
48
- Rake::TestTask.new( :xmltest ) do |t|
49
- t.libs << "test"
50
- t.test_files = test_files
51
- t.verbose = true
52
- t.ruby_opts << '-rtest/unit/ui/xml/testrunner'
53
- ENV['XMLTEST_OUTPUT'] = "#{TEST_OUTPUT}/testresults.xml"
54
- t.options = "--runner=xml"
55
- end
56
- end # !HAVEXMLTEST
57
-
58
-
59
- # backs up existing testresults.xml files in test target dir
60
- task :backup_testresults do
61
- unless File.exist?( TEST_OUTPUT )
62
- mkdir_p( TEST_OUTPUT )
63
- end
64
- old = "#{TEST_OUTPUT}/testresults.xml"
65
- if File.exist?( old )
66
- stat = File.stat( old )
67
- bak = stat.ctime.strftime('testresults-%Y%m%d-%H%M.xml')
68
- new = "#{TEST_OUTPUT}/#{bak}"
69
- #puts "...Backing up previous test results to #{new}"
70
- mv( old, new )
71
- end
72
- end
73
-
74
27
  # define a task to create rdocs
75
28
  # keep a reference to it so we can reuse it in the gempkg task
76
- rd_task = Rake::RDocTask.new( :rdoc ) do |rdoc|
29
+ rd_task = Rake::RDocTask.new do |rdoc|
77
30
  rdoc.title = PKG_SUMMARY
78
- rdoc.template = "doc/jamis.rb" # so nice
79
31
  rdoc.options << '--line-numbers' << '--inline-source'
80
- rdoc.rdoc_files.include( 'STATUS' )
32
+ #rdoc.rdoc_files.include( 'TODO' )
81
33
  rdoc.rdoc_files.include( 'lib/**/*.rb' )
82
- rdoc.rdoc_files.include( 'doc/*.rd' )
83
34
  end
84
35
 
85
36
  PKG_FILES = FileList[
@@ -113,25 +64,5 @@ else
113
64
  end
114
65
  end
115
66
 
116
- desc "Delete all generated files (includes built packages)"
117
- task :realclean do
118
- f = FileList[ 'pkg', 'html', 'doc/test*.xml' ]
119
- rm_rf f
120
- end
121
-
122
- desc "Coverage! (still a big hack)"
123
- task :coverage => [ :test_coverage, :coverage_summary ]
124
67
 
125
- Rake::TestTask.new( :test_coverage ) do |t|
126
- t.libs << "test"
127
- t.test_files = test_files
128
- t.verbose = true
129
- def t.rake_loader
130
- 'test/coverage/c_loader.rb'
131
- end
132
- end
133
-
134
- task :coverage_summary do
135
- # too many options!@
136
- ruby "test/coverage/analyzer.rb xxx.trace html/coverage test/coverage/template.html test/coverage/index_tmpl.html"
137
- end
68
+
data/TODO CHANGED
@@ -1,13 +1,13 @@
1
1
  # todo for rscm/scm/accurev.rb
2
2
 
3
- api - checkout
3
+ **api - checkout
4
4
  - there is no rscm-api update() (only checkout-to-existing-ws)
5
5
  - `pop`, `update`
6
6
 
7
7
  **api - revisions
8
8
  - `hist` (others?)
9
9
 
10
- api - diff
10
+ **api - diff
11
11
  - `diff` (yukx)
12
12
 
13
13
  api - import_central, create_central
@@ -21,23 +21,9 @@ api - triggers?
21
21
  **api - identifiers (Time or revision) to ac format
22
22
  - is this even always applicable? does stat/update take limits?
23
23
 
24
- # xml - s/FileStatus/FileData/
24
+ xml - s/FileStatus/FileData/
25
25
 
26
26
  api - checkout(Time.infinite) just does update
27
27
  checkout(x) only works if ws not exist
28
28
  unless it implies nuke-and-re-checkout (slow)
29
29
 
30
- api - need ac_update which returns an acresponse
31
-
32
- api - update: elements list should not contain directories
33
-
34
- api - update: elements list should probably not include removed files
35
-
36
- # command - Command.working_dir is bad: should use with_working_dir()
37
-
38
- *** api - checkout() should use `pop` instead of `mkws`, unless
39
- user *really* wants it
40
- - yeargh... how does update work with pop? just nuke and/or overwrite?
41
-
42
- ac pop -R -v orbitz-host-gt3-0-rc -L . . > ~/cheese/rscm-accurev/test/eg/ac-pop.txt
43
-
data/lib/rscm/accurev.rb CHANGED
@@ -1,18 +1,6 @@
1
- #!/usr/bin/env ruby
1
+ require 'rubygems'
2
2
  require 'rscm/scm/accurev/api'
3
3
  require 'rscm/scm/accurev/command'
4
4
  require 'rscm/scm/accurev/xml'
5
5
  require 'rscm/scm/accurev/filterio'
6
6
 
7
- module RSCM
8
- #
9
- # == module RSCM::Accurev
10
- #
11
- # Namespace for accurev api classes and utils.
12
- #
13
- # See RSCM::Accurev::API.
14
- #
15
- module Accurev
16
- VERSION = '0.0.5'
17
- end
18
- end
@@ -0,0 +1,95 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'singleton'
4
+
5
+ module RSCM
6
+ module Accurev
7
+
8
+ class Command
9
+ include Singleton
10
+ #Thread.current[:foo]
11
+
12
+ attr_accessor :debug, :debug_to, :accurev, :working_dir
13
+
14
+ def initialize( working_dir="." )
15
+ @debug = false
16
+ @debug_to = STDOUT
17
+ @accurev = "accurev"
18
+ @working_dir = working_dir
19
+ end
20
+
21
+ def accurev_cmdline( cmd, *opts )
22
+ return "#{@accurev} #{cmd} #{opts.join(' ')}";
23
+ end
24
+
25
+ # Execute the given accurev subcommand, and return its
26
+ # output as a plain uninterpreted string.
27
+ # Not all accurev subcommands (eg, `accurev info`) support
28
+ # `-fx` for xml output.
29
+ def accurev_nofx( cmd, *opts )
30
+ # nativepath_to_filepath is actually generic to native
31
+ dir = PathConverter.nativepath_to_filepath( @working_dir )
32
+ dir = File.expand_path( dir )
33
+ with_working_dir( dir ) do
34
+ cmdline = self.accurev_cmdline( cmd, opts )
35
+ if @debug
36
+ @debug_to.puts("ac> #{cmdline}")
37
+ end
38
+ Better.popen( cmdline ) do |stdout|
39
+ return stdout.read()
40
+ end
41
+ end
42
+ end
43
+
44
+ # Execute the given accurev subcommand, and return its
45
+ # output as an REXML document. The options list to the command
46
+ # will automatically have `-fx` prepended, to specify xml output.
47
+ # Certain quirks in <AcResponse>-type documents will be
48
+ # corrected (see Accurev::AcXMLScrubIO).
49
+ def accurev( cmd, *opts )
50
+ # nativepath_to_filepath is actually generic to native
51
+ dir = PathConverter.nativepath_to_filepath( @working_dir )
52
+ dir = File.expand_path( dir )
53
+ opts << "-fx"
54
+ with_working_dir( dir ) do
55
+ cmdline = self.accurev_cmdline( cmd, opts )
56
+ if @debug
57
+ @debug_to.puts("ac> #{cmdline}")
58
+ end
59
+ Better.popen( cmdline ) do |stdout|
60
+ output = stdout.read()
61
+ if @debug
62
+ @debug_to.puts( "raw>\n#{output}" )
63
+ end
64
+ begin
65
+ return REXML::Document.new( AcXMLScrubIO.new( output ) )
66
+ rescue Exception => e
67
+ raise "Unexpected output from #{cmdline}: #{e}"
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ # Execute the given accurev subcommand using +accurev+,
74
+ # and return the <element> REXML elements from the
75
+ # resulting document.
76
+ # For ac commands which emit the common <elements> format.
77
+ def accurev_elements( mapclass, cmd, *opts )
78
+ doc = self.accurev( cmd, opts )
79
+ if @debug
80
+ @debug_to.puts( doc )
81
+ end
82
+ if doc.elements.size==0
83
+ raise "Unexpected output from #{cmd}: #{doc}"
84
+ end
85
+ doc.elements.each( "/AcResponse/element" ) do |e|
86
+ o = mapclass.new( e )
87
+ yield o
88
+ end
89
+ end
90
+
91
+ end
92
+ end
93
+ end
94
+
95
+