Class: Perforce::Changelist

Inherits:
Object
  • Object
show all
Defined in:
lib/perforce.rb

Overview

A Perforce changelist.

Use Perforce#new_changelist to create a new changelist.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(perforce, number) ⇒ Changelist

:nodoc:



274
275
276
277
# File 'lib/perforce.rb', line 274

def initialize(perforce, number) #:nodoc:
  @perforce = perforce
  @number = number
end

Instance Attribute Details

#numberObject (readonly)

Changelist number.



282
283
284
# File 'lib/perforce.rb', line 282

def number
  @number
end

Instance Method Details

#add_files(files) ⇒ Object

Add files to this Changelist.

This is used for both editing files and adding new files.



289
290
291
292
293
294
# File 'lib/perforce.rb', line 289

def add_files(files)
  unless files.empty?
    @perforce.run("edit", "-c", @number, *files)
    @perforce.run("add", "-c", @number, *files)
  end
end

#deleteObject

If empty, delete this Changelist.



336
337
338
339
340
# File 'lib/perforce.rb', line 336

def delete
  if empty?
    @perforce.run("change", "-d", @number)
  end
end

#delete_files(files) ⇒ Object

Open files for deletion. This action is added to the changelist.



308
309
310
311
312
# File 'lib/perforce.rb', line 308

def delete_files(files)
  unless files.empty?
    @perforce.run("delete", "-c", @number, *files)
  end
end

#descriptionObject

Description of this changelist



359
360
361
# File 'lib/perforce.rb', line 359

def description
  info["Description"]
end

#empty?Boolean

True if there are no files in this Changelist.

Returns:

  • (Boolean)


329
330
331
# File 'lib/perforce.rb', line 329

def empty?
  not @perforce.run("describe", @number).first.has_key?("depotFile")
end

#filesObject

Files in this Changelist.



352
353
354
# File 'lib/perforce.rb', line 352

def files
  info["Files"].to_a
end

#infoObject

Info hash for this Changelist.



345
346
347
# File 'lib/perforce.rb', line 345

def info
  @perforce.run("change", "-o", @number).first
end

#revert_files(files) ⇒ Object

Revert these files in this changelist.



299
300
301
302
303
# File 'lib/perforce.rb', line 299

def revert_files(files)
  unless files.empty?
    @perforce.run("revert", "-c", @number, *files)
  end
end

#revert_unchanged_files(in_files = nil) ⇒ Object

Revert unchanged files in this Changelist.



373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/perforce.rb', line 373

def revert_unchanged_files(in_files = nil)
  files =
    if in_files.nil?
      self.files
    else
      in_files
    end

  unless files.empty?
    @perforce.run("revert", "-a", "-c", @number, *files)
  end
end

#statusObject

Status of this changelist



366
367
368
# File 'lib/perforce.rb', line 366

def status
  info["Status"]
end

#submitObject

Submit this Changelist.



317
318
319
320
321
322
323
324
# File 'lib/perforce.rb', line 317

def submit
  revert_unchanged_files
  if empty?
    delete
  else
    @perforce.run("submit", "-c", @number)
  end
end