beginner.html #1

  • //
  • guest/
  • jeff_bowles/
  • faq/
  • beginner.html
  • View
  • Commits
  • Open Download .zip Download (32 KB)
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; U; OSF1 V4.0 alpha) [Netscape]">
   <TITLE>Basic Perforce FAQ</TITLE>
<x-html>
</HEAD>
<BODY>

<H1>
Basic Perforce FAQ</H1>

<H3>
Note - the intended audience for this FAQ is a person using Perforce for
software development. There's a separate <A HREF="admin.html">FAQ for system
administrators</A>, and eventually we'll have one for advanced Perforce
users.</H3>
<I>This FAQ assumes that there is a Perforce Administrator who knows some
of the more complex parts of Perforce, who can provide help, counseling,
and deal with policy-specific issues.&nbsp; This FAQ is taken from an initial
set of questions provided by
<A HREF="mailto:[email protected]">Richard Geiger</A>
and <A HREF="mailto:[email protected]">Jeff Bowles</A>.</I>

<BR>&nbsp;
<OL>
<H4>
<B>Initial List</B></H4>

<LI>
<A HREF="#begin...">Where do I begin?</A></LI>

<LI>
<A HREF="#whatisSCM">What is S.C.M.?</A></LI>

<H4>
Getting and modifying files</H4>

<LI>
<A HREF="#checkoutsource">How do I check out a source tree?</A></LI>

<LI>
<A HREF="#changefiles">How do I make a change to a file
and check it in?</A></LI>

<LI>
<A HREF="#changeeditor">What if I have a favorite editor and want
to use it when I do a change submission?</A></LI>

<LI>
<A HREF="#addfile">How do I add a new directory?</A></LI>

<LI>
<A HREF="#removefile">How do I remove a directory?</A></LI>

<LI>
<A HREF="#olderversion">How do I check out some older
version of a file?</A></LI>

<LI>
<A HREF="#oldertree">How do I check out an entire
tree as of some date?</A></LI>

<LI>
<A HREF="#alltree">How do I check out an entire tree
corresponding to some build or release?</A></LI>

<H4>
Comparing what you've gotten to the reference copy</H4>

<LI>
<A HREF="#diff">How do I compare a working
file to the base?</A></LI>

<LI>
<A HREF="#difftree">How do I compare a whole tree
to the base?</A></LI>

<LI>
<A HREF="#diffoptions">How do I get my favorite diff
behaviors with p4 diff?</A></LI>

<LI>
<A HREF="#updatetree">How do I update a tree from the base?</A></LI>

<LI>
<A HREF="#comparefiles">How do I compare a working file
to an older version (other than the base)?</A></LI>

<H4>
Getting information about a file or workspace</H4>

<LI>
<A HREF="#p4have">How do I get a list of all
files I have open on all my client workspaces?</A></LI>

<LI>
<A HREF="#p4describe">How do I examine the change
log for a file?</A></LI>

<H4>
Abandoning work and starting over</H4>

<LI>
<A HREF="#p4revert">How do I abandon my changes
and pick up a clean copy from the base?</A></LI>

<LI>
<A HREF="#individual_change">How do I propagate an individual
change made in one branch to another?</A></LI>

<LI>
<A HREF="#deletefile_weird">I created a file that begins with a dash, and
want to 'p4 delete' it and cannot. What can I do?</A></LI>
<H4>
Changing your workspace (moving it, deleting it)</H4>

<LI>
<A HREF="#deleteclient">How do I delete a client workspace?</A></LI>

<LI>
<A HREF="#moveclient">How do I move a client workspace?</A></LI>
<h4>Miscellaneous problems</h4>
<LI>
<A HREF="#sync_fails">I can't &quot;p4 sync&quot; a particular file. What might be going on?</li>
</OL>
<OL>
<HR>
<LI>
<A NAME="begin..."></A><B>Where do I begin?</B></LI>

<BR>Start with <A HREF="http://perforce.com/perforce/doc.982/cmdguide/quickstart.html">chapters
#3-5 of the user's guide</A> - that's referred to as the <I>Quick Start</I>
to the product.&nbsp; <A HREF="http://perforce.com/perforce/technical/">All</A>
of the documentation is on-line.

<P>It's probably best to create a small workspace (the term is "client")
to play in, so that you can experiment with a few files and not necessarily
the 16,000 files that you're planning to manage with source control.
<BR>&nbsp;<HR>
<LI>
<A NAME="whatisSCM"></A><B>What is S.C.M.?</B></LI>

<BR>Short answer: it's a way to maintain revisions of files so that you
can easily recreate a version of a file from any moment in time.

<P>The &quot;S.C.M.&quot; translates to &quot;Source Code Management&quot; or perhaps &quot;Software
Code Management&quot; or &quot;Software Control Management&quot; - the better systems
let you manage large sets of files, have multiple people working with the
same body of files (a development team of 1 person isn't much fun),&nbsp;
and work on different platforms (such as Windows/NT and Unix) transparently.

<P>There are a lot of S.C.M. products around - this FAQ won't try to spend
a lot of time enumerating them or contrasting them.
&nbsp;
<HR>
<LI>
<A NAME="checkoutsource"></A><B>How do I check out a source tree?</B></LI>

<BR>&nbsp;
<BR>Another way to phrase the question is &quot;How do I get files and begin
editing them?&quot;.&nbsp; This question will answer the first part of the question
- the next FAQ will answer the rest.
<BR>&nbsp;
<H5>
To get a set of files...</H5>
Each of the following cases assumes you have a &quot;Perforce client&quot; (a.k.a.
'workspace') already. If not, see the FAQ to create one.
<BR>&nbsp;
<BR><I>Case #1: you need to get all the files - the most recent revision
of each file.</I>
<BR>&nbsp;
<UL>Type

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
p4 sync</FONT></TT>

<P>That will get you a read-only copy of the &quot;head &quot;revision of every file
that your client can see.</UL>
<I>Case #2: You need to get the files in a specific directory - the most
recent revision of each file.</I>
<BR>&nbsp;
<UL>You'll want to &quot;cd&quot; (chdir) to the directory you want to get.&nbsp;
Then type p4 sync ... to get the files that should go into that directory.
For example:

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
cd&nbsp; <I>directoryname</I><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
p4&nbsp; sync ...</FONT></TT>

<P>That will get you a read-only copy of the &quot;head&quot; revision of every file
<I>in that directory and its subdirectories </I>that your client can see.</UL>
<I>Case #3: You need to get the files from some `label' someone made for
you.</I>
<BR>&nbsp;
<UL>If the label name is "BUILD_28", you'll be updating your client (a.k.a.
workspace) the "the revision of each file that is included in label 'BUILD_28'."&nbsp;
Note that this means that your local copy of files not included in 'BUILD_28'
are removed.

<P>Some examples:
<BR>&nbsp;
<OL>
<OL>&nbsp;
<CENTER><TABLE BORDER WIDTH="80%" NOSAVE >
<TR>
<TD><TT><FONT COLOR="#990000">p4 sync @BUILD_28</FONT></TT></TD>

<TD>Update the local copies of files on the current client to be the exact
revision specified in label "BUILD_28".&nbsp; The local copy of files not
included in the label, but managed by Perforce, are removed from the client.</TD>
</TR>

<TR NOSAVE>
<TD><TT><FONT COLOR="#990000">cd&nbsp;&nbsp; <I>directoryname</I></FONT></TT>&nbsp;
<BR><TT><FONT COLOR="#990000">p4&nbsp;&nbsp; sync&nbsp; ...@BUILD_28</FONT></TT></TD>

<TD NOSAVE>Update the local copies of files <I>in directoryname (and underneath
that tree)</I> on the current client to be the exact revision specified
in label "BUILD_28".&nbsp;

<P>The local copy <I>in directoryname (and underneath that tree) </I>of
files not included in the label, but managed by Perforce, are removed from
the client. Files not under <I>directoryname</I> aren't touched.</TD>
</TR>

<TR>
<TD><TT><FONT COLOR="#990000">p4 sync&nbsp; <I>directoryname</I>/...@BUILD_28</FONT></TT></TD>

<TD>Should do exactly the same thing as the previous example. (Neat, huh?)</TD>
</TR>

<CAPTION ALIGN=BOTTOM>&nbsp;</CAPTION>
</TABLE></CENTER>
&nbsp;</OL>
</OL>
&nbsp;</UL>
&nbsp;
<BR>&nbsp;<HR>
<LI>
<A NAME="changefiles"></A><B>How do I make a change
to a file and check it in?</B></LI>

<BR>&nbsp;
<H5>
To edit a set of files...</H5>
Normally, you will edit a file using three steps:
<UL>
<LI>
Open the file for the 'edit' operation - you can open more than one file
at a time;</LI>

<LI>
Do the editing in your favorite editor, and make the contents of the files
into what you want.</LI>

<LI>
Submit the modifications as one 'atomic' change so that they're available
to other people.</LI>
</UL>
&nbsp;
<H5>
Step #1:</H5>

<UL>The basic edit command is
<BR>&nbsp;
<BR>&nbsp;<TT><FONT COLOR="#990000">&nbsp;&nbsp; p4&nbsp;&nbsp; edit&nbsp;&nbsp;
<I>filename</I></FONT></TT>
<BR>&nbsp;
<BR>or,
<BR>&nbsp;
<BR><TT><FONT COLOR="#990000">&nbsp;&nbsp; p4&nbsp;&nbsp; edit&nbsp;&nbsp;
<I>filename1&nbsp; filename2&nbsp;</I>&nbsp;&nbsp; </FONT></TT><I>(and
so on)</I>
<BR>&nbsp;
<BR>and occasionally,
<BR>&nbsp;
<BR><TT><FONT COLOR="#990000">&nbsp;&nbsp; p4&nbsp;&nbsp; edit&nbsp;&nbsp;
<I>directoryname</I>/...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></TT><I>(edit
all files in `directoryname' and its subdirectories)</I>
<BR>&nbsp;</UL>

<H5>
Step #2:</H5>

<UL>Do the editing using your favorite editor - Perforce isn't directly
involved in this step.&nbsp; You can always run through "Step #1" on other
files, if you decide you need to edit more files.

<P><I>In Perforce, the 'working' copy of the file is a local copy stored
in the "client area". The modified contents are sent back to the server
only when you do a 'p4 submit'.</I></UL>

<H5>
Step #3:</H5>

<UL>The basic "submit my changes" command is:
<BR>&nbsp;
<BR><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; p4&nbsp; submit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</FONT><I><FONT COLOR="#000000">(submit all modifications)</FONT></I></TT>
<BR>&nbsp;
<BR>or, occasionally,
<BR>&nbsp;
<BR><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; p4 submit&nbsp;&nbsp;
<I>filename&nbsp;&nbsp;&nbsp; </I></FONT></TT><I>(submit only this one
file's modifications, leave the rest checked out)</I>

<P><B>When you run...</B>
<BR>&nbsp;
<BR><B><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; p4 submit</FONT></TT></B>
<BR>&nbsp;
<BR><B>...you'll be dumped into the editor, to write a description of why
you made these changes. </B>See the manual for more details.
<BR>&nbsp;</UL>
<HR>
<LI>
<A NAME="changeeditor"></A><B>What if I have a favorite editor and
want to use it when I do a change submission?</B></LI>

<BR>&nbsp;
<BR>You can either set the environment variable "P4EDITOR" to be the name
of the editor you want to run, or if you're on Windows/NT, use:&nbsp;<BR>
<BR>
<BR><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; p4&nbsp; set&nbsp; P4EDITOR=<I>commandname</I></FONT></TT>
<BR><B>&nbsp;</B><HR>
<LI>
<A NAME="addfile"></A><B>How do I add a new directory?</B></LI>

<BR>&nbsp;
<BR>You don't need to add a directory, explicitly.&nbsp; You simply add
files in that directory, using

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp; cd&nbsp;&nbsp; <I>directoryname</I><BR>&nbsp;&nbsp;&nbsp;&nbsp; p4&nbsp;&nbsp; add&nbsp;&nbsp;
<I>filename</I></FONT></TT>

<P>or,

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp; p4&nbsp;&nbsp; add&nbsp;&nbsp;
<I>directoryname</I>/<I>filename1&nbsp; directoryname/filename2&nbsp;</I>&nbsp;&nbsp;
</FONT></TT><I>(and so on)</I>

<P>The final step, which is to run&nbsp;&nbsp; <TT><FONT COLOR="#990000">p4
submit</FONT> </TT>, will make these new files available to other Perforce
clients.

<P>Perforce infers the existence of new directories whenever it sees a
new directory it hasn't seen before.
&nbsp;
<HR>
<LI>
<A NAME="removefile"></A><B>How do I remove a directory?</B></LI>


<P>&nbsp;
<BR>You don't need to remove a directory, explicitly.&nbsp; You simply
remove files in that directory, using
<BR>&nbsp;
<BR><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp; cd&nbsp;&nbsp; <I>directoryname</I><BR>&nbsp;&nbsp;&nbsp;&nbsp; p4&nbsp;&nbsp; delete&nbsp;&nbsp;
<I>filename</I></FONT></TT>
<BR>&nbsp;
<BR>or,
<BR><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp; p4&nbsp;&nbsp; delete&nbsp;&nbsp;
<I>directoryname</I>/<I>filename1&nbsp; directoryname/filename2&nbsp;</I>&nbsp;&nbsp;
</FONT></TT><I>(and so on)</I>

<P>and occasionally,
<BR>&nbsp;
<BR><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp; p4&nbsp;&nbsp; delete&nbsp;&nbsp;
<I>directoryname</I>/...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></TT><I>(remove
all files in `directoryname' and its subdirectories)</I>

<P>The penultimate step, which is to run&nbsp;&nbsp; <TT><FONT COLOR="#990000">p4
submit</FONT> </TT>, will these deletions to other Perforce clients.

<P><B>The final step is to remove the empty directories on your client:&nbsp;"p4
delete / p4 submit"&nbsp;removed the files, but not the directories.</B>
&nbsp;
<HR>
<LI>
<A NAME="olderversion"></A><B>How do I check out some
older version of a file?</B></LI>

<BR>&nbsp;
<BR>You'll need to retrieve that revision first, then&nbsp; <TT><FONT COLOR="#990000">p4
edit </FONT></TT>the file. That's the easy part. The hard part is deciding
how to submit the change. (Let's save that for later in the answer.)

<P>For example, if you want to edit revision #12 of xyz.java, you'll need
to type:
<BR>&nbsp;
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;<FONT COLOR="#990000"> p4&nbsp;&nbsp; sync&nbsp;
<I>xyz.java#12</I><BR>&nbsp;&nbsp;&nbsp;&nbsp; p4&nbsp;&nbsp; edit&nbsp;
<I>xyz.java</I></FONT></TT>

<P>The first command, of course, isn't needed if you already have revision
#12 of <I>xyz.java</I>. (You can tell which revision you have by typing&nbsp;
<TT><FONT COLOR="#990000">p4 files&nbsp; <I>xyz.java</I> </FONT><FONT COLOR="#000000">.</FONT></TT>

<P><B><FONT COLOR="#000000">You'll be told, when you run </FONT><FONT COLOR="#990000">p4&nbsp;&nbsp;
edit&nbsp; xyz.java</FONT><FONT COLOR="#000000">, that you're not editing
the most recent revision and that you'll need to resolve later revisions
prior to submitting your changes.&nbsp; </FONT></B><FONT COLOR="#000000">(If
you think about it, that makes sense.)</FONT>
<BR>Now the file's opened for "edit", and you can do whatever you want
to the file. Submitting it, however, is going to be a problem: you don't
want to inadvertently overwrite the contents of later revisions of the
files.

<P><I>Case #1: you really do want to <U>overwrite</U> the later revisions
for some reason.</I>
<BR>&nbsp;
<UL>When you run the command...

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
p4 submit</FONT></TT>

<P>you'll be told that the your changes need to be resolved against more
recent revisions prior to submitting.&nbsp; <B>Write down the change number
it gives in the error message (e.g. "submit -c 12345")</B>, although you
can always find it again by running&nbsp; the command&nbsp; <TT><FONT COLOR="#990000">p4&nbsp;
changes -s pending </FONT><FONT COLOR="#000000">.</FONT></TT>
<BR>&nbsp;
<BR>&nbsp;
<BR>&nbsp;</UL>
<I>Case #2: You don't want to overwrite anything - you were just experimenting
with an old version of a file to debug something.</I>
<BR>&nbsp;
<UL>From <A HREF="#p4revert">another question</A>
in this FAQ: use&nbsp; <TT><FONT COLOR="#990000">p4 revert <I>filename</I>
</FONT></TT><FONT COLOR="#000000">to discard the modifications you've made
to <I>filename</I> and retrieve a fresh copy of the <U>exact same revision</U>
you had prior to typing</FONT>&nbsp; <TT><FONT COLOR="#990000">p4 edit
<I>filename</I> </FONT><FONT COLOR="#000000">.</FONT></TT>
<BR>&nbsp;</UL>
<HR>
<LI>
<A NAME="oldertree"></A><B>How do I check out an
entire tree as of some date?</B></LI>

<BR>&nbsp;
<H5>
For release 98.2...</H5>

<UL>There's an entry in the <A HREF="http://perforce.com/perforce/doc.982/user/relnotes.txt">release
notes</A> that says:</UL>
&nbsp;
<UL>
<CENTER><TABLE COLS=1 WIDTH="70%" NOSAVE >
<TR NOSAVE>
<TD NOSAVE><I><FONT COLOR="#009900">&nbsp;</FONT><FONT COLOR="#660000">Wherever
revision specifications are supported, @date and "@datetime" can now be
used in addition to @change and @label.&nbsp; The format for date is YYYY/MM/DD,
and the format for datetime is YYYY/MM/DD:HH:MM:SS.&nbsp; If no time is
given, midnight is assumed.</FONT></I></TD>
</TR>
</TABLE></CENTER>
&nbsp;</UL>

<UL>That means that the command&nbsp; <TT><FONT COLOR="#990000">p4 sync
...@<I>1998/09/02 </I></FONT></TT><FONT COLOR="#000000">will retrieve all
files that map to the current directory (and its subdirectories!), at the
revisions that were current at midnight on September 2, 1998.</FONT></UL>

<H5>
<FONT COLOR="#000000">For releases prior to 98.2...</FONT></H5>

<UL><FONT COLOR="#000000">You'll need to use&nbsp;</FONT>&nbsp; <FONT COLOR="#990000"><TT>p4
changes&nbsp;</TT>&nbsp; </FONT><FONT COLOR="#000000">to find the change
number <U>immediately prior</U> to the desired date, and then use the command&nbsp;&nbsp;</FONT>&nbsp;
<TT><FONT COLOR="#990000">p4 sync ...@<I>changenum</I> </FONT></TT><FONT COLOR="#000000">to
retrieve the fileset you want.</FONT></UL>
&nbsp;
<HR>
<LI>
<A NAME="alltree"></A><B>How do I check out an entire
tree corresponding to some build or release?</B></LI>


<P>In general, you'll need to have a piece of data from your build person:
the label name used for that build.&nbsp; (You can always hunt for it,
using the command&nbsp;&nbsp;<FONT COLOR="#000000">&nbsp;</FONT>&nbsp;
<TT><FONT COLOR="#990000">p4 labels </FONT></TT><FONT COLOR="#000000">.)</FONT>

<P><FONT COLOR="#000000">If the label is&nbsp;<I> release3.2label</I>,
you can update your client area to this by typing:</FONT>

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p4 sync&nbsp;
@release3.2label</FONT></TT>

<P><FONT COLOR="#000000">This will update your client to this label, <U>removing
local copies of files that aren't in the label.</U></FONT>
<BR>&nbsp;
<BR>If you want subdirectory xyz to be updated, but no other directories
on your client, you would type:

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p4 sync&nbsp;
xyz/[email protected]</FONT></TT>
<BR>&nbsp;<HR>
<LI>
<A NAME="diff"></A><B>How do I compare a working
file to the base?</B></LI>

<BR>&nbsp;
<BR>Use&nbsp;<TT><FONT COLOR="#990000"> p4 diff <I>filename</I> </FONT></TT>,
which will compare the <U>local copy</U> of a file you've opened for edit
or an integrate operation against the revision of the file you were original
given.

<P>For example, say you've opened&nbsp; <I>xyz.java</I> using the command:
<BR>&nbsp;
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;<FONT COLOR="#990000"> p4&nbsp;&nbsp; edit&nbsp;&nbsp;
<I>xyz.java</I></FONT></TT>
<BR>&nbsp;
<BR>To see your modifications, type:
<BR>&nbsp;
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#990000">p4&nbsp;&nbsp; diff&nbsp;&nbsp;
<I>xyz.java</I></FONT></TT>
<BR>&nbsp;
<BR>Note that this is not comparing your local&nbsp; copy of the file against
the most recent changes that other people have checked in - it's comparing
against the revision you were working against. (That's&nbsp; <TT><FONT COLOR="#990000">p4
diff <I>filename#head </I></FONT>.)</TT><HR>
<LI>
<A NAME="difftree"></A><B>How do I compare a whole
tree to the base?</B></LI>

<BR>&nbsp;
<BR>Use&nbsp; <TT><FONT COLOR="#990000">p4 diff <I>directory/...</I> </FONT></TT>,
which will compare the <U>local copy</U> of every file in <I>directory</I>
that is opened for edit or an integrate operation against the revision
of the file you were original given.

<P>For example, say you've opened&nbsp; <I>xyz.java</I>&nbsp; and<I> z.java
</I>in directory dir1 using the command:
<BR>&nbsp;
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;<FONT COLOR="#990000"> p4&nbsp;&nbsp; edit&nbsp;&nbsp;
<I>dir1/xyz.java&nbsp; dir1/z.java</I></FONT></TT>
<BR>&nbsp;
<BR>To see your modifications, type:
<BR>&nbsp;
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#990000">p4&nbsp;&nbsp; diff&nbsp;&nbsp;
<I>dir1/...</I></FONT></TT>
<BR>&nbsp;
<BR>Note that this is not comparing your local&nbsp; copy of the file against
the most recent changes that other people have checked in - it's comparing
against the revision you were working against. (That's&nbsp; <TT><FONT COLOR="#990000">p4
diff <I>dir1/...#head </I></FONT>.)</TT>
&nbsp;
<HR>
<LI>
<A NAME="diffoptions"></A><B>How do I get my favorite
diff behaviors with p4 diff?</B></LI>

<BR>&nbsp;
<BR>The environment variable $DIFF is the command line that's run when
you run:

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p4 diff&nbsp;<I>
file1&nbsp; file2</I></FONT></TT>

<P><FONT COLOR="#000000">If, for example, the command </FONT><TT><FONT COLOR="#990000">"diff
-c"</FONT></TT><FONT COLOR="#000000">&nbsp; produces "context output format",
then the sequence:</FONT>

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DIFF="diff
-c"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; export
DIFF<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p4 diff&nbsp;<I>
file1&nbsp; file2</I></FONT></TT>

<P><FONT COLOR="#000000">will produce that type of output for the differences
between the two files.</FONT>

<P><FONT COLOR="#000000">Note that&nbsp;</FONT> <TT><FONT COLOR="#990000">p4
diff2&nbsp; <I>file1&nbsp; file2 </I></FONT></TT><FONT COLOR="#000000">doesn't
honor this variable,&nbsp; because the "diff" operation is run on the server
and only the formatted output is returned to the user.</FONT>
<BR>&nbsp;<HR>
<LI>
<A NAME="updatetree"></A><B>How do I update a tree from
the base?</B></LI>

<BR>&nbsp;
<BR>Use&nbsp; <TT><FONT COLOR="#990000">p4 sync <I>directory/...</I> </FONT></TT>,
which will retrieve the most recent revision of every file in <I>directory</I>
(and its subdirectories!) that you haven't already got a copy of.
<BR>&nbsp;
<BR>This makes several assumptions:
<UL>
<LI>
That there's something to get - if you have already updated <I>directory</I>
to the most recent revisions and nothing's been changed since,&nbsp; <TT><FONT COLOR="#990000">p4
sync </FONT></TT><FONT COLOR="#000000">won't retrieve the revisions again.
(</FONT> <TT><FONT COLOR="#990000">p4 sync -f <I>directory/...#have</I>
</FONT></TT><FONT COLOR="#000000">will do that.)</FONT></LI>

<LI>
<FONT COLOR="#000000">That <I>directory</I> is located under your local
Perforce's client root.&nbsp;&nbsp;</FONT> The command...<BR>
<BR></LI>

<BR><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; p4 info</FONT></TT>
<BR>&nbsp;
<BR><FONT COLOR="#000000">will tell you what your client's root directory
is.</FONT>
<LI>
<FONT COLOR="#000000">That <I>directory</I> is mapped in from the Perforce
depot using your client specification. The command...</FONT><BR>
<BR></LI>

<BR><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; cd <I>directory</I><BR>&nbsp;&nbsp;&nbsp; p4 where <I>xxx</I></FONT></TT>

<P><FONT COLOR="#000000">will product output that looks something like:</FONT>
<BR><TT><FONT COLOR="#000000">&nbsp;&nbsp;&nbsp; xxx - file(s) not in client
view.</FONT></TT>
<BR><FONT COLOR="#000000">if the directory's not included in your client
view. (You'll want to see the documentation for help on this, but you'll
know where to start: <U>client specification</U>.)</FONT></UL>
&nbsp;
<HR>
<LI>
<A NAME="comparefiles"></A><B>How do I compare a working
file to an older version (other than the base)?</B></LI>

<BR>&nbsp;
<BR>Use&nbsp;<TT><FONT COLOR="#990000"> p4 diff <I>filename#revision</I>
</FONT></TT>, which will compare the <U>working copy</U> of a file you've
opened for edit or an integrate operation against the revision of the file
you specify using "#revision".

<P>For example, say you've opened&nbsp; <I>xyz.java</I> using the command:
<BR>&nbsp;
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;<FONT COLOR="#990000"> p4&nbsp;&nbsp; edit&nbsp;&nbsp;
<I>xyz.java</I></FONT></TT>
<BR>&nbsp;
<BR>Various "diff" commands follow:
<BR>&nbsp;
<UL>
<DL>&nbsp;
<CENTER><TABLE BORDER WIDTH="80%" NOSAVE >
<TR NOSAVE>
<TD><TT><FONT COLOR="#990000">p4 diff <I>xyz.java</I></FONT></TT></TD>

<TD NOSAVE>Compares your working copy against the revision your edits are
on - if you are editing revision #4 of a file, this will compare your working
copy against revision #4.</TD>
</TR>

<TR>
<TD><TT><FONT COLOR="#990000">p4 diff <I>xyz.java#2</I></FONT></TT></TD>

<TD>Compares your working copy against the revision #2.</TD>
</TR>

<TR>
<TD><TT><FONT COLOR="#990000">p4 diff xyz.java#head&nbsp;</FONT></TT></TD>

<TD>Compares your working copy against the most recent revision in the
depot.</TD>
</TR>

<CAPTION ALIGN=BOTTOM>&nbsp;</CAPTION>
</TABLE></CENTER>
&nbsp;</DL>
</UL>
<HR>
<LI>
<A NAME="p4have"></A><B>How do I get a list
of all files I have open on all my client workspaces?</B></LI>

<BR>&nbsp;
<BR>If your username is <I>joe</I>, then the following command will show
you your opened files for all workspaces:

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p4 opened -a
| grep <I>joe</I></FONT></TT>

<P>If you don't have "grep" (i.e. you're on Windows) you'll need to search
the output of&nbsp; <TT><FONT COLOR="#990000">p4 opened</FONT></TT><FONT COLOR="#000000">
for this.</FONT>
<BR>&nbsp;<HR>
<LI>
<A NAME="p4describe"></A><B>How do I examine the change
log for a file?</B></LI>

<BR>&nbsp;
<BR>Use&nbsp; <TT><FONT COLOR="#990000">p4 filelog <I>filename</I> </FONT></TT><FONT COLOR="#000000">to
get the list of <U>revisions</U> since a file was created in a particular
codeline.</FONT>

<P>Use&nbsp; <TT><FONT COLOR="#990000">p4 changes -i <I>directory/...</I>
</FONT></TT><FONT COLOR="#000000">to get the list of <U>change numbers</U>
since a file stored originally in Perforce.</FONT>

<P><FONT COLOR="#000000">You'll recall that the difference between a <U>revision</U>
and a <U>change number</U> is that the revision is specific to a file...</FONT>
<BR><FONT COLOR="#000000"><TT>&nbsp;&nbsp;&nbsp; x.c#1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</TT><I>(revision #1 of file x.c)</I></FONT>
<BR><FONT COLOR="#000000"><TT>&nbsp;&nbsp;&nbsp; x.c#2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</TT><I>(revision #2 of file x.c)</I></FONT>
<BR><FONT COLOR="#000000"><TT>&nbsp;&nbsp;&nbsp; y.java#1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</TT><I>(revision #1 of file y.java)</I></FONT>
<BR><FONT COLOR="#000000"><TT>&nbsp;&nbsp;&nbsp; y.java#2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</TT><I>(revision #2 of file y.java)</I></FONT>
<BR><FONT COLOR="#000000"><TT>&nbsp;&nbsp;&nbsp; y.java#3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</TT><I>(revision #3 of file y.java)</I></FONT>
<BR><FONT COLOR="#000000">The change number is a list of revisions that
got changed as part of one atomic change to the Perforce depot. For example,
change #12345 might be a change to add comments to x.c and y.java, and
this change might've created revision #2 of<I> x.c</I> and #3 of <I>y.java.</I></FONT><HR>
<LI>
<A NAME="p4revert"></A><B>How do I abandon my
changes and pick up a clean copy from the base?</B></LI>

<BR>&nbsp;
<BR>Use&nbsp; <TT><FONT COLOR="#990000">p4 revert <I>filename</I> </FONT></TT><FONT COLOR="#000000">to
discard the modifications you've made to <I>filename</I> and retrieve a
fresh copy of the <U>exact same revision</U> you had prior to typing</FONT>&nbsp;
<TT><FONT COLOR="#990000">p4 edit <I>filename</I> </FONT><FONT COLOR="#000000">.</FONT></TT>

<P>Use&nbsp; <TT><FONT COLOR="#990000">p4 revert <I>directory/...</I> </FONT></TT><FONT COLOR="#000000">to
discard all the modifications you've made to any file in <I>directory</I>
(or its subdirectories).</FONT><HR>
<LI>
<A NAME="individual_change"></A><B>How do I propagate an
individual change made in one branch to another?</B></LI>


<P>Let's say you have a main codeline, and a child codeline ("branch")
called <I>methusalah</I>.

<P>If you wanted to propogate change number 900 from the main codeline to <I>methusalah</I>,
you'd type:
<BR>&nbsp;
<OL><TT><FONT COLOR="#990000">p4 integrate -b <I>methusalah</I>&nbsp; @900,@900</FONT></TT></OL>


<P>Of course, if you wanted to propogate change number 902 from methusalah to
the main codeline, you'd type:
<BR>&nbsp;
<OL><TT><FONT COLOR="#990000">p4 integrate -b <I>methusalah</I>&nbsp; -r
@902,@902</FONT></TT><BR>
<BR></OL>
<FONT COLOR="#000000">The subsequent&nbsp; resolve/submit combination is
left as an exercise.</FONT>

<P><FONT COLOR="#000000">It's a good idea to include the original change
number in the change description for the integration.</FONT>
<BR>&nbsp;<HR>
<LI>
<A NAME="deletefile_weird"></A>
<b>I created a file that begins with a dash, and
want to 'p4 delete' it and cannot. What can I do?</b>
<p>
Let's say that the name of the file is <i>&quot;-filename&quot;</i>.
<p>
Run &quot;<font COLOR="#990000">p4 delete dummy -filename</font>&quot;
to delete the file - ignore the comment about the dummy filename, its
purpose is to stop the option/argument processing and let everything else
on the command line be interpreted as filenames.
<p>
<i>Or, you could run &quot;<font COLOR="#990000">p4 delete ./-filename</font>&quot;, which uses the Unix directory separator ('/') to construct a
filename that refers to the same file, but doesn't begin with a dash.
(NT uses might use '\'.)</i>
</LI>
<br>&nbsp;
<hr>


<LI>
<A NAME="deleteclient"></A><B>How do I delete a client workspace?</B></LI>

<BR>&nbsp;
<BR><FONT COLOR="#000000">Use&nbsp;</FONT>&nbsp; <TT><FONT COLOR="#990000">p4
client -d&nbsp; <I>workspacename</I>&nbsp;</FONT></TT><FONT COLOR="#990000">&nbsp;
</FONT><FONT COLOR="#000000">to do this. The steps are:</FONT>
<UL><li><FONT COLOR="#000000">Set $P4CLIENT to the name of the workspace, or
make sure that every command you run for this task uses the syntax</FONT>

<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p4 -c
<I>workspacename</I>&nbsp; cmd</FONT></TT>
<BR>&nbsp;
<LI>
<FONT COLOR="#000000">Run&nbsp;</FONT>&nbsp; <FONT COLOR="#990000"><TT>p4
opened&nbsp;</TT>&nbsp; </FONT><FONT COLOR="#000000">to make sure that
no files are opened for any operations in this workspace. If there are,
use the command...</FONT></LI>


<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p4 revert
<I>filelist</I></FONT></TT>

<P><FONT COLOR="#000000">... to revert them.</FONT>
<LI>
<FONT COLOR="#000000">Remove the workspace entry on the Perforce server...</FONT></LI>


<P><TT><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p4 client
-d <I>workspacename</I></FONT></TT>
<BR>&nbsp;
<LI>
<FONT COLOR="#000000">Remove the files and directories on the local disk
that correspond to the client area.</FONT></LI>
</UL>
&nbsp;
<HR>
<LI>
<A NAME="moveclient"></A><B>How do I move a client workspace?</B></LI>


<P>It's easy, but requires a little planning.
<BR>&nbsp;
<OL>
<LI>
Figure out the new client "root". Let's say it's "/home/jojo/newroot".</LI>

<LI>
If you're using the Windows GUI program against this particular Perforce
client, exit the GUI.</LI>

<LI>
Move the entire subtree from its old place to "/home/jojo/newroot".</LI>

<BR>Run&nbsp; <TT><FONT COLOR="#990000">p4 client<I>&nbsp;</I></FONT></TT><FONT COLOR="#000000">
, which will dump you into the editor - you'll be changing the client specification.
Change the "Root:" field to the name "/home/jojo/newroot" and save the
file.</FONT>
<BR>&nbsp;</OL>
<hr>
<LI>
<A NAME="sync_fails"><b>I can't &quot;p4 sync&quot; a particular file. What might be going on?</b></li>
<p>
Let's say that you can retrieve all the files in the
directory (using the depot name syntax) //bas/BIN/src/krn/rsec/
except the file //bas/BIN/src/krn/rsec/rsecstoc.c.
<p>
It could be several things:
<ol>
<li>The other files it gets are in the directory
<tt>//bas/bin/src/krn/rsec/...</tt>
If that's the case, you're up against upper-case/lower-case issues.
(The NT version of the server ignores case; the Unix version of
the server does not.) If this is the case, it'll be easiest to
go to a Unix client and rename the file to be in the same directory
as the files that are succeeding. ("p4 help rename" gives the steps
for renaming a file.)
<li>You might not have permissions on this file from this IP address
for this user. Use "p4 protect -o" and "p4 where" to make sure that
isn't the case.
<li>The client spec might not be mapping that file as you expect.
The command
&quot;<TT><FONT COLOR="#990000">p4 where  //bas/BIN/src/krn/rsec/rsecstoc.c<I>&nbsp;</I></FONT></TT><FONT COLOR="#000000">&quot;
will process
the argument filename through the client spec [processing] code to
tell you where it would be mapped.
<li>The top-most revision of that file might be a "delete" revision,
so that there's nothing to get(!).
(&quot;<TT><FONT COLOR="#990000">p4 files  //bas/BIN/src/krn/rsec/rsecstoc.c<I>&nbsp;</I></FONT></TT><FONT COLOR="#000000">&quot;
will tell you the type of the top-most revision of the file.)
<li>There might be nothing to get, because it thinks you have the
most recent revision. "p4 have //bas/BIN/src/krn/rsec/rsecstoc.c" will
tell you if you already have a revision for that file, or at least
whether the database thinks you do.
(&quot;<TT><FONT COLOR="#990000">p4 sync -f //bas/BIN/src/krn/rsec/rsecstoc.c<I>&nbsp;</I></FONT></TT><FONT COLOR="#000000">&quot;
will force getting a fresh revision.)
</ol>
</OL>

<P><I>Last modified on 11 November 1998.</I>
</BODY>
</HTML>
# Change User Description Committed
#1 5415 michael Move user FAQ to //guest branch and provide pointers.
Remove old branching FAQ.
Update page to reference Perforce Software documentation.