Renaming an Element

The Rename command changes the pathname at which an element is accessed. You can use this command to perform a simple renaming of an element within a directory. You cannot move an element to another directory or another depot.

Invoking the Rename Command

Select an element in the Details pane of the File Browser. Then choose Rename from the selection's context menu.

In the Rename dialog box, type a simple name to rename the element within the same directory.

A move transaction records the changing of the element's pathname in your workspace. The renamed object is activated (it is included in the workspace's default group), and the (kept) and (member) flags are added to its status.

Back to top

Renaming a Modified File Before Keeping It

You can create a new version of a file element in your workspace, recording either a content change or a namespace change. But you can't do both at once. For example, suppose you:

  1. Edit the contents of file color.java, so that it gets (modified) status.
  2. Use the Rename command to change the filename to hue.java.

This creates a new version of the file element in your workspace, recording the name change, but not the content change. To preserve the content change, you must use a separate Keep command to create a second new version.

Back to top

Caution on Reusing the Name of a Renamed Element

The ability to reuse the name of a renamed element provides significant flexibility for project refactoring tasks. But it also introduces a complication: what happens if you rename an element, create a new element at the same pathname, then invoke the Revert to Basis command on the renamed element?

The renamed element cannot revert to its old pathname, because there’s a new element at that pathname. The original element simply disappears from your workspace. You might wonder “Why does the element not get (stranded) status?” The Revert to Basis command makes an element inactive in the workspace. The (stranded) status applies only to active elements.

At this point, your workspace contains a new element at the given pathname, and the parent stream contains the original element at that pathname. Attempting to promote the new element would produce a 'name already exists in parent stream' error. Use one of the following procedures to return this pathname to a consistent state:

If you want to return to using the original element

  1. Rename the new element, to a name like myfile.java.DISCARDED.
  2. Defunct the new element.
  3. Promote the new element to the backing stream.
  4. At this point, the original element reappears in the Details pane, with (missing) status.
  5. Invoke the Populate command on the original element.

If you want to discard the original element and use the new element

These steps must be performed with the AccuRev CLI, which supports defuncting of the "disappeared" element using its element-ID.

  1. Defunct the original element in the workspace, using the command accurev defunct –e <element-ID>.
  2. Promote the defuncted version to the backing stream.

Back to top