You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

perforce.html 17 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <html>
  2. <head>
  3. <title>Perforce Tasks</title>
  4. </head>
  5. <body>
  6. <h1>Perforce Tasks User Manual</h1>
  7. <p>by</p>
  8. <ul>
  9. <li>Les Hughes (<a href="mailto:leslie.hughes@rubus.com">leslie.hughes@rubus.com</a>)</li>
  10. <li>Kirk Wylie (<a href="mailto:kirk@radik.com">kirk@radik.com</a>)</li>
  11. </ul>
  12. <p>Version 1.1 - 2001/01/09</p>
  13. <hr>
  14. <h2>Contents</h2>
  15. <ul>
  16. <li><a href="#intro">Introduction</a></li>
  17. <li><a href="#tasks">The Tasks</a></li>
  18. <li><a href="#changes">Change History</a></li>
  19. </ul>
  20. <br>
  21. <h2><a name="intro">Introduction</a></h2>
  22. <p>These tasks provide an interface to the <a href="http://www.perforce.com" target="_top">Perforce</a> SCM.
  23. The <code>org.apache.tools.ant.taskdefs.optional.perforce</code> package consists of a simple framework to support
  24. p4 functionality as well as some Ant tasks encapsulating frequently used (by me :-) p4 commands.
  25. However, the addition of new p4 commands is a pretty simple task (see the source).
  26. Although it is possible to use these commands on the desktop,
  27. they were primarily intended to be used by automated build systems.</p>
  28. <p><b>Note:</b> These tasks require the <a href="http://jakarta.apache.org/oro" target="_top">oro 2.0.XXX</a> regular
  29. expression package. Simply download this package and copy the jakarta-oro-2.0.XXX.jar file into Ant's lib directory.
  30. You will also need the Perforce client executable (p4 or p4.exe but not p4win.exe) in your path.
  31. </p>
  32. <h2><a name="tasks">The Tasks</a></h2>
  33. <table border="0" cellspacing="0" cellpadding="3">
  34. <tr>
  35. <td><a href="#p4sync">P4Sync</a></td>
  36. <td>Synchronise a workspace to a depot</td>
  37. </tr>
  38. <tr>
  39. <td><a href="#p4change">P4Change</a></td>
  40. <td>Request a new changelist from the Perforce server</td>
  41. </tr>
  42. <tr>
  43. <td><a href="#p4edit">P4Edit</a></td>
  44. <td>Open files for edit (checkout)</td>
  45. </tr>
  46. <tr>
  47. <td><a href="#p4submit">P4Submit</a></td>
  48. <td>Submit a changelist to the Perforce server (checkin)</td>
  49. </tr>
  50. <tr>
  51. <td><a href="#p4have">P4Have</a></td>
  52. <td>List current files in client view, useful for reporting</td>
  53. </tr>
  54. <tr>
  55. <td><a href="#p4label">P4Label</a></td>
  56. <td>Create a label reflecting files in the current workspace</td>
  57. </tr>
  58. <tr>
  59. <td><a href="#p4counter">P4Counter</a></td>
  60. <td>Obtain or set the value of a counter</td>
  61. </tr>
  62. <tr>
  63. <td><a href="#p4reopen">P4Reopen</a></td>
  64. <td>Move files between changelists</td>
  65. </tr>
  66. <tr>
  67. <td><a href="#p4revert">P4Revert</a></td>
  68. <td>Revert files</td>
  69. </tr>
  70. <tr>
  71. <td><a href="#p4add">P4Add</a></td>
  72. <td>Add files</td>
  73. </tr>
  74. </table>
  75. <h3>General P4 Properties</h3>
  76. <p>Each p4 task requires a number of settings, either through build-wide properties, individual attributes
  77. or environment variables. These are
  78. </p>
  79. <table border="1" cellpadding="2" cellspacing="0">
  80. <tr>
  81. <td valign="top"><b>Property</b></td>
  82. <td valign="top"><b>Attribute</b></td>
  83. <td valign="top"><b>Env Var</b></td>
  84. <td valign="top"><b>Description</b></td>
  85. <td align="center" valign="top"><b>Default</b></td>
  86. </tr>
  87. <tr>
  88. <td valign="top">p4.port</td>
  89. <td valign="top">port</td>
  90. <td valign="top">P4PORT</td>
  91. <td valign="top">The p4d server and port to connect to</td>
  92. <td valign="top">perforce:1666</td>
  93. </tr>
  94. <tr>
  95. <td valign="top">p4.client</td>
  96. <td valign="top">client</td>
  97. <td valign="top">P4CLIENT</td>
  98. <td valign="top">The p4 client spec to use</td>
  99. <td valign="top">The logged in username</td>
  100. </tr>
  101. <tr>
  102. <td valign="top">p4.user</td>
  103. <td valign="top">user</td>
  104. <td valign="top">P4USER</td>
  105. <td valign="top">The p4 username</td>
  106. <td valign="top">The logged in username</td>
  107. </tr>
  108. <tr>
  109. <td valign="top" align="center">--</td>
  110. <td valign="top">view</td>
  111. <td valign="top" align="center">--</td>
  112. <td valign="top">The client, branch or label view to operate upon. See the p4 user guide for more info.</td>
  113. <td valign="top">//...</td>
  114. </tr>
  115. </table>
  116. <p>
  117. Your local installation of Perforce may require other settings (e.g. P4PASSWD, P4CONFIG). At the moment, these can only be set outside of Ant, as environment variables.
  118. </p>
  119. <h3>Examples</h3>
  120. <p>Setting in the environment:-</p>
  121. <p>
  122. (Unix csh)</p>
  123. <pre>setenv P4PORT myperforcebox:1666</pre>
  124. <p>(Unix sh et al)</p>
  125. <pre>P4USER=myp4userid; export P4USER</pre>
  126. <p>Using build properties:-</p>
  127. <pre>&lt;property name=&quot;p4.client&quot; value=&quot;nightlybuild&quot;/&gt;</pre>
  128. <p>Using task attributes:-</p>
  129. <pre>
  130. &lt;p4Whatever
  131. port=&quot;myserver:1666&quot;
  132. client=&quot;smoketest&quot;
  133. user=&quot;smoketestdude&quot;
  134. .
  135. .
  136. .
  137. /&gt;
  138. </pre>
  139. <p>
  140. For more information regarding the underlying 'p4' commands you are referred to the Perforce Command Reference
  141. available from the <a href="http://www.perforce.com/" target="_top">Perforce website</a>.
  142. </p>
  143. <h3>Taskdefs</h3>
  144. <p>Standard taskdefs (for you to copy'n'paste) -- normally this is done automatically if you install this optional task.</p>
  145. <pre>
  146. &lt;taskdef name=&quot;p4sync&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Sync&quot; /&gt;
  147. &lt;taskdef name=&quot;p4change&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Change&quot; /&gt;
  148. &lt;taskdef name=&quot;p4edit&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Edit&quot; /&gt;
  149. &lt;taskdef name=&quot;p4submit&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Submit&quot; /&gt;
  150. &lt;taskdef name=&quot;p4have&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Have&quot; /&gt;
  151. &lt;taskdef name=&quot;p4label&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Label&quot; /&gt;
  152. &lt;taskdef name=&quot;p4counter&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Counter&quot; /&gt;
  153. &lt;taskdef name=&quot;p4reopen&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Reopen&quot; /&gt;
  154. &lt;taskdef name=&quot;p4revert&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Revert&quot; /&gt;
  155. &lt;taskdef name=&quot;p4add&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Add&quot; /&gt;
  156. </pre>
  157. <hr>
  158. <h2>Task Descriptions</h2>
  159. <h2><a name="p4sync">P4Sync</a></h2>
  160. <h3>Description:</h3>
  161. <p>Synchronize the current workspace with the depot.</p>
  162. <h3>Parameters</h3>
  163. <table border="1" cellpadding="2" cellspacing="0">
  164. <tr>
  165. <td valign="top"><b>Attribute</b></td>
  166. <td valign="top"><b>Description</b></td>
  167. <td align="center" valign="top"><b>Required</b></td>
  168. </tr>
  169. <tr>
  170. <td valign="top">force</td>
  171. <td valign="top">force a refresh of files</td>
  172. <td valign="top" align="center">no</td>
  173. </tr>
  174. <tr>
  175. <td valign="top">label</td>
  176. <td valign="top">sync client to label</td>
  177. <td valign="top" align="center">no</td>
  178. </tr>
  179. </table>
  180. <h3>Examples</h3>
  181. <pre>&lt;p4sync label=&quot;nightlybuild-0.0123&quot; force=&quot;yes&quot; /&gt;
  182. &lt;p4sync view=&quot;//depot/projects/projectfoo/main/src/...&quot; /&gt;
  183. </pre>
  184. <hr>
  185. <h2><a name="p4change">P4Change</a></h2>
  186. <h3>Description:</h3>
  187. <p>Request a new changelist from the Perforce server.
  188. This task sets the ${p4.change} property which can then be passed to <A HREF="#p4submit">P4Submit</A>,
  189. <A HREF="#p4edit">P4Edit</A>, or <a HREF="#p4add">P4Add</A>.
  190. </p>
  191. <h3>Parameters</h3>
  192. <table border="1" cellpadding="2" cellspacing="0">
  193. <tr>
  194. <td valign="top"><b>Attribute</b></td>
  195. <td valign="top"><b>Description</b></td>
  196. <td align="center" valign="top"><b>Required</b></td>
  197. </tr>
  198. <tr>
  199. <td valign="top">description</td>
  200. <td valign="top">Description for ChangeList. If none specified, it will
  201. default to "AutoSubmit By Ant"</td>
  202. <td valign="top" align="center">No.</td>
  203. </tr>
  204. </table>
  205. <h3>Examples</h3>
  206. <pre>&lt;p4change description="Change Build Number in Script"&gt;
  207. </pre>
  208. <hr>
  209. <h2><a name="p4edit">P4Edit</a></h2>
  210. <h3>Description:</h3>
  211. <p>Open file(s) for edit. P4Change should be used to obtain a new changelist for P4Edit as,
  212. although P4Edit can open files to the default change, P4Submit cannot yet submit it.
  213. </p>
  214. <h3>Parameters</h3>
  215. <table border="1" cellpadding="2" cellspacing="0">
  216. <tr>
  217. <td valign="top"><b>Attribute</b></td>
  218. <td valign="top"><b>Description</b></td>
  219. <td align="center" valign="top"><b>Required</b></td>
  220. </tr>
  221. <tr>
  222. <td valign="top">view</td>
  223. <td valign="top">The filespec to request to edit</td>
  224. <td valign="top" align="center">Yes</td>
  225. </tr>
  226. <tr>
  227. <td valign="top">change</td>
  228. <td valign="top">An existing changelist number to assign files to.</td>
  229. <td valign="top" align="center">No, but see above.</td>
  230. </tr>
  231. </table>
  232. <h3>Examples</h3>
  233. <pre>
  234. &lt;p4edit
  235. view=&quot;//depot/projects/projectfoo/main/src/Blah.java...&quot;
  236. change=&quot;${p4.change}&quot; /&gt;
  237. </pre>
  238. <hr>
  239. <h2><a name="p4submit">P4Submit</a></h2>
  240. <h3>Description:</h3>
  241. <p>Submit a changelist, usually obtained from P4Change.
  242. </p>
  243. <h3>Parameters</h3>
  244. <table border="1" cellpadding="2" cellspacing="0">
  245. <tr>
  246. <td valign="top"><b>Attribute</b></td>
  247. <td valign="top"><b>Description</b></td>
  248. <td align="center" valign="top"><b>Required</b></td>
  249. </tr>
  250. <tr>
  251. <td valign="top">change</td>
  252. <td valign="top">The changelist number to submit</td>
  253. <td valign="top" align="center">Yes</td>
  254. </tr>
  255. </table>
  256. <h3>Examples</h3>
  257. <pre>&lt;p4submit change=&quot;${p4.change}&quot; /&gt;
  258. </pre>
  259. <hr>
  260. <h2><a name="p4have">P4Have</a></h2>
  261. <h3>Description:</h3>
  262. <p>List handy file info reflecting the current client contents.
  263. </p>
  264. <h3>Parameters</h3>
  265. <table border="1" cellpadding="2" cellspacing="0">
  266. <tr>
  267. <td valign="top"><b>Attribute</b></td>
  268. <td valign="top"><b>Description</b></td>
  269. <td align="center" valign="top"><b>Required</b></td>
  270. </tr>
  271. <tr>
  272. <td valign="top">None</td>
  273. <td valign="top" align="center">--</td>
  274. <td valign="top" align="center">--</td>
  275. </tr>
  276. </table>
  277. <h3>Examples</h3>
  278. <pre>&lt;p4have /&gt;
  279. </pre>
  280. <hr>
  281. <h2><a name="p4label">P4Label</a></h2>
  282. <h3>Description:</h3>
  283. <p>Create a new label and set contents to reflect current client file revisions.
  284. </p>
  285. <h3>Parameters</h3>
  286. <table border="1" cellpadding="2" cellspacing="0">
  287. <tr>
  288. <td valign="top"><b>Attribute</b></td>
  289. <td valign="top"><b>Description</b></td>
  290. <td align="center" valign="top"><b>Required</b></td>
  291. </tr>
  292. <tr>
  293. <td valign="top">name</td>
  294. <td valign="top">The name of the label</td>
  295. <td valign="top" align="center">Yes</td>
  296. </tr>
  297. <tr>
  298. <td valign="top">view</td>
  299. <td valign="top">client view to use for label</td>
  300. <td valign="top" align="center">No</td>
  301. </tr>
  302. <tr>
  303. <td valign="top">desc</td>
  304. <td valign="top">Label Description</td>
  305. <td valign="top" align="center">No</td>
  306. </tr>
  307. <tr>
  308. <td valign="top">lock</td>
  309. <td valign="top">Lock the label once created.</td>
  310. <td valign="top" align="center">No</td>
  311. </tr>
  312. </table>
  313. <h3>Examples</h3>
  314. <pre>
  315. &lt;p4label
  316. name=&quot;NightlyBuild:${DSTAMP}:${TSTAMP}&quot;
  317. desc=&quot;Auto Nightly Build&quot;
  318. lock=&quot;locked&quot;
  319. /&gt;
  320. </pre>
  321. <hr>
  322. <h2><a name="p4counter">P4Counter</a></h2>
  323. <h3>Description:</h3>
  324. <p>
  325. Obtain or set the value of a counter. When used in its base form
  326. (where only the counter name is provided), the counter value will be
  327. printed to the output stream. When the value is provided, the counter
  328. will be set to the value provided. When a property name is provided,
  329. the property will be filled with the value of the counter. You may
  330. not specify to both get and set the value of the counter in the same
  331. Task.
  332. </p>
  333. <P>
  334. The user performing this task must have Perforce &quot;review&quot; permissions
  335. as defined by Perforce protections in order for this task to succeed.
  336. </P>
  337. <h3>Parameters</h3>
  338. <table border="1" cellpadding="2" cellspacing="0">
  339. <tr>
  340. <td valign="top"><b>Attribute</b></td>
  341. <td valign="top"><b>Description</b></td>
  342. <td align="center" valign="top"><b>Required</b></td>
  343. </tr>
  344. <tr>
  345. <td valign="top">name</td>
  346. <td valign="top">The name of the counter</td>
  347. <td valign="top" align="center">Yes</td>
  348. </tr>
  349. <tr>
  350. <td valign="top">value</td>
  351. <td valign="top">The new value for the counter</td>
  352. <td valign="top" align="center">No</td>
  353. </tr>
  354. <tr>
  355. <td valign="top">property</td>
  356. <td valign="top">The property to be set with the value of the counter</td>
  357. <td valign="top" align="center">No</td>
  358. </tr>
  359. </table>
  360. <h3>Examples</h3>
  361. Print the value of the counter named &quot;last-clean-build&quot; to the output stream:
  362. <pre>
  363. &lt;p4counter name=&quot;last-clean-build&quot; /&gt;
  364. </PRE>
  365. Set the value of the counter based on the value of the &quot;TSTAMP&quot; property:
  366. <PRE>
  367. &lt;p4counter name=&quot;last-clean-build&quot; value=&quot;${TSTAMP}&quot; /&gt;
  368. </PRE>
  369. Set the value of the &quot;p4.last.clean.build&quot; property to the current
  370. value of the &quot;last-clean-build&quot; counter:
  371. <PRE>
  372. &lt;p4counter name=&quot;last-clean-build&quot; property=&quot;${p4.last.clean.build}&quot; /&gt;
  373. </pre>
  374. <hr>
  375. <h2><a name="p4reopen">P4Reopen</a></h2>
  376. <h3>Description:</h3>
  377. <p>
  378. Move (or reopen in Perforce speak) checkout files between changelists.
  379. </p>
  380. <h3>Parameters</h3>
  381. <table border="1" cellpadding="2" cellspacing="0">
  382. <tr>
  383. <td valign="top"><b>Attribute</b></td>
  384. <td valign="top"><b>Description</b></td>
  385. <td align="center" valign="top"><b>Required</b></td>
  386. </tr>
  387. <tr>
  388. <td valign="top">tochange</td>
  389. <td valign="top">The changelist to move files to.</td>
  390. <td valign="top" align="center">Yes</td>
  391. </tr>
  392. </table>
  393. <h3>Examples</h3>
  394. Move all open files to the default changelist
  395. <pre>
  396. &lt;p4reopen view=&quot;//...&quot; tochange=&quot;default&quot; /&gt;
  397. </PRE>
  398. Create a new changelist then reopen into it, any files from the view //projects/foo/main/...
  399. <PRE>
  400. &lt;p4change description="Move files out of the way" /&gt;
  401. &lt;p4reopen view=&quot;//projects/foo/main/...&quot; tochange=&quot;${p4.change}&quot; /&gt;
  402. </pre>
  403. <hr>
  404. <h2><a name="p4revert">P4Revert</a></h2>
  405. <h3>Description:</h3>
  406. <p>
  407. Reverts files.
  408. </p>
  409. <h3>Parameters</h3>
  410. <table border="1" cellpadding="2" cellspacing="0">
  411. <tr>
  412. <td valign="top"><b>Attribute</b></td>
  413. <td valign="top"><b>Description</b></td>
  414. <td align="center" valign="top"><b>Required</b></td>
  415. </tr>
  416. <tr>
  417. <td valign="top">change</td>
  418. <td valign="top">The changelist to revert.</td>
  419. <td valign="top" align="center">No</td>
  420. </tr>
  421. <tr>
  422. <td valign="top">revertOnlyUnchanged</td>
  423. <td valign="top">Revert only unchanged files (p4 revert -a)</td>
  424. <td valign="top" align="center">No</td>
  425. </tr>
  426. </table>
  427. <h3>Examples</h3>
  428. Revert everything!
  429. <pre>
  430. &lt;p4revert view=&quot;//...&quot; /&gt;
  431. </PRE>
  432. Revert any unchanged files in the default change
  433. <PRE>
  434. &lt;p4revert change="default" revertonlyunchanged=&quot;true&quot; /&gt;
  435. </pre>
  436. <hr>
  437. <h2><a name="p4add">P4Add</a></h2>
  438. <h3>Description:</h3>
  439. <p>
  440. Adds files specified in nested fileset children.
  441. </p>
  442. <h3>Parameters</h3>
  443. <table border="1" cellpadding="2" cellspacing="0">
  444. <tr>
  445. <td valign="top"><b>Attribute</b></td>
  446. <td valign="top"><b>Description</b></td>
  447. <td align="center" valign="top"><b>Required</b></td>
  448. </tr>
  449. <tr>
  450. <td valign="top">commandlength</td>
  451. <td valign="top">A positive integer specifying the maximum length
  452. of the commandline when calling Perforce to add the files.
  453. Defaults to 450, higher values mean faster execution,
  454. but also possible failures.</td>
  455. <td valign="top" align="center">No</td>
  456. </tr>
  457. <tr>
  458. <td valign="top">changelist</td>
  459. <td valign="top">If specified the open files are associated with the
  460. specified pending changelist number; otherwise the open files are
  461. associated with the default changelist.</td>
  462. <td valign="top" align="center">No</td>
  463. </tr>
  464. </table>
  465. <h3>Examples</h3>
  466. Require a changelist, add all java files starting from a directory,
  467. and submit
  468. <pre>
  469. &lt;p4change/&gt;
  470. &lt;p4add commandlength=&quot;20000&quot; changelist=&quot;${p4.change}&quot;&gt;
  471. &lt;fileset dir=&quot;../dir/src/&quot; includes=&quot;**/*.java&quot;/&gt;
  472. &lt;p4add&gt;
  473. &lt;p4submit change=&quot;${p4.change}&quot;/&gt;
  474. </pre>
  475. <h2><a name="changes">Change History</a></h2>
  476. <table border="1" cellpadding="2" cellspacing="0">
  477. <tr>
  478. <td valign="top">Sept 2000</td>
  479. <td valign="top" align="center">--</td>
  480. <td valign="top">Internal Release within Rubus</td>
  481. </tr>
  482. <tr>
  483. <td valign="top">Nov 2000</td>
  484. <td valign="top">V1.0</td>
  485. <td valign="top">Initial Release donated to ASF :-)</td>
  486. </tr>
  487. <tr>
  488. <td valign="top">Jan 2001</td>
  489. <td valign="top">V1.1</td>
  490. <td valign="top">fixed cross platform (NT/Unix) bug<br>refactored p4 output handling code<br>refactored exec'ing code</td>
  491. </tr>
  492. </table>
  493. <hr>
  494. <p align="center">Copyright &copy; 2001 Apache Software Foundation. All rights
  495. Reserved.</p>
  496. </body>
  497. </html>