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:



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

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

Instance Attribute Details

#numberObject (readonly)

Changelist number.



298
299
300
# File 'lib/perforce.rb', line 298

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.



305
306
307
308
309
310
# File 'lib/perforce.rb', line 305

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.



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

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.



324
325
326
327
328
# File 'lib/perforce.rb', line 324

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

#descriptionObject

Description of this changelist



375
376
377
# File 'lib/perforce.rb', line 375

def description
  info["Description"]
end

#empty?Boolean

True if there are no files in this Changelist.

Returns:

  • (Boolean)


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

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

#filesObject

Files in this Changelist.



368
369
370
# File 'lib/perforce.rb', line 368

def files
  info["Files"].to_a
end

#infoObject

Info hash for this Changelist.



361
362
363
# File 'lib/perforce.rb', line 361

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

#revert_files(files) ⇒ Object

Revert these files in this changelist.



315
316
317
318
319
# File 'lib/perforce.rb', line 315

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.



389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/perforce.rb', line 389

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



382
383
384
# File 'lib/perforce.rb', line 382

def status
  info["Status"]
end

#submitObject

Submit this Changelist.



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

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