<html> <head> <title>C:\p4\shawnhladky_public\guest\shawn_hladky\P4.Net\doc\pythonsample\cpython.py.html</title> <meta name="Generator" content="Vim/6.4"> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000"> <pre> """ <font color="blue">This sample demonstrates the following:</font> <font color="blue"> Given a list of changelists:</font> <font color="blue"> </font> <font color="blue"> Create a new label</font> <font color="blue"> Change the view</font> <font color="blue"> Change the description</font> <font color="blue"> </font> <font color="blue"> Identify all the files in each Changelist</font> <font color="blue"> Add the most recent version of each file in all changelists to the label</font> """ <font color="#a020f0">import</font> p4 as P4API p4 = P4API.P4() p4.parse_forms() p4.connect() labelName = '<font color="blue">P4NetTestingSample</font>' <font color="green"># build my label</font> labelForm = p4.fetch_label(labelName) labelForm['<font color="blue">Description</font>'] = '<font color="blue">Created for P4.Net sample</font>' view = ['<font color="blue">//guest/shawn_hladky/...</font>'] labelForm['<font color="blue">View</font>'] = view p4.save_label(labelForm) <font color="green"># My list of changes. This is totally arbitrary</font> changes=['<font color="blue">5774</font>', '<font color="blue">5680</font>', '<font color="blue">5636</font>', '<font color="blue">5444</font>'] <font color="green"># sort ascending, so the highest revisions will be last when looping</font> sorted_changes = changes.sort() <font color="green"># dictionary: keyed by file, value = revision</font> filerevs = {} <font color="green"># spin the description on each file</font> <font color="#804040"><b>for</b></font> chg <font color="#804040"><b>in</b></font> p4.run_describe('<font color="blue">-s</font>', *changes): depotFiles = chg['<font color="blue">depotFile</font>'] revisions = chg['<font color="blue">rev</font>'] <font color="#804040"><b>for</b></font> i <font color="#804040"><b>in</b></font> range(0, len(depotFiles)): key,value = depotFiles[i], revisions[i] filerevs[key]=value <font color="green"># convert the dictionary to a list like ['//depot/file#5']</font> fileRevList = ["<font color="blue">%s#%s</font>" % (k,v) <font color="#804040"><b>for</b></font> k,v <font color="#804040"><b>in</b></font> filerevs.items()] <font color="green"># print fileRevList</font> <font color="green"># now I want to run in non-parsed mode</font> p4.disconnect() p4 = P4API.P4() p4.connect() labelsync_output = p4.run('<font color="blue">labelsync</font>', '<font color="blue">-l</font>', labelName, *fileRevList) <font color="#804040"><b>for</b></font> s <font color="#804040"><b>in</b></font> labelsync_output: <font color="#804040"><b>print</b></font> s <font color="green"># delete the label to keep the public depot clean :-)</font> p4.run('<font color="blue">label</font>', '<font color="blue">-d</font>', labelName) p4.disconnect() </pre> </body> </html>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19706 | MikeEheler |
Populate //guest/shawn_hladky/P4.Net/... //guest/MikeEheler/P4.Net/.... |
||
//guest/shawn_hladky/P4.Net/main/doc/pythonsample/cpython.py.html | |||||
#1 | 5830 | Shawn Hladky | P4.Net: reorg to support release branches | ||
//guest/shawn_hladky/P4.Net/doc/pythonsample/cpython.py.html | |||||
#1 | 5799 | Shawn Hladky | p4.net missing doc files |