| In: |
autointeg.rb
|
| Parent: | Object |
This simple class encapsulates the functionality of this script. Essentially, we integrate using a branchspec and auto resolve with ‘Accept Theirs’. This means that there’s no support for maintaining variant branches here, only master/slave branches. Useful for so-called ‘shared files’ (VSS-style).
| branch | [R] | |
| p4 | [R] |
# File autointeg.rb, line 101
101: def initialize( p4, branchspec )
102: @p4 = p4
103: @branch = branchspec
104: end
Create a new empty changelist for this transaction
# File autointeg.rb, line 145
145: def create_change( changeno )
146: spec = p4.fetch_change
147: spec[ "Files" ] = Array.new
148: spec[ "Jobs" ] = Array.new
149: spec[ "Description" ] = "Automatically propagate change #{changeno} " +
150: "to slave branch."
151: change = p4.save_change( spec ).shift
152: if( change =~ /^Change (\d+)/ )
153: return $1
154: end
155: raise( P4Exception, "Unable to create an empty pending changelist" )
156: end
Integrate the specified change through the branch view and resolve them.
# File autointeg.rb, line 112
112: def integrate( change )
113: p4.run_sync
114: c = create_change( change )
115: p4.run_integrate( "-c", c, "-b", branch, "-s",
116: "//...@#{change},@#{change}" )
117: p4.run_resolve( "-at" )
118:
119: # Build a list of the files to be submitted.
120: filelist = p4.run_opened( "-c", c ).collect do
121: |h|
122: sprintf( "%s#%s (%s)", h[ "depotFile" ], h[ "rev" ], h[ "action" ] )
123: end
124:
125: # If no files were opened for integrate, there's nothing to do, so
126: # we just delete our pending changelist and get out of here
127: if filelist.length == 0
128: p4.delete_change( c )
129: return
130: end
131:
132: # Now submit it.
133: p4.run_submit( "-c", c )
134:
135: admin_report do
136: "Change #{change} automatically integrated using branchspec " +
137: @branch + "\n\n" +
138: "Affected Files:\n\n\t" +
139: filelist.join( "\n\t" ) +
140: "\n"
141: end
142: end