#---------------------------------------------------------------------------- # 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.1 modified by Andrew Chan based on //guest/chris_stoy/p4_shelve/... 09/22/2009 \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 | |
---|---|---|---|---|---|
#2 | 7396 | Andrew Chan |
bug fix: 1. fixed: p4shelve fail if there is space within the file path 2. fixed: user will get "can't clobber openned file" if the user shelved newly added file and unshelve the change. 3. fixed: when shelving a numbered changelist, if there is an openned file in default changelist, the file in default changelist will be submitted. enhancement: 1. commented out p4c.parse_forms() for the new P4Python API 2. replace "p4" with "P4" for the new P4Python API |
||
#1 | 7395 | Andrew Chan | Branching P4_Shelve from //guest/shawn_hladky/p4_shelve/ | ||
//guest/shawn_hladky/p4_shelve/p4_unshelve.py | |||||
#1 | 5285 | Shawn Hladky |
Integrating p4_shelve from Chris Stoy. I intend to make the following fixes/enhancements: If you shelve a named changelist, and also have opend files in your defualt changelist, then the files in the default changelist will be submitted along with the shelve. Opend files with the same filename, but different directories can not be shelved together Filepaths with a space in the filename will not be shelved correctly. A file opened for Add will left writable in the local workspace. When you un-shelve, and you have noclobber set on your client spec, you will get a "Can't clobber writable file" error. |
||
//guest/chris_stoy/p4_shelve/p4_unshelve.py | |||||
#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. |