[SCM] source code management-Perforce command line

Source: Internet
Author: User

A P4 (perforce) Environment and sample project

P4 environment:

Sample project:

 

Binary P4 command line

1) p4env. bat

Set path = C: \ Program Files \ Perforce; % path %

Set P4Port = localhost: 1666
Set p4user = AAA
Set p4passwd = aaa
Set p4client = TestProject_AAA

Set p4Root = // depot/TestProject
Set p4LocalRoot = c: \ MyLocalTestProject

Set p4Drive = H:

If exist % p4Drive % (subst/d % p4Drive %)
Subst % p4Drive % p4LocalRoot %

Set p4port, p4user, p4password, and p4client before executing all commands;
Generally, subst Virtual Disks are required to avoid absolute paths and ensure that the development environment is available on all developers.

 

2) p4login + logout. bat

Call p4env. bat

Echo % p4passwd % | p4 login

Pause

P4 logout

Pause

Before executing all p4 commands, run p4 login to obtain ticket (indicating to use the current % p4user % for login ).

 

3) p4set. bat

Call p4env. bat

P4 set

Pause

View the current p4 environment variable settings, including p4user, p4passwd, p4client, p4port ....

 

4) p4sync. bat

Call p4env. bat

REM sync to head
P4 sync-f % p4Root % /...

Pause

REM sync to CL
P4 sync-f % p4Root %/... @ 9

Pause

REM sync to label
P4 sync-f % p4Root %/... @ label1

Pause

You can sync to the latest head, to the specified CL (changelist), or to the specified label;
When syncing to the specified label, only the files included in the label are synchronized. The newly added files are not synchronized after the label.

 

5) p4label. bat

Call p4env. bat

REM label the head version and create the label
P4 tag-l label2 % p4Root % /...

Pause

REM label to one CL and create the label
REM this is the best way to label p4 by one CL
P4 tag-l label1_1 % p4Root %/... @ 12

Pause

REM show all files in one label
P4 files @ label2

Pause

Label is used to identify certain files of a specific version;

The label can identify the latest file on p4 or the version of some files at the specified CL time;

Labelsync uses the content of the current client to update the label. Use label to create a label.

 

6) p4latestcl. bat

Call p4env. bat

For/f "tokens = 2" % I IN ('p4 changes-m 1% p4Root %/... ') do (@ echo % I> CL.txt)

Set/p latestCL = <CL.txt
Echo % latestCL %

Pause

Used to obtain the latest CL.

 

7) p4checkin. bat

Call p4env. bat

Set FileBeChanged = % p4Drive % \ TestProject \ components.txt

REM generate p4 change form for new CL
Printf "\ n"> change.txt
Printf "Change: \ tnew \ n"> change.txt
Printf "\ n"> change.txt
Printf "Status: \ tnew \ n"> change.txt
Printf "\ n"> change.txt
Printf "Description: \ n"> change.txt
Printf "\ tUpdate BBB components.txt! \ N "> change.txt

Pause

REM new CL
Cat change.txt | p4 change-I | awk '{print $2}'> newCL.txt
Set/p newcl = <newcl.txt

Pause

REM add the changed files into the CL
P4 edit-c % newcl % FileBeChanged %

Pause

REM update BBB component to 5
Attrib-r % FileBeChanged %
Set newversion = 5

Sed s/'bbb. * '/'bbb % newversion %'/% FileBeChanged %> temp.txt
Cat temp.txt> % FileBeChanged %

Pause

REM submit the CL
P4 submit-c % newcl %

Pause

Components.txt is as follows:

BBB 4
CCC 9

This script demonstrates the process of automatically modifying the componets.txt file and then automatically submitting the file;

P4 changeis used to upload new CLs, And the change.txt file is input;

P4 edit is used to add the modified file to CL;

P4 submit is used to submit CL;

The third-party sed.exe,cat.exe.

 

Complete!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.