Friday, May 3, 2019

Fromatting Perforce Output For Simple Scripting

Perforce has a global option -ztag




If you run a normal perforce command like this


1
2
3
4
p4 files -m3 ...
//depot/da/infra/dmx/main/lib/python/dmx/tnrlib/__init__.py#1 - add change 4491003 (text+kx)
//depot/da/infra/dmx/main/lib/python/dmx/tnrlib/audit_check.py#57 - edit change 5716075 (text+kx)
//depot/da/infra/dmx/main/lib/python/dmx/tnrlib/css/style.css#1 - branch change 4757380 (text+k)


With the -ztag ...

1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
p4 -ztag files -m3 ...
... depotFile //depot/da/infra/dmx/main/lib/python/dmx/tnrlib/__init__.py
... rev 1
... change 4491003
... action add
... type text+kx
... time 1473325143

... depotFile //depot/da/infra/dmx/main/lib/python/dmx/tnrlib/audit_check.py
... rev 57
... change 5716075
... action edit
... type text+kx
... time 1556850031

... depotFile //depot/da/infra/dmx/main/lib/python/dmx/tnrlib/css/style.css
... rev 1
... change 4757380
... action branch
... type text+k
... time 1494905434



Now, say, I'd like to have perforce report out the following info in 3 columns, separated by :::, like this

1
depotFile ::: revision ::: type



All I need to do is run the following:-

1
2
3
4
p42 -ztag -F "%depotFile% ::: %rev% ::: %type%" files -m3 ...
//depot/da/infra/dmx/main/lib/python/dmx/tnrlib/__init__.py ::: 1 ::: text+kx
//depot/da/infra/dmx/main/lib/python/dmx/tnrlib/audit_check.py ::: 57 ::: text+kx
//depot/da/infra/dmx/main/lib/python/dmx/tnrlib/css/style.css ::: 1 ::: text+k


... and here you go :)

No comments:

Post a Comment

How To Bypass Kerberos(kinit) Authentication

Whenever you try to setuid and impersonate as someone else to run something, it is very likely that you will run into kerberos/kinit issues....