annotate

Annotates lines of text file / time stamps, user names, and so on

Applicability

Product

Command type

VersionVault

cleartool subcommand

Platform

UNIX

Linux

Windows

Synopsis

ann/otate [ –a/ll | –rm ] [ –nco ] [ –out pname ]
[ –s/hort | –l/ong | –fmt format[,hdr-format[,elide-format ] ] ]

[ –rmf/mt rm-format ] [ –nhe/ader ]

[ –nda/ta | –f/orce ] pname ...

Description

The annotate command lists the contents of a version, annotating each line to indicate when, and in which version, the line was added. You can customize the annotations using the –fmt option, which is described in the fmt_ccase reference page. By default, annotate writes its output to a file whose file-name extension is .ann.

Line of descent

Each version has a line of descent, a sequence of ancestor versions going all the way back to version 0 on the main branch. The default listing has a header section that includes the event records of all the versions in the line of descent of the annotated version.

Type manager interface

The annotate command extracts information from the element's versions. To do so, it invokes the annotate method of the element's type manager. Only the text_file_delta and z_text_file_delta type managers (which correspond to the predefined element types text_file and compressed_text_file) include an annotate method. You must use the –ndata option when annotating versions of other element types.

Report format

The default report format includes the following components:

  • Time since the reported operation:
    • A string of five # characters indicates less than one week
    • A string of four # characters indicates less than one month
    • A string of three # characters indicates less than one-quarter year
    • A string of two # characters indicates less than one-half year
    • One # character indicates less than one year
    • Zero # characters indicates greater than one year
  • Element path name: Shows the path of the element being annotated.
  • Heading section: Lists the event record for each version along the line of descent, in standard cleartool lshistory format.
  • Text line annotations: Includes a bar graph indicating how long ago the line first appeared in an ancestor version, along with that version's time stamp, creator, and version ID.
  • Elision strings: Replace text line annotations that would duplicate the annotation on the preceding line. An elision string includes the bar graph and a single dot (.) character.
  • Source lines from the specified version: Any TAB characters in source lines are expanded according to the value of environment variable CLEARCASE_TAB_SIZE (default: 8).

If you use the –rm or –all option, the report also includes deletion annotations. These appear on text lines that are not in the annotated version, but do exist in some other version of the element.

Options and arguments

Including other text lines

Default
The listing includes only text lines that are present in the specified version.
–a/ll
Expands the listing to include all text lines that occurred in any version of the element, including lines in versions that are not along the line of descent. (Lines from versions outside the line of descent are annotated as UNRELATED; this annotation appears in the same column used to annotate deletion lines.)
–rm
Also includes removed lines—text lines that were present in one or more versions along the line of descent, but do not appear in the specified version. See also the –rmfmt option.

Handling of checked-out versions

Default
An error occurs if you specify a checked-out version. (The type manager can annotate checked-in versions only.)
–nco
If you specify a checked-out version, the version from which it was checked out is used.

Destination of listing

Default
  Command output is sent to the file input-file.ann.
–out output-pname
If output-pname is a file name, redirects command output to the specified file (overwriting the file if it already exists). If output-pname is a single hyphen character (–out –), sends command output to stdout. If output-pname is a directory, places command output for each annotated version in a file within that directory (which must already exist).

If you use this option when annotating more than one version, output-pname must be a directory.

Formatting of report

Default
The source file is listed as described in the section Report format.
–s/hort
Uses predefined annotation format strings that yield an abbreviated report.
–l/ong
Uses predefined annotation format strings that yield a verbose report.
–fmt format[,hdr-format[,elide-format]]
Specifies a display format for primary annotations, and optionally, for the header section and/or elision strings. Format strings must be enclosed in quotation marks. The default format is "%BAd %Sd %-8.8u %-16.16Vn | " .

Use a hyphen (-) to designate a default format string. For example, to supply a hdr-format, but not a primary annotation format, use the construction –fmt –, hdr-format. It is usually desirable to terminate the hdr-format with a <NL> character, by using \n.

If you omit the elide-format, it is computed based on the primary line-by-line annotation: all characters except <TAB> and the vertical bar (|) in the primary annotation are replaced by <SPACE>, and the middle character, if it is a <SPACE>, is replaced by a period (.).

In general, it is simpler to use fixed-width fields, not <TAB>-character specifiers (\t), to create aligned columns of annotations. See the fmt_ccase reference page for more details about composing format strings.

–rmf/mt rm-format
Specifies a format for deletion annotations (see also –rm and –all). The default format is "DEL %Sd %-8.8u | " .
–f/orce
Displays each text line's annotation, even if it duplicated the previous line's annotation. This option suppresses use of elision strings.

Partial reports

Default
  The report includes both a header section and the annotated text lines.
–nhe/ader
Suppresses the header section; the report consists of the annotated text lines only.
–nda/ta
Suppresses the annotated text lines; the report consists of the header section only.

Examples

The UNIX system and Linux examples in this section are written for use in csh. If you use another shell, you might need to use different quoting and escaping conventions.

The Windows examples that include wildcards or quoting are written for use in cleartool interactive mode. If you use cleartool single-command mode, you might need to change the wildcards and quoting to make your command interpreter process the command appropriately.

In cleartool single-command mode, cmd-context represents the UNIX system and Linux shells or Windows command interpreter prompt, followed by the cleartool command. In cleartool interactive mode, cmd-context represents the interactive cleartool prompt.

  • Annotate a source file, using the short format.

    cmd-context annotate -short msg.c
    Annotated result written to "msg.c.ann".
    cat msg.c.ann
    /vobs_src/msg.c
    ---------------
    2007-04-24 anne /main/rel2_bugfix/9
    2007-03-12 ravi /main/rel2_bugfix/8
    .
    .
    .
    2007-04-23 rks /main/48 (REL2)
    2007-04-20 spc /main/47
    .
    .
    .
    -------------------------------------------------
    -------------------------------------------------
    2006-05-20    | #include "hello.h"
     .           |
     .           | char *
    2007-04-21    | env_user() {
    .           | char * user_env;
    .           | user_env = getenv("USER");
    .
    .
    .
     .           | time_t clock;
    2007-03-24    | char *s;
    2006-09-20    |
    2007-06-14    | s = ctime(&clock);
    .           | s[ strlen(s)-1 ] = ' ';
     .           | return s;
    2006-05-20    | }

  • Annotate a source file, using the long format.

    cmd-context annotate -long msg.c
    Annotated result written to "msg.c.ann".
    type  msg.c.ann
    2007-04-02T10:51:54 ##### Steve (scd.user@reach)\main\rel2_bugfix\1
    a test
    .
    .
    .
    -------------------------------------------------
    -------------------------------------------------
    ##### 2007-04-01T16:19:25 scd \main\1              | #include "hello.h"
    ##### 2007-04-02T10:51:54 scd \main\rel2_bugfix\1  | /* a test */
    ##### 2007-04-01T16:19:25 scd \main\1              |
    .
    .
    .
    ##### .                                           |char *
    ##### .                                           | hello_msg() {
    .
    .
    .

  • Annotate a source file and write the output to standard output. Display deletion lines, customize the annotation format, and suppress the header output.

    cmd-context annotate -out - -fmt "%Sd %-8.8u | " -rm -nheader util.c
    2006-05-20 anne |                      | #include "hello.h"
    .              |                      |
    .              |                      | char *
    .              |                      | env_user() {
    .              | DEL 2007-02-08 gcd    | return getenv("USER");
    2007-02-08 gcd  |                      | char *str = getenv("USER");
    .              |                      | if ( strcmp(str,"root") == 0 )
    .
    .
    .

  • Customize the header format, but use the default format for text line annotations.

    cmd-context annotate -out - -fmt "-,Version %Vn created by %u.\n" util.c
    version \main\3 created by anne.
    version \main\2 created by anne.
    version \main\1 created by rick.
    version \main\0 created by rick.
    -------------------------------------------------
    -------------------------------------------------
    # 2006-05-20 rick         \main\1       | #include "hello.h"
    #                        .             |
    #                        .             | char *
    #                        .             | env_user() {
    ### 2007-02-08 anne       \main\3       | char *str = getenv("USER");
    ###                      .             | if ( strcmp(str,"root") == 0 )
    .
    .
    .