2. AccuRev® Command-Line Reference : diff

diff
compare two versions of an element
Usage
Compare a file in your workspace tree (local file system) with another version:
accurev diff [ -b | -v <ver-spec> ] [ -cwWIB | -G ] <element-specs>
Compare two specified versions:
accurev diff -v <ver-spec-1> -V <ver-spec-2> [ -cwWIB | -G ] <element-specs>
Compare a version with the previous version:
accurev diff [ -v <ver-spec> ] -1 [ -cwWIB | -G ] <element-specs>
Compare a version with the corresponding basis version:
accurev diff [ -b | -v <ver-spec> ] -j [ -cwWIB | -G ] <element-specs>
Compare all file versions in two streams:
accurev diff -a -i -v <stream-spec-1> -V <stream-spec-2> [ -cwW ]
Compare versions in a stream between two transactions:
accurev diff -a -i -v <stream-spec> -V <stream-spec>
[ -t <transaction-1>-<transaction-2> ]
Compare versions that have an (overlap) status:
accurev diff [ --mine | --theirs ] <element-specs>
accurev diff -v <stream-spec> [ --mine | --theirs ] <element-specs>
accurev diff -a [ --mine | --theirs ]
accurev diff -a -v <stream-spec> [ --mine | --theirs ]
At the end of any diff command, you can add:
-- <diff-utility-flags>
These flags are the options to be passed through to the program that performs the actual file comparison. They can be specified on the command line, or stored in the ACCUREV_DIFF_FLAGS environment variable.
Description
The diff command compares two versions of a file element, or a set of file elements. For certain forms of this command, the meaning of “version” is expanded to include a modified file that you have not yet preserved with the keep command. For such a file, there is no official version object in the AccuRev repository.
In its simplest form ...
accurev diff myfile.c
... diff shows the changes you’ve made recently to a file — changes you’ve made since an update of the workspace or a keep of the file. More precisely, the default is to compare the file in your workspace tree (in the local file system) with the repository version in your workspace stream, as listed by the stat or files command:
Finding the Differences between Two Streams
The command diff -a -i -v -V is a very powerful tool for finding the differences between two streams. It processes just the elements that have different versions in the two streams. It indicates the “before” and “after” version-IDs, along with the content changes and namespace changes between the two versions.
The mergelist command also shows the differences between two streams; but it doesn’t include the changes in the “source” stream that have already been propagated to the “destination” stream. See the mergelist reference page for a fuller explanation.
User Preferences
AC_DIFF_CLI: An environment variable used by diff to invoke an alternative file-comparison program. (The default file-comparison program is acdiff in the AccuRev bin directory.) The command string should include these substitution patterns:
%1% or %1 — filename of the first version to be compared
%2% or %2 — filename of the second version to be compared
%3% or %3 — title to be displayed for the first version
%4% or %4 — title to be displayed for the second version
The values that AccuRev substitutes for the %3% and %4% patterns are not enclosed in double-quotes, even though the values typically include SPACE characters. The values that AccuRev substitutes for the %1% and %2% patterns are enclosed in double-quotes.
Make sure that the file-comparison program you specify is on your search path.
ACCUREV_DIFF_FLAGS: Stores the options to pass through to the file-comparison program used by the diff command. If you use - - to specify these options while issuing the diff command, this environment variable is ignored.
Options
Specifying the Elements — <element-specs>
You can use a combination of exact filenames, pathname patterns (wildcards), and filters to specify the set of file elements whose versions are to be compared. diff automatically ignores any elements that are not text files.
Some examples of filenames and/or wildcards:
brass.c brass.h
Two files in the current directory.
*.c
All files in the current directory whose names end with .c.
*.c /./include/*.h
All files in the current directory whose names end with .c, along with all files in subdirectory include of the depot’s top-level directory whose names end with .h.
intro.doc chap??.doc
File intro.doc along with all files in the current directory with names such as chap02.doc or chap17.doc.
The following options implement filters. Use them to select a subset of the elements in your workspace stream.
-a
Select all elements in the workspace. The output only includes elements for which a difference exists.
-d
Select only elements in the workspace’s default group.
-k
Select only elements that have been kept in your workspace, but not yet promoted. May not be used with -m or -n.
-m
Select only elements that have been modified in your workspace. May not be used with -k.
-n
Select only elements that have been modified in your workspace, and are not in the workspace’s default group. May not be used with -k or -d.
-o
Select only elements with overlapping changes: you have made changes in your workspace, and changes made in another workspace have already been promoted to the backing stream.
-p
Select only elements that are pending promotion in your workspace.
You can use filenames and wildcards in combination with a filter. The filter spec must come first, because it’s syntactically a command-line option. For example:
-k *.doc
... selects all elements in the current directory that have the suffix .doc and have (kept) status.
(For more information on specifying elements, see Techniques for Selecting Elements.)
Specifying the Versions to Compare
Each of the following options specifies a version to be compared. You can use two options to specify both versions. If you use just one option, your workspace supplies the other version. See the valid-combinations listing below for details.
-b
The version in the backing stream. If an element appears only in the workspace stream, not in the workspace’s backing stream, the diff operation continues and displays the following message when complete:
/./dir03/sub04/my.new.file created
If you use the -b -v combination, -b indicates the version in the stream, P, that is the parent of the stream specified with -v. If -v specifies a time-based stream, then diff uses the version that was in stream P at the basis time, not the version currently in stream P.
Note: if a text-file element is active in a time-based stream, accurev diff -b may produce an incorrect result. In this case, we recommend specifying the backing stream by name using this command variant:
> accurev diff -v timebased_stream -V backing_stream foo.c
-v <ver-spec>
A particular version (stream-ID/version-number) or the version currently in a particular stream (stream-ID).
-V <ver-spec2>
Same meaning as -v. Use along with -v to specify the second version to be compared. If you are comparing a stream between two transactions, the versions used with -v and -V must be the same.
-t <transaction-1-transaction-2>
A transaction range, used with the -v and -V options to compare the versions in the stream between the two listed transactions.
-j
The basis version corresponding to the other specified version. See the patch reference page for a description of the basis version.
-1
(“dash-one”, meaning “the previous one”) The version that was the “previous occupant” of the stream to which the other specified version belongs. See Previous Occupant Algorithm in the anc reference page for a precise explanation of “belongs”.
If you use this option along with -v, be sure to specify a complete version-ID — for example, -v rose_dvt/14, not -v rose_dvt.
Common cases: If the first version was created in a workspace with keep, the -1 option selects the version on which it was based (the predecessor version), which may or may not have been created in the same workspace. If the first version was created in a dynamic stream with promote, the -1 option selects the version that was in the first version’s stream just prior to the promotion.
--mine
Compares the workspace or stream version against the common ancestor in the backing stream. This option identifies the changes in the workspace or stream that did not come from the backing stream; it is the equivalent of diffing against the last version that you merged with.
--theirs
Displays only the changes added to the backing stream since the last time you merged with the backing stream. This option is useful for identifying the changes to the backing stream that caused the overlap condition.
 
Following are the valid combinations of the above options:
(no options)
Compare the file in the workspace tree with the version in the workspace stream.
-b
Compare the file in the workspace tree with the version in the workspace’s backing stream.
-v
Compare the file in the workspace tree with the specified version (or the version in the specified stream).
-j
Compare the version in the workspace stream with the corresponding basis version.
-b -j
Compare the version in the workspace’s backing stream with the corresponding basis version.
-v -b
Compare the specified version (X) with the version in X’s stream’s backing stream. (Use
-v -V instead if comparing elements of type text that are active in a time-based stream.)
-v -j
Compare the specified version with the corresponding basis version.
-v -1 (dash-one)
Compare the specified version (X) with the version in X’s stream’s backing stream.
-v -V
Compare the two specified versions.
-v -V -t
Compare versions in the stream between two transactions.
Controlling the Comparison Process
The following options control the way in which the two selected versions of an element are compared as text files.
-B
Ignore blank lines in the file comparison.
-c
Context diff: show three lines above and below the line in which the difference occurs.
-i
Information only: Report the IDs of the two versions, but don’t actually compare them. This option is valid only in a command that uses a -v/-V combination or a -v/-b combination. If an element appears only in the workspace stream, not in the workspace’s backing stream, this option does not list it.
-I
Ignore uppercase/lowercase differences in the file comparison.
-w
Ignore whitespace in the file comparison.
-W
Ignore changes in the amount of whitespace in the file comparison. But report on newly created whitespace and on whitespace that has been completely removed. For example, -w doesn’t see the difference between compareme and compare me, but -W does.
-G
Use AccuRev’s graphical Diff tool to perform the file comparison (any value set in AC_DIFF_CLI is ignored).
- - <diff-utility-flags>
Any items on the command line following the double-dash (--) are passed through to the program that performs the actual file comparison. Typically, each of these flags also starts with a dash (for example, -c -i -w). They can be specified on the command line, or stored in the ACCUREV_DIFF_FLAGS environment variable.
Examples
Show the difference between the current contents of file foo.c and the most recently kept version:
> accurev diff foo.c
Show the difference between the current contents of file foo.c and the version in the backing stream:
> accurev diff -b foo.c
Show the difference between the current contents of file foo.c and the third version in stream gizmo:
> accurev diff -v gizmo/3 foo.c
What has changed between Release 1.0 and Release 2.0 in the gizmo source base?
> accurev diff -a -i -v gizmo1.0 -V gizmo2.0
In a command shell, specify an alternative file-comparison program, located in a directory on your search path:
> export AC_DIFF_CLI="diff %1 %2"     (UNIX Bourne shell)
> set AC_DIFF_CLI=windiff %1 %2       (Windows)
Use the UNIX diff command to show the difference between the current contents of file foo.c and the most recently kept version:
> export AC_DIFF_CLI="diff %1 %2"     (tell AccuRev which diff command to use)
> accurev diff foo.c -- -i -b         (the -i and -b options tell the UNIX diff command to
                                      ignore case differences and space changes)
Return Values
diff returns 0 for no differences, 1 for differences, or 2 for an error.
See Also
merge, mergelist, patch
Using a Specific Version of an Element

Micro Focus