#----------------------------------------------------------------------------
# unshelve changelist in Perforce
#
# $Id: $
#
# Copyright 2005, Chris Stoy. All Rights Reserved.
#
# License:
# This file and any derivatives or translations of it may be freely
# copied and redistributed so long as:
# 1) This license and copyright notice are not changed.
# 2) Any fixes or enhancements are reported back to either the
# author (cstoy@nc.rr.com).
# and any of:
# a) The source is redistributed with it.
# b) The source is compiled unmodified, and instructions for finding
# the original source are included.
# c) The source is made available by some other means.
#
#----------------------------------------------------------------------------
import sys
import os
import time
import shutil
import p4
import getopt
VERSION = "\np4_unshelve Version 1.0 11/11/2005\n"
#----------------------------------------------------------------------------
def p4_unshelve(p4c, shelfBranch ):
print "Restoring shelf %s" % shelfBranch
p4c.run_integrate( "-d", "-b", shelfBranch, "-r" )
#----------------------------------------------------------------------------
# prints the usage message. If short is true, prints abreviated
# help message.
#----------------------------------------------------------------------------
def usage(short=True):
print "\nUsage: p4_unshelve [options] <shelve branchspec>\n"
if short :
print "Try 'p4_unshelve --help' for more information."
else:
print "Restores a shelved changelist into the default changelist for editing."
print ""
print " <shelve branchspec> Perforce branchspec created by p4_shelve."
print ""
print "Options:"
print " -h, --help Prints this help message"
print " -p, --port Perforce Port depot is on"
print " -c, --client Perforce Client that maps the depot files"
print " -u, --user Perforce User that owns the client"
print " -P, --password Perforce Password for the user"
print ""
print "Note: Uses the default P4 settings for Perforce options not supplied."
print "\nReport bugs to Chris Stoy (cstoy@nc.rr.com)"
print VERSION
#-----------------------------------------------------------
# Main entry point
#-----------------------------------------------------------
if __name__ == "__main__":
options = []
input = []
for x in sys.argv[1:]:
if x.startswith("-"):
options.append(x)
else:
input.append(x)
try:
opts, args = getopt.getopt( options, "hp:c:u:P:v", ["help", "port=", "client=", "user=", "password=", "verbose"] )
except getopt.GetoptError, intr:
print "Argument error: ", intr
usage()
sys.exit(2)
# set P4 options
p4c = p4.P4()
p4c.parse_forms()
verbose = False
# we got our options.
for o, a in opts:
if o in ("-h", "--help"):
usage(False)
sys.exit(0)
if o in ("-p", "--port"):
p4c.port = a
if o in ("-c", "--client"):
p4c.client = a
if o in ("-u", "--user"):
p4c.user = a
if o in ("-P", "--password"):
p4c.password = a
if o in ("-v", "--verbose"):
verbose = True
if len(input) != 1:
print "Failed to specify branchspec for shelf."
usage()
sys.exit(2)
branchSpec = input[0]
# connect to P4
p4c.connect()
if verbose:
print "Settings:"
print "\tP4 Port = %s" % p4c.port
print "\tP4 Client = %s" % p4c.client
print "\tP4 User = %s" % p4c.user
print "\tShelve Branchspec = %s" % branchSpec
# do the unshelving
try:
p4_unshelve(p4c, branchSpec)
except p4.P4Error:
print "P4 Error:"
for e in p4c.errors:
print "\t%s" % e
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #1 | 5208 | Chris Stoy |
First version of these files. Provides the shelve, unshelve, and setup script for making stand-alone Exes. Requires P4Python to run. |