# publish.py
# 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
import p4 as p4py
import string
import sys
p4 = p4py.P4()
# TODO - pass as parameters and validate.
p4.port = "1666"
p4.client = "bruno_ws"
p4.user = "robert"
p4.exception_level = 1
branch = sys.argv[1]
def die(msg, files):
print "You haven't caught up - " + msg + "\n" + string.join(files, "\n")
exit(1)
try:
p4.connect()
# Check if anything needs to be "caught up"
catchup_list = p4.run_integ("-b", branch, "-n")
if len(catchup_list) > 0:
die("files to catchup:", catchup_list)
# 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 len(resolve_list) > 0:
die("some files couldn't be safely resolved:", resolve_list)
# At this point I would build and test and check for errors before submitting...
print "All files ready to submit!"
except:
if len(p4.warnings) > 0:
print "Warnings: ", p4.warnings
if len(p4.errors) > 0:
print "Errors: ", p4.errors