3. The File Browser : The Patch From Command

The Patch From Command
The Patch From (or Patch) command performs a patch operation on a text-file element, incorporating some of the changes in a specified "patch from" version into the version in your workspace. The combined contents are saved, with Keep, as a new version in your workspace.
 The patch operation is operationally similar to a merge operation, which incorporates all of the changes in a specified version. (In fact, both operations use the same tool, either AccuRev's Merge tool or a third-party text-file-merge tool.)
Patch vs. Merge
When you merge version V of a file into your workspace version, you are saying:
"combine my file with version V, taking into account all the changes in version V, back to the common ancestor"
When you patch version V of a file into your workspace version, you are saying:
"combine my file with version V, taking into account only the recent changes to version V"
To find the "recent changes to Version V", AccuRev scans backward through the file’s ancestry, starting at version V and stopping when it encounters ...
· a version that was originally created in another workspace
... or ...
· a version that was promoted to another stream
This backward search defines a patch to the element. Version V is termed the head version of the patch. The older version is termed the basis version of the patch. The patch consists of all the versions of the element between the basis version and head version. The basis version itself is not included in the patch -- it precedes the set of "recent changes" in version V. The head version is included in the patch -- it contains the latest of the recent changes.
In identifying versions "between" the head and basis versions, AccuRev follows both direct ancestor and merge ancestry lines. In particular, if version V was created by a merge, its "recent changes" include both contributors to the merge.
Historical note
Prior to AccuRev 3.5.5, the Patch From command used a simpler definition of "recent changes to Version V" -- it meant "just the changes between version V and its immediate predecessor". (In effect, the Show Patch List command still uses this definition of patch, showing all the individual versions whose changes need to be propagated between two streams.)
For example, suppose user Mary recently created versions 4, 5, 6, and 7 of a file in her workspace, talon_dvt_mary. When patching version talon_dvt_mary/7 into your workspace version, AccuRev previously only incorporated the changes between versions talon_dvt_mary/6 and talon_dvt_mary/7. The limitation of this simple algorithm is clear: you probably wanted to incorporate all of Mary’s recent changes — the modifications in versions 4, 5, 6, and 7. In previous releases, you would have had to perform four separate Patch From commands to achieve this result.
Example 1
Before Mary started her recent work, she updated her workspace. This brought in a version of the file originally created by another user -- say, version brown_dvt_john/5. Then she proceeded to create versions 5 through 7 in workspace brown_dvt_mary.
Derek decides to patch version brown_dvt_mary/7 into his workspace. He invokes the Patch From command from the context menu of this version. AccuRev searches backward through the element's ancestry, and includes the set of changes recently made in Mary's workspace: this set includes brown_dvt_mary/5 through brown_dvt_mary/7; the patch doesn't include the two versions created in workspace brown_dvt_john.
Example 2
Mary started a task by bringing version brown_dvt_john/6 into her workspace with an update. Then she created versions brown_dvt_mary/4 through brown_dvt_mary/6, promoted her work to the backing stream, and then created two more versions: brown_dvt_mary/7 and brown_dvt_mary/8.
When John patches version brown_dvt_mary/8 into his workspace, AccuRev decides that only the versions since the promotion — versions 7 and 8 — contain "recent changes". The idea is that a promotion typically marks the end of a programming task, not an intermediate checkpoint.
Example 3
John patches version trike_dvt_mary/3 into his workspace, creating version trike_mnt_john/1. Because Mary's version was created by a merge, the patch includes the recent changes to both merge contributors.
Invoking the Patch From Command
You can invoke Patch From on a selected version in the following contexts:
· In the Version Browser (when invoked from a workspace), to patch from an arbitrary version.
· In the History Browser (when invoked from a workspace), to patch from the version in a particular transaction.
AccuRev processes the files you specify one-by-one. For each file, it does one or both of the following:
· Prompts you, in one or more dialogs, to resolve namespace-level conflicts.
· Invokes AccuRev's Merge tool or the other tool you've configured, in order to perform the patch operation. AccuRev's Merge tool opens in a separate tab within the AccuRev GUI window; any other tool opens in its own window.
The Patch Algorithm
The Patch From command performs its content-level work with the Merge tool. Submitting a different set of versions to this tool effectively implements the patch algorithm (see The Merge, Patch, and Reverse Patch Algorithms on page 242).

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