Class: Perforce2Svn::Perforce::P4Depot
- Inherits:
-
Object
- Object
- Perforce2Svn::Perforce::P4Depot
- Includes:
- Logging, Singleton
- Defined in:
- lib/perforce2svn/perforce/p4_depot.rb
Instance Method Summary collapse
- #connect! ⇒ Object
- #disconnect! ⇒ Object
-
#initialize ⇒ P4Depot
constructor
A new instance of P4Depot.
-
#latest_revision ⇒ Object
Retrieves the latest revision on the Perforce server.
- #query(&block) ⇒ Object
Methods included from Logging
Constructor Details
#initialize ⇒ P4Depot
Returns a new instance of P4Depot.
11 12 13 |
# File 'lib/perforce2svn/perforce/p4_depot.rb', line 11 def initialize @p4 = P4.new end |
Instance Method Details
#connect! ⇒ Object
15 16 17 18 19 |
# File 'lib/perforce2svn/perforce/p4_depot.rb', line 15 def connect! handle_errors do @p4.connect unless @p4.connected? end end |
#disconnect! ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/perforce2svn/perforce/p4_depot.rb', line 21 def disconnect! begin @p4.disconnect if @p4.connected? rescue Exception => e log.fatal(e) exit 1 end end |
#latest_revision ⇒ Object
Retrieves the latest revision on the Perforce server
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/perforce2svn/perforce/p4_depot.rb', line 39 def latest_revision if @latest_revision.nil? query do |p4| log.debug "Retrieving latest perforce revision" output = p4.run("changes", "-m1")[0] @latest_revision = output['change'].to_i end end @latest_revision end |
#query(&block) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/perforce2svn/perforce/p4_depot.rb', line 30 def query(&block) raise Perforce2Svn::P4Error, "Requires a block" unless block_given? connect! handle_errors do yield @p4 end end |