[p4] p4 submit w/o an editor

Weintraub, David david.weintraub at bofasecurities.com
Fri Jul 14 13:59:43 PDT 2006

> Perforce should be a kit. It could use an -m comment like CVS, but in
> it should not simplify things so much that scripting becomes

The problem is I WANT to script Perforce, but Perforce seems to do
almost everything in its power to prevent me from easily writing

* Inability to run commands without creating forms
A lot of software now use text forms for entry. Heck, even CVS brought
up a text form in your favorite editor if you didn't put in a comment
when you ran "cvs commit". I don't mind the text forms. All I ask is an
alternative way to get the information into the command via command line

Look at the example in Chapter 8
tml#1032869>. I've been doing Unix shell scripting for almost 20 years,
and I had to read that a couple of times before I understood what was
going on. I then read it a few more times because I found the whole
thing so unbelievable.

I shouldn't have to go through temp files or pipes to do basic commands.

* Perforce commands always returning a zero return code even when they
Standard practice for Unix commands: If you output something on STDERR,
you return a non-zero return code. A non-zero return code doesn't mean
your command failed. It means that I might not be getting back the
information I requested. Almost all of my scripts are a big mess
handling this situation. The only way I found around it is to run "p4
-s", and look for lines that start with "error:".

* Incomplete Reporting commands
When I get a list of all the clients, labels, users, branches,
changelists, etc., I end up having to parse the output in order to find
the information I'm looking for. In almost all Unix reporting commands,
there is a flag for short output (either something like "-s" or "-short"
or "-brief"). That is, if I am listing users, you give me only the user
ids. If I am listing clients, you give me only client ids.

I would also like a way to verify whether if an id exists. For example,
if I have a script to create a new user ID, and I give the script an
existing ID, I want the script to be able to tell me. In ClearCase, all
the listing commands allowed me to do something like this:

   $ cleartool lstype lbtype:FOO1.0.0

If the command returned a non-zero exit code, I can assume that the
label FOO1.0.0 didn't exist. In Perforce I have two choices:

1). Run the command with the "-o" option and see if the form doesn't
contain an "Access:" field
2). Run through the entire list and see if my Id is in any of the lines.

* Format flexibility in listing command output
Here's a common example, I want to find all clients for a particular
user. The "p4 clients" command doesn't list the user's name in the
output. I could use "p4 -ztag clients", but then the Owner field is on a
separate line from the client's name. I could write an entire script to
parse the output and handle this situation, but it would be much easier
if I could format my output:

    $ p4 clients -fmt "%i:%o\n" | awk -F: '$2 = "david" {print $1}'

Look, I like Perforce. It is fast and powerful. However, I've found
scripting it to be a big pain. Just look at the difference between
Subversion triggers and Perforce triggers. Subversion triggers on
failure return STDERR while Perforce triggers return STDOUT. In
Subversion, I see why my command fails. In Perforce, I don't see the
errors. Why was STDOUT made the default? Yes, I can get around this, but
that's my point. It should work as expected, not something I have to get

-----Original Message-----
From: perforce-user-bounces at perforce.com
[mailto:perforce-user-bounces at perforce.com] On Behalf Of Phlip
Sent: Friday, July 14, 2006 1:36 PM
To: perforce-user at perforce.com
Subject: Re: [p4] p4 submit w/o an editor

Sam Roberts wrote:

> > I want an source code control system (and an editor), I don't want 
> > to write one.
> Amen.


Observe what our trivial integrate() function did. It synchronized all
the source, then re-tested the current folder, and only then submitted
the change.

All projects need a standard set of steps to integrate, to outegrate,
and to test. Programmers should not type the same 70 keystrokes for each
step, and Perforce should not guess what their exact
Standard-Operating-Procedure is. Perforce should be a kit. It could use
an -m comment like CVS, but in general it should not simplify things so
much that scripting becomes impossible.

  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!
perforce-user mailing list  -  perforce-user at perforce.com

More information about the perforce-user mailing list