Class: RSCM::Perforce

Inherits:
Base show all
Defined in:
lib/rscm/scm/perforce.rb

Overview

Perforce RSCM implementation.

Understands operations against multiple client-workspaces You need the p4/p4d executable on the PATH in order for it to work.

Constant Summary collapse

@@counter =
0

Constants inherited from Base

Base::DEFAULT_QUIET_PERIOD, Base::THIRTY_TWO_WEEKS_AGO, Base::TWO_WEEKS_AGO

Instance Attribute Summary collapse

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Base

#==, #checked_out?, #checkout_commandline, #checkout_dir, #checkout_dir=, classes, #destroy_working_copy, #file, #poll_new_revisions, register, #to_yaml_properties, #update_commandline

Constructor Details

#initialize(port = "1666", user = ENV["LOGNAME"], pwd = "", client_name = Perforce.next_client_name) ⇒ Perforce

Returns a new instance of Perforce.



36
37
38
# File 'lib/rscm/scm/perforce.rb', line 36

def initialize(port = "1666", user = ENV["LOGNAME"], pwd = "", client_name = Perforce.next_client_name)
  @port, @user, @pwd, @client_name = port, user, pwd, client_name
end

Instance Attribute Details

#client_nameObject

Returns the value of attribute client_name.



23
24
25
# File 'lib/rscm/scm/perforce.rb', line 23

def client_name
  @client_name
end

#portObject

Returns the value of attribute port.



26
27
28
# File 'lib/rscm/scm/perforce.rb', line 26

def port
  @port
end

#pwdObject

Returns the value of attribute pwd.



32
33
34
# File 'lib/rscm/scm/perforce.rb', line 32

def pwd
  @pwd
end

#repository_root_dirObject

Returns the value of attribute repository_root_dir.



34
35
36
# File 'lib/rscm/scm/perforce.rb', line 34

def repository_root_dir
  @repository_root_dir
end

#userObject

Returns the value of attribute user.



29
30
31
# File 'lib/rscm/scm/perforce.rb', line 29

def user
  @user
end

Instance Method Details

#add(relative_filename) ⇒ Object



89
90
91
# File 'lib/rscm/scm/perforce.rb', line 89

def add(relative_filename)
  p4client.add(relative_filename)
end

#can_create_central?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/rscm/scm/perforce.rb', line 48

def can_create_central?
  true
end

#central_exists?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/rscm/scm/perforce.rb', line 62

def central_exists?
  p4admin.central_exists?
end

#checkout(to_identifier = nil, &proc) ⇒ Object



85
86
87
# File 'lib/rscm/scm/perforce.rb', line 85

def checkout(to_identifier = nil, &proc)
  p4client.checkout(to_identifier, &proc)
end

#commit(message, &proc) ⇒ Object



97
98
99
# File 'lib/rscm/scm/perforce.rb', line 97

def commit(message, &proc)
  p4client.submit(message, &proc)
end

#create_centralObject



52
53
54
55
56
# File 'lib/rscm/scm/perforce.rb', line 52

def create_central
  raise "perforce depot can be created only from tests" unless @repository_root_dir
  @p4d = P4Daemon.new(@repository_root_dir)
  @p4d.start
end

#destroy_centralObject



58
59
60
# File 'lib/rscm/scm/perforce.rb', line 58

def destroy_central
  @p4d.shutdown
end

#diff(revfile, &proc) ⇒ Object



125
126
127
# File 'lib/rscm/scm/perforce.rb', line 125

def diff(revfile, &proc)
  p4client.diff(revfile, &proc)
end

#edit(file) ⇒ Object



109
110
111
# File 'lib/rscm/scm/perforce.rb', line 109

def edit(file)
  p4client.edit(file)
end

#import_central(dir, comment) ⇒ Object



78
79
80
81
82
83
# File 'lib/rscm/scm/perforce.rb', line 78

def import_central(dir, comment)
  with_create_client(dir) do |client|
    client.add_all(list_files)
    client.submit(comment)
  end
end

#install_trigger(trigger_command, damagecontrol_install_dir) ⇒ Object



117
118
119
# File 'lib/rscm/scm/perforce.rb', line 117

def install_trigger(trigger_command, damagecontrol_install_dir)
  p4admin.install_trigger(trigger_command)
end

#move(relative_src, relative_dest) ⇒ Object



93
94
95
# File 'lib/rscm/scm/perforce.rb', line 93

def move(relative_src, relative_dest)
  p4client.move(checkout_dir, relative_src, relative_dest)
end

#p4adminObject



40
41
42
# File 'lib/rscm/scm/perforce.rb', line 40

def p4admin
  @p4admin ||= P4Admin.new(@port, @user, @pwd)
end

#p4clientObject



44
45
46
# File 'lib/rscm/scm/perforce.rb', line 44

def p4client
  @p4client ||= p4admin.create_client(@checkout_dir, @client_name)
end

#revisions(from_identifier, to_identifier = Time.infinity) ⇒ Object



101
102
103
# File 'lib/rscm/scm/perforce.rb', line 101

def revisions(from_identifier, to_identifier=Time.infinity)
  p4client.revisions(from_identifier, to_identifier)
end

#supports_trigger?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/rscm/scm/perforce.rb', line 70

def supports_trigger?
  true
end

#transactional?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/rscm/scm/perforce.rb', line 74

def transactional?
  true
end

#trigger_installed?(trigger_command, trigger_files_checkout_dir) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/rscm/scm/perforce.rb', line 113

def trigger_installed?(trigger_command, trigger_files_checkout_dir)
  p4admin.trigger_installed?(trigger_command)
end

#uninstall_trigger(trigger_command, trigger_files_checkout_dir) ⇒ Object



121
122
123
# File 'lib/rscm/scm/perforce.rb', line 121

def uninstall_trigger(trigger_command, trigger_files_checkout_dir)
  p4admin.uninstall_trigger(trigger_command)
end

#uptodate?(from_identifier) ⇒ Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/rscm/scm/perforce.rb', line 105

def uptodate?(from_identifier)
  p4client.uptodate?
end