rscm-accurev 0.0.1 → 0.0.2

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.
@@ -9,6 +9,7 @@ require 'rscm/scm/accurev'
9
9
  #files; puts "#{f.location}\t\t#{f.status}"
10
10
  #files; end
11
11
 
12
+ # yes, i cannot spell, the dir is "hirdcar":
12
13
  ac = RSCM::Accurev.new( '/home/gfast/dev/orbitz-api-hirdcar-0-rc' )
13
14
  ac.backing_stream = "orbitz-api-hiredcar-0-rc"
14
15
  ac.workspace_stream = "orbitz-api-hiredcar-0-rc-testing_gfast"
data/bumprelease.sh ADDED
@@ -0,0 +1,10 @@
1
+ #!/bin/sh
2
+
3
+ # gee, i bet you could stick this in the rakefile...
4
+
5
+ LAST=`cat .version.minor`
6
+ MINOR=$(( $LAST + 1 ))
7
+
8
+ PKG_BUILD=$MINOR rake package gem && \
9
+ echo $MINOR > .version.minor
10
+
@@ -0,0 +1,226 @@
1
+ # -*- ruby -*-
2
+ require 'rubygems'
3
+ require 'rscm/base'
4
+ require 'rscm/path_converter'
5
+ require 'rexml/document'
6
+ require 'rscm/scm/accurev/xml'
7
+ require 'rscm/scm/accurev/filterio'
8
+ require 'rscm/scm/accurev/command'
9
+
10
+ module RSCM
11
+ module Accurev; end
12
+ end
13
+
14
+ module RSCM::Accurev
15
+
16
+ class AccurevException < Exception ; end
17
+
18
+ # Indicates a failure of the update command due to unkept local modifications
19
+ class StaleWorkspaceError < AccurevException; end
20
+
21
+ # RSCM implementation for Accurev (http://www.accurev.com/).
22
+ #
23
+ # Requires an accurev cli executable on the path, and the correct
24
+ # environment for ac server/principal/password.
25
+ #
26
+ class API < RSCM::Base
27
+ register self
28
+
29
+ ann :description => "Accurev Depot"
30
+ attr_accessor :depot
31
+
32
+ ann :description => "Backing Stream (autodetected)"
33
+ attr_accessor :backing_stream
34
+
35
+ ann :description => "Workspace Stream"
36
+ attr_accessor :workspace_stream
37
+
38
+ # defined in Base
39
+ # ann :description => "Filesystem Path to Workspace"
40
+ # attr_accessor :checkout_dir
41
+
42
+ STATUSES = {
43
+ '(backed)' => :backed,
44
+ '(external)' => :external,
45
+ '(modified)' => :modified,
46
+ '(kept)' => :kept,
47
+ '(defunct)' => :defunct,
48
+ '(missing)' => :missing,
49
+ '(stranded)' => :stranded,
50
+ '(overlap)' => :overlap
51
+ }
52
+
53
+ def initialize( checkout_dir=nil, depot=nil, workspace_stream=nil )
54
+ @depot = depot
55
+ @checkout_dir = checkout_dir
56
+ @workspace_stream = workspace_stream
57
+ @backing_stream = nil # will be pulled from files cmd output
58
+ end
59
+
60
+ def name()
61
+ return "Accurev"
62
+ end
63
+
64
+ # Accurev operations are atomic:
65
+ def transactional?
66
+ return true
67
+ end
68
+
69
+ # "Adds +relative_filename+ to the working copy."
70
+ def add( relative_filename )
71
+ raise "XXX implement me"
72
+ end
73
+
74
+ def edit( relative_filename )
75
+ # NOP - not required for ac
76
+ end
77
+
78
+ # "Returns a Revisions object for the period specified ... (inclusive)."
79
+ def revisions( from_identifier, to_identifier=Time.infinity )
80
+ raise "XXX implement me"
81
+ end
82
+
83
+ # default impl depends on a correct impl of revisions()
84
+ # def uptodate?( identifier=nil )
85
+ #
86
+ # end
87
+
88
+ # def checked_out? - base
89
+
90
+ # accurev actually does have triggers, but I haven't implemented that yet
91
+ def supports_trigger?
92
+ false
93
+ end
94
+
95
+ # def diff() XXX
96
+
97
+
98
+ # --- ac specific
99
+
100
+ def ac_files( relative_path )
101
+ cmd = Command.instance
102
+ # there must be a better way to do this yield->yield loopage
103
+ obj = []
104
+ cmd.accurev_elements( StatData, "files", relative_path ) do |fd|
105
+ yield fd if block_given?
106
+ obj << fd
107
+ end
108
+ return obj
109
+ end
110
+
111
+ def ac_keep( files=[], message="" )
112
+ raise "XXX implement me"
113
+ end
114
+
115
+ def ac_promote( files=[], message="" )
116
+ raise "XXX implement me"
117
+ end
118
+
119
+ def ac_update( relative_path="." )
120
+ d = accurev( "update", relative_path )
121
+ if xxx_error_stale
122
+ raise StaleWorkspaceError.new( "#{relative_path} is stale -- keep/anchor all changes and re-update" )
123
+ end
124
+ end
125
+
126
+ def ac_purge( files=[] )
127
+ raise "XXX implement me"
128
+ end
129
+
130
+ def ac_revert( files=[] )
131
+ raise "XXX implement me"
132
+ end
133
+
134
+ def ac_move( current_file, new_file )
135
+ raise "XXX implement me"
136
+ end
137
+
138
+ # ac info: shows eg, backing stream
139
+ # but doesn't support -fx!
140
+
141
+ # ac mkws
142
+ # -b orbitz-host-gt3-0-impl
143
+ # -w orbitz-host-gt3-0-impl-test2_gfast
144
+ # -l `pwd`
145
+ # - does not support fx (argh!@)
146
+ # - does not pop
147
+ #
148
+
149
+ # diff: /usr/local/bin/acdiff (!) --fx
150
+ # (after an ac cat on the backed file)
151
+ # (eg, no in-process diffing ala cvs diff)
152
+ # lists modified lines in xml
153
+
154
+ # checkout():
155
+ # "Checks out or updates[!] contents from a central SCM
156
+ # to +checkout_dir+ - a local working copy."
157
+ #
158
+ # "The +to_identifier+ parameter may be optionally specified to
159
+ # obtain files up to a particular time or label."
160
+ #
161
+ # For accurev, this:
162
+ # * checks to see if @checkout_dir exists and appears checked out.
163
+ # If it's already checked out, this calls update().
164
+ # * otherwise, this creates a new workspace stream and populates it
165
+ # at @checkout_dir.
166
+ #
167
+ # Unknown: support for +to_identifier+ (esp for update)?
168
+ #
169
+ # This method yields files in the workspace and doesn't need to be
170
+ # overridden.
171
+ # The checkout_silent() method does the actual work.
172
+ #
173
+ # Only yields files, not directories
174
+ def checkout( to_identifier=Time.infinite )
175
+ co = PathConverter.nativepath_to_filepath( @checkout_dir )
176
+ unless File.exists?( co )
177
+ puts "> creating new workspace..."
178
+ if @backing_stream.nil?
179
+ raise "Backing stream must be set"
180
+ end
181
+ if @workspace_stream.nil?
182
+ raise "Workspace stream must be set"
183
+ end
184
+ mkws_out = self.accurev_nofx( "mkws",
185
+ "-b", @backing_stream,
186
+ "-w", @workspace_stream,
187
+ "-l", co )
188
+ # sucks:
189
+ if ( mkws_out =~ /already exists/ )
190
+ raise AccurevException.new( mkws_out )
191
+ end
192
+ end
193
+ puts "> Updating workspace.."
194
+ self.update( to_identifier )
195
+ end
196
+
197
+ def update( to_identifier=Time.infinite )
198
+ co = PathConverter.nativepath_to_filepath( @checkout_dir )
199
+ unless File.exists?( co )
200
+ raise AccurevException.new( "Workspace does not exist!" )
201
+ end
202
+ updated = []
203
+ with_working_dir( co ) do
204
+ # XXX Command...
205
+ accurev_elements( UpdateData, "update" ) do |up|
206
+ yield up.location
207
+ updated << up.location
208
+ end
209
+ end
210
+ return updated
211
+ end
212
+
213
+
214
+ # --- internals
215
+
216
+ private
217
+
218
+ # Takes a status flags line (eg, "(modified)(kept)")
219
+ # and returns a list of status flags.
220
+ def map_status( status_line )
221
+ l = status_line.split( " " ).map {|x| x.trim}
222
+ end
223
+
224
+ end
225
+
226
+ end
@@ -98,19 +98,14 @@ module RSCM::Accurev
98
98
  # --- ac specific
99
99
 
100
100
  def ac_files( relative_path )
101
- out = self.accurev( "files", relative_path )
102
- # validate
103
- raise AccurevException.new("Failed to get response") if out.nil?
104
- if ( out.root.name!="AcResponse" )
105
- raise AccurevException.new("Invalid response")
101
+ cmd = Command.instance
102
+ # there must be a better way to do this yield->yield loopage
103
+ obj = []
104
+ cmd.accurev_elements( StatData, "files", relative_path ) do |fd|
105
+ yield fd if block_given?
106
+ obj << fd
106
107
  end
107
- files = []
108
- out.elements.each( "/AcResponse/element" ) do |e|
109
- f = FileStatus.new( e )
110
- yield f if block_given?
111
- files << f
112
- end
113
- return files
108
+ return obj
114
109
  end
115
110
 
116
111
  def ac_keep( files=[], message="" )
@@ -1,20 +1,26 @@
1
1
  # -*- ruby -*-
2
2
 
3
- require 'singleton'
4
-
5
3
  module RSCM
6
4
  module Accurev
7
5
 
6
+ #
7
+ # Executes accurev commands and deals with the output.
8
+ # This class is a thread local singleton: each thread
9
+ # calling +Command.instance+ gets a different instance.
10
+ #
8
11
  class Command
9
- include Singleton
10
12
 
11
13
  attr_accessor :debug, :debug_to, :accurev, :working_dir
12
14
 
13
- def initialize( working_dir="." )
15
+ # map of xml element types to classes
16
+ # used by accurev_element to return a list of objects
17
+ attr_accessor :classmap
18
+
19
+ def initialize()
14
20
  @debug = false
15
21
  @debug_to = STDOUT
16
22
  @accurev = "accurev"
17
- @working_dir = working_dir
23
+ @working_dir = "."
18
24
  end
19
25
 
20
26
  def accurev_cmdline( cmd, *opts )
@@ -81,13 +87,47 @@ module RSCM
81
87
  if doc.elements.size==0
82
88
  raise "Unexpected output from #{cmd}: #{doc}"
83
89
  end
90
+ objs = []
84
91
  doc.elements.each( "/AcResponse/element" ) do |e|
85
92
  o = mapclass.new( e )
86
- yield o
93
+ yield o if block_given?
94
+ objs << o
95
+ end
96
+ return objs
97
+ end
98
+
99
+ # Retrieve this thread's +Command+ instance.
100
+ #
101
+ # eg:
102
+ # cmd = Command.instance
103
+ # eg:
104
+ # Command.instance do |cmd|
105
+ # cmd.workspace_dir = "/var/tmp"
106
+ # end
107
+ #
108
+ def Command.instance()
109
+ if Thread.current[ :RSCM_ACCUREV_COMMAND ].nil?
110
+ Thread.current[ :RSCM_ACCUREV_COMMAND ] = Command.new
87
111
  end
112
+ yield Thread.current[ :RSCM_ACCUREV_COMMAND ] if block_given?
113
+ return Thread.current[ :RSCM_ACCUREV_COMMAND ]
114
+ end
115
+
116
+ # Discard the current thread's Command object.
117
+ # The next call to +Command.instance+ in this thread will
118
+ # return a new instance configured with the defaults.
119
+ def Command.discard()
120
+ Thread.current[ :RSCM_ACCUREV_COMMAND ] = nil
121
+ end
122
+
123
+ # new() is marked private, use Command.instance().
124
+ private
125
+ def new( *args )
126
+ super(args)
88
127
  end
89
128
 
90
- end
129
+ end # class Command
130
+
91
131
  end
92
132
  end
93
133
 
@@ -21,7 +21,7 @@ module RSCM::Accurev
21
21
  end
22
22
 
23
23
  # Data from "accurev file" command:
24
- class FileStatus < ElementBackedClass
24
+ class StatData < ElementBackedClass
25
25
  element_name 'element'
26
26
  attr_accessor :location, :status, :dir, :id
27
27
  attr_accessor :elemType, :namedVersion, :Virtual, :Real
@@ -0,0 +1,172 @@
1
+ <?xml version="1.0"?>
2
+ <AcResponse
3
+ Command="stat"
4
+ Directory="/home/gfast/dev/orbitz-host-gt3-0-impl">
5
+ <element
6
+ location="./.acignore"
7
+ dir="no"
8
+ id="197"
9
+ elemType="text"
10
+ Virtual="7/2"
11
+ namedVersion="orbitz-host-gt3-0-impl/2"
12
+ Real="8/2"
13
+ status="(backed)"/>
14
+ <element
15
+ location="./apps"
16
+ dir="yes"
17
+ id="6"
18
+ elemType="dir"
19
+ Virtual="4/1"
20
+ namedVersion="orbitz-host-gt3-0-rc/1"
21
+ Real="6/1"
22
+ status="(backed)"/>
23
+ <element
24
+ location="./bin"
25
+ dir="yes"
26
+ id="20"
27
+ elemType="dir"
28
+ Virtual="4/1"
29
+ namedVersion="orbitz-host-gt3-0-rc/1"
30
+ Real="6/1"
31
+ status="(backed)"/>
32
+ <element
33
+ location="./build"
34
+ dir="yes"
35
+ id="34"
36
+ elemType="dir"
37
+ Virtual="4/1"
38
+ namedVersion="orbitz-host-gt3-0-rc/1"
39
+ Real="6/1"
40
+ status="(backed)"/>
41
+ <element
42
+ location="./build-deps.xml"
43
+ dir="no"
44
+ id="2"
45
+ elemType="text"
46
+ Virtual="4/1"
47
+ namedVersion="orbitz-host-gt3-0-rc/1"
48
+ Real="6/1"
49
+ status="(backed)"/>
50
+ <element
51
+ location="./build.properties"
52
+ dir="no"
53
+ id="3"
54
+ elemType="text"
55
+ Virtual="4/1"
56
+ namedVersion="orbitz-host-gt3-0-rc/1"
57
+ Real="6/1"
58
+ status="(backed)"/>
59
+ <element
60
+ location="./build.xml"
61
+ dir="no"
62
+ id="4"
63
+ elemType="text"
64
+ Virtual="7/1"
65
+ namedVersion="orbitz-host-gt3-0-impl/1"
66
+ Real="8/1"
67
+ status="(backed)"/>
68
+ <element
69
+ location="./conf"
70
+ dir="yes"
71
+ id="65"
72
+ elemType="dir"
73
+ Virtual="4/1"
74
+ namedVersion="orbitz-host-gt3-0-rc/1"
75
+ Real="6/1"
76
+ status="(backed)"/>
77
+ <element
78
+ location="./doc"
79
+ dir="yes"
80
+ id="117"
81
+ elemType="dir"
82
+ Virtual="4/1"
83
+ namedVersion="orbitz-host-gt3-0-rc/1"
84
+ Real="6/1"
85
+ status="(backed)"/>
86
+ <element
87
+ location="./hosts.properties"
88
+ dir="no"
89
+ id="198"
90
+ elemType="text"
91
+ Virtual="7/2"
92
+ namedVersion="orbitz-host-gt3-0-impl/2"
93
+ Real="8/2"
94
+ status="(backed)"/>
95
+ <element
96
+ location="./logs"
97
+ dir="yes"
98
+ id="128"
99
+ elemType="dir"
100
+ Virtual="4/1"
101
+ namedVersion="orbitz-host-gt3-0-rc/1"
102
+ Real="6/1"
103
+ status="(backed)"/>
104
+ <element
105
+ location="./scripts"
106
+ dir="yes"
107
+ id="130"
108
+ elemType="dir"
109
+ Virtual="4/1"
110
+ namedVersion="orbitz-host-gt3-0-rc/1"
111
+ Real="6/1"
112
+ status="(backed)"/>
113
+ <element
114
+ location="./src"
115
+ dir="yes"
116
+ id="136"
117
+ elemType="dir"
118
+ Virtual="4/1"
119
+ namedVersion="orbitz-host-gt3-0-rc/1"
120
+ Real="6/1"
121
+ status="(backed)"/>
122
+ <element
123
+ location="./test"
124
+ dir="yes"
125
+ id="194"
126
+ elemType="dir"
127
+ Virtual="4/1"
128
+ namedVersion="orbitz-host-gt3-0-rc/1"
129
+ Real="6/1"
130
+ status="(backed)"/>
131
+ <element
132
+ location="./version.properties"
133
+ dir="no"
134
+ id="5"
135
+ elemType="text"
136
+ Virtual="7/1"
137
+ namedVersion="orbitz-host-gt3-0-impl/1"
138
+ Real="8/1"
139
+ status="(backed)"/>
140
+ <element
141
+ location="./install"
142
+ dir="yes"
143
+ status="(external)"/>
144
+ <element
145
+ location="./target"
146
+ dir="yes"
147
+ status="(external)"/>
148
+ <element
149
+ location="./ground.iml"
150
+ dir="no"
151
+ status="(external)"/>
152
+ <element
153
+ location="./.project"
154
+ dir="no"
155
+ status="(external)"/>
156
+ <element
157
+ location="./.eclipsebuild"
158
+ dir="yes"
159
+ status="(external)"/>
160
+ <element
161
+ location="./.classpath"
162
+ dir="no"
163
+ status="(external)"/>
164
+ <element
165
+ location="./ac-files.xml"
166
+ dir="no"
167
+ status="(external)"/>
168
+ <element
169
+ location="./TODO"
170
+ dir="no"
171
+ status="(external)"/>
172
+ </AcResponse>
@@ -1,5 +1,3 @@
1
- ac> ./test/acreplay.rb eg/update-newwksp.xml files -fx
2
- raw>
3
1
  <?xml version="1.0"?>
4
2
  <!-- ac update -fx on a newly created workspace (eg, no files yet) -->
5
3
  <acResponse
@@ -183,139 +181,3 @@ raw>
183
181
  </acResponse>
184
182
 
185
183
 
186
- <?xml version='1.0'?><!-- ac update -fx on a newly created workspace (eg, no files yet) --><AcResponse command='update'>
187
- <message>Updating element /./ChangeLog
188
- </message>
189
- <element location='/ChangeLog'/>
190
- <message>Updating (creating) dir /./build
191
- </message>
192
- <element location='/build'/>
193
- <message>Updating (creating) dir /./build/filesets
194
- </message>
195
- <element location='/build/filesets'/>
196
- <message>Updating element /./build/filesets/orbitz-api-robot.exclude
197
- </message>
198
- <element location='/build/filesets/orbitz-api-robot.exclude'/>
199
- <message>Updating element /./build/filesets/orbitz-api-robot.include
200
- </message>
201
- <element location='/build/filesets/orbitz-api-robot.include'/>
202
- <message>Updating element /./build/filesets/orbitz-api-robot.metainf
203
- </message>
204
- <element location='/build/filesets/orbitz-api-robot.metainf'/>
205
- <message>Updating element /./build/filesets/orbitz-api-robot.src
206
- </message>
207
- <element location='/build/filesets/orbitz-api-robot.src'/>
208
- <message>Updating element /./build.properties
209
- </message>
210
- <element location='/build.properties'/>
211
- <message>Updating element /./build.sh
212
- </message>
213
- <element location='/build.sh'/>
214
- <message>Updating element /./build.xml
215
- </message>
216
- <element location='/build.xml'/>
217
- <message>Updating (creating) dir /./src
218
- </message>
219
- <element location='/src'/>
220
- <message>Updating (creating) dir /./src/java
221
- </message>
222
- <element location='/src/java'/>
223
- <message>Updating (creating) dir /./src/java/com
224
- </message>
225
- <element location='/src/java/com'/>
226
- <message>Updating (creating) dir /./src/java/com/orbitz
227
- </message>
228
- <element location='/src/java/com/orbitz'/>
229
- <message>Updating (creating) dir /./src/java/com/orbitz/dc
230
- </message>
231
- <element location='/src/java/com/orbitz/dc'/>
232
- <message>Updating (creating) dir /./src/java/com/orbitz/dc/client
233
- </message>
234
- <element location='/src/java/com/orbitz/dc/client'/>
235
- <message>Updating (creating) dir /./src/java/com/orbitz/dc/client/robot
236
- </message>
237
- <element location='/src/java/com/orbitz/dc/client/robot'/>
238
- <message>Updating element /./src/java/com/orbitz/dc/client/robot/RobotFactory.java
239
- </message>
240
- <element location='/src/java/com/orbitz/dc/client/robot/RobotFactory.java'/>
241
- <message>Updating element /./src/java/com/orbitz/dc/client/robot/RobotImpl.java
242
- </message>
243
- <element location='/src/java/com/orbitz/dc/client/robot/RobotImpl.java'/>
244
- <message>Updating (creating) dir /./src/java/com/orbitz/dc/core
245
- </message>
246
- <element location='/src/java/com/orbitz/dc/core'/>
247
- <message>Updating element /./src/java/com/orbitz/dc/core/ROBOT_STATE.java
248
- </message>
249
- <element location='/src/java/com/orbitz/dc/core/ROBOT_STATE.java'/>
250
- <message>Updating element /./src/java/com/orbitz/dc/core/THROTTLE_TYPE.java
251
- </message>
252
- <element location='/src/java/com/orbitz/dc/core/THROTTLE_TYPE.java'/>
253
- <message>Updating (creating) dir /./src/java/com/orbitz/dc/service
254
- </message>
255
- <element location='/src/java/com/orbitz/dc/service'/>
256
- <message>Updating (creating) dir /./src/java/com/orbitz/dc/service/robot
257
- </message>
258
- <element location='/src/java/com/orbitz/dc/service/robot'/>
259
- <message>Updating element /./src/java/com/orbitz/dc/service/robot/Robot.java
260
- </message>
261
- <element location='/src/java/com/orbitz/dc/service/robot/Robot.java'/>
262
- <message>Updating element /./src/java/com/orbitz/dc/service/robot/RobotAdminProperties.java
263
- </message>
264
- <element location='/src/java/com/orbitz/dc/service/robot/RobotAdminProperties.java'/>
265
- <message>Updating element /./src/java/com/orbitz/dc/service/robot/RobotInfo.java
266
- </message>
267
- <element location='/src/java/com/orbitz/dc/service/robot/RobotInfo.java'/>
268
- <message>Updating element /./src/java/com/orbitz/dc/service/robot/RobotProperties.java
269
- </message>
270
- <element location='/src/java/com/orbitz/dc/service/robot/RobotProperties.java'/>
271
- <message>Updating element /./src/java/com/orbitz/dc/service/robot/RobotStatus.java
272
- </message>
273
- <element location='/src/java/com/orbitz/dc/service/robot/RobotStatus.java'/>
274
- <message>Updating element /./src/java/com/orbitz/dc/service/robot/RobotUsageHistoryEntry.java
275
- </message>
276
- <element location='/src/java/com/orbitz/dc/service/robot/RobotUsageHistoryEntry.java'/>
277
- <message>Updating (creating) dir /./src/java/com/orbitz/dc/service/robot/remote
278
- </message>
279
- <element location='/src/java/com/orbitz/dc/service/robot/remote'/>
280
- <message>Updating element /./src/java/com/orbitz/dc/service/robot/remote/RobotServiceRemote.java
281
- </message>
282
- <element location='/src/java/com/orbitz/dc/service/robot/remote/RobotServiceRemote.java'/>
283
- <message>Updating (creating) dir /./src/java/com/orbitz/dc/service/util
284
- </message>
285
- <element location='/src/java/com/orbitz/dc/service/util'/>
286
- <message>Updating element /./src/java/com/orbitz/dc/service/util/ThrottleProperties.java
287
- </message>
288
- <element location='/src/java/com/orbitz/dc/service/util/ThrottleProperties.java'/>
289
- <message>Updating (creating) dir /./src/java/com/orbitz/dc/system
290
- </message>
291
- <element location='/src/java/com/orbitz/dc/system'/>
292
- <message>Updating (creating) dir /./src/java/com/orbitz/dc/system/core
293
- </message>
294
- <element location='/src/java/com/orbitz/dc/system/core'/>
295
- <message>Updating element /./src/java/com/orbitz/dc/system/core/ROBOT_TYPE.java
296
- </message>
297
- <element location='/src/java/com/orbitz/dc/system/core/ROBOT_TYPE.java'/>
298
- <message>Updating (creating) dir /./test
299
- </message>
300
- <element location='/test'/>
301
- <message>Updating (creating) dir /./test/src
302
- </message>
303
- <element location='/test/src'/>
304
- <message>Updating (creating) dir /./test/src/java
305
- </message>
306
- <element location='/test/src/java'/>
307
- <message>Updating (creating) dir /./test/src/java/com
308
- </message>
309
- <element location='/test/src/java/com'/>
310
- <message>Updating (creating) dir /./test/src/java/com/orbitz
311
- </message>
312
- <element location='/test/src/java/com/orbitz'/>
313
- <message>Updating element /./test/src/java/com/orbitz/package.html
314
- </message>
315
- <element location='/test/src/java/com/orbitz/package.html'/>
316
- <message>Updating element /./version.properties
317
- </message>
318
- <element location='/version.properties'/>
319
- </AcResponse>
320
-
321
-
@@ -0,0 +1,12 @@
1
+ <acResponse
2
+ command="update"Scanning entire workspace for files touched since last scan - ok
3
+ ok
4
+ >
5
+ <message
6
+ error="true">
7
+ Some of the elements in your workspace have been modified
8
+ and are not in your default group. Use &apos;accurev stat -n&apos; to
9
+ get a list of these files. Then resolve all modifications
10
+ with anchor, keep, or purge before trying update again.
11
+ </message>
12
+ </acResponse>
data/test/t_api.rb ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rscm/accurev'
5
+ include RSCM::Accurev
6
+
7
+ class AccurevAPITest < Test::Unit::TestCase
8
+
9
+ def test_ac_files()
10
+ Command.instance do |cmd|
11
+ cmd.working_dir = "test"
12
+ cmd.accurev = "./acreplay.rb eg/ac-files.xml"
13
+ end
14
+ api = API.new( ".", "test-bogus-depot", "test-bogus-depot-0-impl" )
15
+ # test array returns
16
+ files = api.ac_files( "." )
17
+ assert( files.length > 0, "Should get some stat-ed files" )
18
+ assert_equal( files.length, 23 )
19
+ files.each do |fd|
20
+ assert( fd.respond_to?( :location ) )
21
+ end
22
+ # test block yield
23
+ count = 0
24
+ api.ac_files( "." ) do |fd|
25
+ assert( fd.respond_to?( :location ) )
26
+ count += 1
27
+ end
28
+ assert_equal( count, 23 )
29
+ end
30
+
31
+ def test_update()
32
+ Command.instance do |cmd|
33
+ cmd.working_dir = "test"
34
+ cmd.accurev = "./acreplay.rb eg/update-stale.xml"
35
+ end
36
+ end
37
+
38
+ end
data/test/t_command.rb CHANGED
@@ -7,6 +7,7 @@ include RSCM::Accurev
7
7
  class CommandTest < Test::Unit::TestCase
8
8
 
9
9
  def test_command_line_subs
10
+ Command.discard
10
11
  cmd = Command.instance
11
12
 
12
13
  s = cmd.accurev_cmdline( "foo", "bar" )
@@ -16,22 +17,70 @@ class CommandTest < Test::Unit::TestCase
16
17
 
17
18
  s = cmd.accurev_cmdline( "foo", "bar" )
18
19
  assert_equal( "xyzzy foo bar", s )
19
-
20
+
21
+ Command.discard
20
22
  end
21
23
 
22
24
  def test_a_e
23
- puts "XXX test skipped XXX"
24
- return ## XXX
25
25
  cmd = Command.instance
26
- cmd.working_dir = "." # xxx
27
- cmd.debug = true
28
- cmd.debug_to = File.open( "testing.log", "w" )
29
- cmd.accurev = "./test/acreplay.rb eg/update-newwksp.xml"
30
- list = cmd.accurev_elements( RSCM::Accurev::FileStatus, "files" )
26
+ cmd.working_dir = "test"
27
+ #cmd.debug = true
28
+ #cmd.debug_to = File.open( "testing.log", "w" )
29
+ cmd.accurev = "./acreplay.rb eg/update-newwksp.xml"
30
+ # test listy output
31
+ list = cmd.accurev_elements( RSCM::Accurev::StatData, "files" )
31
32
  assert( list.size > 0 )
32
33
  list.each do |fd|
33
- assert( fd.respond_to?( location ) )
34
+ assert( fd.respond_to?( :location ) )
35
+ end
36
+ # test yieldy output
37
+ got_any = false
38
+ cmd.accurev_elements( RSCM::Accurev::StatData, "files" ) do |fd|
39
+ got_any = true
40
+ assert( fd.respond_to?( :location ) )
41
+ end
42
+ assert( got_any )
43
+ Command.discard
44
+ end
45
+
46
+ def test_threadlocal_private_new
47
+ begin
48
+ cmd = Command.new
49
+ flunk( "Command.new() should be private" )
50
+ rescue
51
+ assert( true )
52
+ end
53
+ end
54
+
55
+ def test_threadlocal
56
+ # instance returns this thread's Command object
57
+ begin
58
+ cmd = Command.instance
59
+ cmd.working_dir = "/one/two/three"
60
+ assert_equal( cmd.working_dir, "/one/two/three" )
61
+ end
62
+ # and calling it again returns the same object
63
+ begin
64
+ cmd = Command.instance
65
+ assert_equal( cmd.working_dir, "/one/two/three" )
34
66
  end
67
+ # but instance in another thread should be different
68
+ Thread.new do
69
+ cmd = Command.instance
70
+ assert_not_equal( cmd.working_dir, "/one/two/three" )
71
+ end.join()
72
+ # ...and calling it *again* returns the same object
73
+ begin
74
+ cmd = Command.instance
75
+ assert_equal( cmd.working_dir, "/one/two/three" )
76
+ end
77
+ # but discard tosses this thread's object:
78
+ Command.discard
79
+ begin
80
+ cmd = Command.instance
81
+ assert_not_equal( cmd.working_dir, "/one/two/three" )
82
+ end
83
+
35
84
  end
36
85
 
37
86
  end
data/test/t_scrubio.rb CHANGED
@@ -99,12 +99,6 @@ end
99
99
 
100
100
  class BrokenGarbleTest3 < Test::Unit::TestCase
101
101
  include TestBase
102
-
103
- def test_parse
104
- # commented out for build only
105
- puts "XXX test skipped XXX"
106
- end
107
-
108
102
  def broken; true; end
109
103
  def fixable; true; end
110
104
  def input
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rscm-accurev
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
6
+ version: 0.0.2
7
7
  date: 2005-08-10 00:00:00 -05:00
8
8
  summary: "RSCM::Accurev - RSCM API for Accurev"
9
9
  require_paths:
@@ -29,30 +29,34 @@ cert_chain:
29
29
  authors:
30
30
  - Greg Fast
31
31
  files:
32
- - eg
32
+ - apitest.rb
33
+ - bumprelease.sh
33
34
  - lib
34
35
  - LICENSE
35
36
  - Rakefile
36
37
  - README
37
38
  - test
38
- - test.rb
39
- - testing.log
40
39
  - tmp
41
40
  - TODO
42
41
  - lib/rscm
43
42
  - lib/rscm/accurev.rb
44
43
  - lib/rscm/scm
45
44
  - lib/rscm/scm/accurev
46
- - "lib/rscm/scm/accurev/#command.rb#"
45
+ - "lib/rscm/scm/accurev/#api.rb#"
47
46
  - lib/rscm/scm/accurev/api.rb
48
47
  - lib/rscm/scm/accurev/command.rb
49
48
  - lib/rscm/scm/accurev/filterio.rb
50
49
  - lib/rscm/scm/accurev/xml.rb
51
50
  - test/acreplay.rb
51
+ - test/eg
52
+ - test/t_api.rb
52
53
  - test/t_command.rb
53
54
  - test/t_filterio.rb
54
55
  - test/t_load.rb
55
56
  - test/t_scrubio.rb
57
+ - test/eg/ac-files.xml
58
+ - test/eg/update-newwksp.xml
59
+ - test/eg/update-stale.xml
56
60
  test_files: []
57
61
  rdoc_options:
58
62
  - "--line-numbers"
@@ -1,95 +0,0 @@
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
-