Helix SwarmHelix Swarm
Loading...

ironpyton.py.html

  • //
  • guest/
  • erik_purins/
  • P4.Net/
  • main/
  • doc/
  • pythonsample/
  • ironpyton.py.html #1
  • View
  • Commits
  • Open Download .zip Download (3 KB)
  1. <html>
  2. <head>
  3. <title>C:\p4\shawnhladky_public\guest\shawn_hladky\P4.Net\doc\pythonsample\ironpyton.py.html</title>
  4. <meta name="Generator" content="Vim/6.4">
  5. <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
  6. </head>
  7. <body bgcolor="#ffffff" text="#000000">
  8. <pre>
  9. &quot;&quot;&quot;
  10. <font color="blue">This sample demonstrates the following:</font>
  11. <font color="blue"> Given a list of changelists:</font>
  12. <font color="blue"> </font>
  13. <font color="blue"> Create a new label</font>
  14. <font color="blue"> Change the view</font>
  15. <font color="blue"> Change the description</font>
  16. <font color="blue"> </font>
  17. <font color="blue"> Identify all the files in each Changelist</font>
  18. <font color="blue"> Add the most recent version of each file in all changelists to the label</font>
  19.  
  20. &quot;&quot;&quot;
  21. <font color="#a020f0">import</font> clr
  22. <font color="#a020f0">from</font> System <font color="#a020f0">import</font> Array, String
  23. clr.AddReferenceToFile('<font color="blue">P4API.dll</font>')
  24.  
  25. <font color="#a020f0">import</font> P4API
  26.  
  27. p4 = P4API.P4Connection()
  28. p4.Connect()
  29.  
  30. labelName = '<font color="blue">P4NetTestingSample</font>'
  31.  
  32. <font color="green"># build my label</font>
  33. labelForm = p4.Fetch_Form('<font color="blue">label</font>', labelName)
  34. labelForm['<font color="blue">Description</font>'] = '<font color="blue">Created for P4.Net sample</font>'
  35. view = Array[String](['<font color="blue">//guest/shawn_hladky/...</font>'])
  36. labelForm.ArrayFields['<font color="blue">View</font>'] = view
  37. p4.Save_Form(labelForm)
  38.  
  39. <font color="green"># My list of changes. This is totally arbitrary</font>
  40. changes=['<font color="blue">5774</font>', '<font color="blue">5680</font>', '<font color="blue">5636</font>', '<font color="blue">5444</font>']
  41.  
  42. <font color="green"># sort ascending, so the highest revisions will be last when looping</font>
  43. sorted_changes = changes.sort()
  44.  
  45. <font color="green"># dictionary: keyed by file, value = revision</font>
  46. filerevs = {}
  47.  
  48. <font color="green"># spin the description on each file</font>
  49. <font color="#804040"><b>for</b></font> chg <font color="#804040"><b>in</b></font> p4.Run('<font color="blue">describe</font>', '<font color="blue">-s</font>', *changes):
  50. depotFiles = chg.ArrayFields['<font color="blue">depotFile</font>']
  51. revisions = chg.ArrayFields['<font color="blue">rev</font>']
  52. <font color="#804040"><b>for</b></font> i <font color="#804040"><b>in</b></font> range(0, len(depotFiles)):
  53. key,value = depotFiles[i], revisions[i]
  54. filerevs[key]=value
  55.  
  56. <font color="green"># convert the dictionary to a list like ['//depot/file#5']</font>
  57. fileRevList = [&quot;<font color="blue">%s#%s</font>&quot; % (k,v) <font color="#804040"><b>for</b></font> k,v <font color="#804040"><b>in</b></font> filerevs.items()]
  58.  
  59. labelsync_output = p4.RunUnParsed('<font color="blue">labelsync</font>', '<font color="blue">-l</font>', labelName, *fileRevList)
  60.  
  61. <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
  62.  
  63. <font color="green"># delete the label to keep the public depot clean :-)</font>
  64. p4.RunUnParsed('<font color="blue">label</font>', '<font color="blue">-d</font>', labelName)
  65.  
  66. p4.Disconnect()
  67. </pre>
  68. </body>
  69. </html>
# Change User Description Committed
#1 7341 Erik Purins p4.net
---
pull p4.net#head
16 years ago
//guest/shawn_hladky/P4.Net/main/doc/pythonsample/ironpyton.py.html
#1 5830 Shawn Hladky P4.Net: reorg to support release branches 19 years ago
//guest/shawn_hladky/P4.Net/doc/pythonsample/ironpyton.py.html
#1 5799 Shawn Hladky p4.net missing doc files 19 years ago