publish.rb #1

  • //
  • guest/
  • robert_cowham/
  • perforce/
  • utils/
  • p4gui/
  • publish.rb
  • View
  • Commits
  • Open Download .zip Download (1 KB)
# publish.rb
# Do a safe "publish" - means an integration back to the main line from a development line.
# Integrate from development to main is called a "catchup".
#
# Assumes branch spec parameter is always main->dev branch direction (should of course validate this)
#
# Note lack of error checking etc!
# Author: Robert Cowham
# Usual disclaimers apply

require "P4"

p4 = P4.new

# TODO - pass as parameters and validate.
p4.port = "1666"
p4.client = "bruno_ws"
p4.user = "robert"

p4.exception_level = 1
branch = ARGV[0]

def die(msg, files)
    print "You haven't caught up - " + msg + files.join("\n")
    exit(1)
end

begin
    p4.connect
    # Check if anything needs to be "caught up"
    catchup_list = p4.run_integ("-b", branch, "-n")
    if catchup_list.size > 0
        die("files to catchup:", catchup_list)
    end
    # Now do the integrate into main
    p4.run_integ("-b", branch, "-r")
    # and resolve safely - should resolve everything!
    p4.run_resolve("-as")
    resolve_list = p4.run_resolve("-n")
    if resolve_list.size > 0
        die("some files couldn't be safely resolved:", resolve_list)
    end
    # At this point I would build and test and check for errors before submitting...
    print "All files ready to submit!"
rescue
    print "Warnings: ", p4.warnings
    print "Errors: ", p4.errors
end

# Change User Description Committed
#1 5217 Robert Cowham Simple version of publish scripts