AccuRev® Command-Line Reference : add

add
add a new element to a depot
Usage
accurev add [ -c <comment> ] [ -d] [ -E <value(s)> ] [ -x ] [ -R ] [ -s ]
[ -fi ] { -l <list-file> | <element-list> }
Description
The add command converts one or more existing files, directories, and/or links in a workspace to version-controlled elements. The new elements are placed in the depot associated with your workspace. (They cannot be moved later to another depot.) Version 1 of each element is created in your workspace stream. The new elements will not appear in other streams or workspaces until you promote them.
In the transaction recorded in the database for an add command, the AccuRev operation is listed as “create”, not “add”. Transactions are listed by the hist command.
If a pre-create-trig trigger is defined for the depot, it fires before the add command is executed. See the mktrig reference page and AccuRev Triggers on page 71 of the AccuRev Administrator’s Guide.
Controlling the Element Type and Exclusive File Locking State
By default, add guesses an element type for each file element it creates:
Note: as a result of this algorithm, Unicode files are usually considered to be binary, not text.
You can override add's element type determination with the -E option, specifying text, binary, or a third element type, ptext (a variant of text, never assigned automatically). See below for a description of how AccuRev handles ptext elements. You can also set the new element’s exclusive file locking state: serial (exclusive file locking enabled) or parallel (exclusive file locking disabled).
By default, all files in a workspace are writable. You can edit any file at any time, and use keep to create new versions of them. But if you use the -E serial option, the file becomes read-only after you promote it to the backing stream. See File Locking in Workspaces on page 5.
You can change both the element type and exclusive file locking state in subsequent keep -E commands. This change affects the newly created version and future versions only; it does not change the type of any existing version.
To see an element’s type, use the hist -fv or stat -fk command. To see an element’s exclusive file locking state, use the stat -fx command (see the hierType attribute in the XML-format listing).
Using Triggers to Control the Element Type and Exclusive File Locking State
Setting of the element type or the exclusive file locking state (or both) can be automated with triggers. Settings made by triggers scripts override the add -E specifications, if any.
To set the element type based on file extensions and/or file content, set a pre-operation trigger with mktrig pre-create-trig. AccuRev ships with a sample trigger script, elem_type.pl. You can customize it to recognize new file suffixes.
These triggers are fully described in AccuRev Triggers on page 71 of the AccuRev Administrator’s Guide.
How AccuRev Handles File Elements of Different Types
AccuRev handles binary files very simply: when a new binary version is created (with add or keep), AccuRev simply copies the file from your workspace tree to the repository, creating a storage file. When you retrieve a binary file from the repository (for example, with co -v or update), AccuRev simply copies the storage file to your workspace tree.
Handling of text files is more sophisticated. By default:
When a new version is created (add or keep), a new storage file is placed in the repository, with a single NL (or LF) character (hex character code x0A) at the end of each text line. This means that a version’s storage file may have different line terminators than the file you submitted to the add or keep command.
When a text file is copied into the workspace by an AccuRev command (e.g. update, pop), it gets the line terminators appropriate to the machine where the workspace is located: NL (x0A) for a UNIX/Linux machine, or CR-NL (x0D x0A) for a Windows machine.
On the individual element level, you can override the manipulation of line terminators by specifying the “preserve text line terminators” element type, with the -E ptext option. Files of this type are copied to and from the repository with no change, just like binary files.
On the workspace level, you can force the use of a particular line terminator when text files are copied to the workspace, using the -e option to mkws or chws. This applies to all elements of type text, but not to elements of type ptext.
How AccuRev Converts Existing Links to Link Elements
The add command converts existing link objects with (external) status to AccuRev elements as follows:
An existing symbolic link (UNIX/Linux) or junction point (Windows) is converted to an AccuRev element-link element (elink) in these circumstances:
The target is a file element, directory element, or elink in your workspace, and you omit the -s command-line option. (If the target is an slink, you must use -s to convert the object to an slink. You cannot create an elink that points to an slink.)
An existing symbolic link (UNIX/Linux) or junction point (Windows) is converted to an AccuRev symbolic-link element (slink) in these circumstances:
The target is an element in your workspace, and you specify the -s command-line option. (If the target is an slink, you must specify this option.)
The target is an (external) object in your workspace, and you specify the -s command-line option.
Controlling the UNIX/Linux Access Mode
On a UNIX/Linux machine, if a file has any of its executable bits (user, group, other) set, then add automatically sets all three bits on the kept version. Otherwise, all three bits are cleared on the kept version.
You can set or clear the executable bits on subsequent versions, using the accurev chmod command.
Adding Directories to the Depot
add can create directory elements as well as file elements. For each file it processes, add automatically creates elements (if necessary) for the file’s directory, its parent directory, and so on up to the top level of the depot. If you want to turn an empty directory into an element, you can specify it as a command-line argument, or you can let add -x find it automatically.
User Preferences
The following preferences are implemented through environment variables. Setting of environment variables differs among operating systems and shell programs.
ACCUREV_IGNORE_ELEMS: Takes a SPACE-separated list of filename patterns. Causes add -x to ignore external files that match any of the patterns.
Example: in the UNIX Bourne shell, have accurev add -x ignore temporary files and text-editor backup files:
export ACCUREV_IGNORE_ELEMS="*.tmp *.bak"
In general, enclose the pattern list in quotes on UNIX/Linux systems, but not on Windows systems. See also Pathname Optimization: ACCUREV_IGNORE_ELEMS and .acignore on page 21 of AccuRev Technical Notes.
Options
–c <comment>
Specify a comment for the transaction. The next command-line argument should be a quoted string. Alternatively, the next argument can be in the form @<comment-file>, which uses the contents of text-file <comment-file> as the comment.
-d

Deny access to other users. If your site makes use of element-level security (“EACLs”), this option allows you to add elements to the depot and immediately make them inaccessible to other users, while assigning FULL access to the user adding the element. After adding the element, the adding user can then set the EACLs appropriately.
-E <value(s)>
Specify the element type: text (default) or ptext or binary; and/or specify the exclusive file locking state for this element: serial or parallel. To specify two (non-conflicting) values at once, separate them with a comma, but not a SPACE:
-E serial,binary
See Controlling the Element Type and Exclusive File Locking State above.
-l <list-file>
Create elements from the files listed in <list-file>. This must be a text file, with one name per line. A name can be a simple filename; or it can be a relative, depot-relative, or absolute pathname. An absolute pathname must indicate a location within your current workspace.
Empty lines are ignored, but leading or trailing whitespace around the filenames is not ignored. There is no provision for comment lines in a <list-file>.
If you use this option, any <element-list> specified is silently ignored.
<element-list>
One or more file or directory names, separated by whitespace. If you also specify a <list-file> using the -l option, this <element-list> is silently ignored.
-R
Recurse into each directory specified in <element-list>, and add all the external files in that directory subtree. You need not specify the -x option. (Use “.” to specify the current working directory.)
-x
Select all external files and directories in the workspace, except objects that match any of the patterns specified by ACCUREV_IGNORE_ELEMS. (See the -x description and User Preferences on page 42.)
-fi
Include objects even if they would be excluded by the value of ACCUREV_IGNORE_ELEMS. (See the -x description and User Preferences on page 42.)
-s
Forces all symbolic link objects (at the OS level) whose targets are within the current workspace to be converted to symbolic-link elements (at the AccuRev level). See How AccuRev Converts Existing Links to Link Elements on page 41.
Examples
Create element foo.c:
> accurev add foo.c
Create binary element fig1.jpg:
> accurev add -E binary fig1.jpg
Create elements from all files in the workspace that are not already under version control:
> accurev add -x
Create directory elements from three new directories:
> mkdir sun linux windows
> accurev add sun linux windows
Create elements from all files in subdirectory widgets that are not already under version control:
> accurev add -x -R widgets
See Also
chmod, eacl, hist, keep, ln, mktrig, promote
Techniques for Selecting Elements on page 13

AccuRev, Inc.
Phone: 781-861-8700
Fax: 781-861-8704
support@accurev.com