In: |
p4table.rb
|
Parent: | Object |
*******************************************************************************
Class for representing files that are versioned in the depot.
*******************************************************************************
name | [R] | |
p4 | [R] | |
rec | [R] |
# File p4table.rb, line 122 122: def initialize( p4, name, rec ) 123: @p4 = p4 124: @name = name 125: @rec = rec 126: @exists = false 127: @depot_path = nil 128: @ws_path = nil 129: end
# File p4table.rb, line 181 181: def add 182: if ( exists? ) 183: raise( RuntimeError, "Can't open existing file for add", caller ) 184: end 185: p4.run_add( ws_path() ) 186: end
# File p4table.rb, line 203 203: def delete 204: if ( ! exists? ) 205: raise( RuntimeError, "Can't delete non-existent file", caller ) 206: end 207: 208: p4.run_sync( depot_path() ) 209: p4.run_delete( depot_path() ) 210: end
# File p4table.rb, line 158 158: def depot_path 159: return @depot_path if @depot_path 160: table_path = @rec.table.storage_map( @rec ).join( "/" ) 161: @depot_path = [ DEPOT_ROOT_PATH, table_path, @rec.id.seq_str, @name ].join( "/" ) 162: end
# File p4table.rb, line 191 191: def edit 192: if ( ! exists? ) 193: raise( RuntimeError,"Can't open non-existent file for edit", caller) 194: end 195: 196: p4.run_sync( depot_path() ) 197: p4.run_edit( depot_path() ) 198: end
# File p4table.rb, line 235 235: def mkdir 236: dirs = ws_path.split( SEP ) 237: dirs.pop 238: dir = "" 239: dirs.each do 240: |d| 241: dir += d + SEP 242: Dir.mkdir( dir ) unless File.directory?( dir ) 243: end 244: end
# File p4table.rb, line 215 215: def read 216: p4.run_sync( depot_path() ) 217: f = File.open( ws_path, "r" ) 218: buf = f.read 219: f.close 220: return buf 221: end