[Top] [Prev] [Next]

Changelists

A Perforce changelist is a list of files, their revision numbers, and operations to be performed on these files. Commands such as p4 add filenames and p4 edit filenames include the affected files in a changelist; the depot is not actually altered until the changelist is submitted with p4 submit.

When a changelist is submitted to the depot, the depot is updated atomically: either all of the files in the changelist are updated in the depot, or none of them are. This grouping of files as a single unit guarantees that code alterations spanning multiple files will update in the depot simultaneously. To reflect the atomic nature of changelist submissions, submission of a changelist is sometimes called an atomic change transaction.

Perforce attempts to make changelist usage as transparent as possible: in the normal case, Perforce commands such as p4 edit add the affected files to a default changelist (called, appropriately enough, the default changelist), and p4 submit sends the default changelist to the server for processing. However, there are two sets of circumstances that would require the user to understand and manipulate non-default changelists:

In the above circumstances, the user must understand how to work with numbered changelists.

Working with the Default Changelist

A changelist is a list of files, revision numbers of those files, and operations to be performed on those files. For example, a single changelist might contain the following:

Each of the files in the changelist are said to be open within the client workspace: the first of the files above was opened for edit with p4 edit, and the second was opened for deletion with p4 delete. The files in the changelist are updated within the depot with p4 submit, which sends the changelist to the server; the server processes the files contained in the changelist and alters the depot accordingly.

The commands that add or remove files from changelists are:

   p4 add

p4 delete

   p4 edit

p4 integrate

   p4 reopen

p4 revert

By default, these commands, and p4 submit, act on the default changelist; for example, if a user types p4 add filename, this file is added to the default changelist. When a user types p4 submit, the default changelist is submitted.

When p4 submit is typed, a change form is displayed that contains the files in the default changelist. Any file can be deleted from this list; when a file is deleted, it is moved to the next default changelist, and will appear again the next time p4 submit is typed. A changelist must contain a user-entered description, which should describe the nature of the changes being made.

p4 submit can take an optional, single file pattern as an argument. In this case, only those files in the default change that match the file pattern will be included in the submitted changelist. Since the p4d server program must receive this file pattern as a single argument, make sure to escape the * wildcard if it is used.

When the user quits from the p4 submit editor, the changelist is submitted to the server and the server attempts to update the files in the depot. If there are no problems, the changelist is assigned a sequential number, and its status changes from new or pending to submitted. Once a changelist has been submitted, it becomes a permanent part of the depot's metadata, and is unchangeable except by Perforce superusers.

Creating Numbered Changelists Manually

A user can create a changelist in advance of submission with p4 change. This command brings up the same form seen during p4 submit. All files in the default changelist are moved to this new changelist; when the user quits from the form, the changelist is assigned the next changelist number in sequence, and this changelist must be subsequently referred to by this change number. Files can be deleted from the changelist by editing the form; files deleted from this changelist are moved to the next default changelist. The status for a changelist created by this method is pending until the form is submitted.

Any client file may be included in only one pending changelist.

Working With Numbered Changelists

Commands such as p4 edit filename, which by default adds the files to the default changelist, can be used to append a file to a pending numbered changelist with the
-c changenum flag. For example, to edit a file and submit it in change number 4, use
p4 edit -c 4 filename.

Files can be moved from one changelist to another with p4 reopen -c changenum filenames, where changenum is the number of the moving-to changelist. If files are being moved to the default changelist, use p4 reopen -c default filenames.

Ed is working on two bug fixes simultaneously. One of the bugs involves mail filtering and requires updates of files in the filter subdirectory; the other problem is in the elm aliasing system, and requires an update of utils/elmalias.c. Ed wants to update each bug separately in the depot; this will allow him to refer to one bug fix by one change number and the other bug fix by another change number. He's already started fixing both bugs, and has opened some of the affected files for edit. He types p4 change, and sees

Change: new
Client: eds_elm
User: edk
Status: new
Description:
<enter description here>
Files:
//depot/elm_proj/filter/filter.c # edit
//depot/elm_proj/filter/lock.c # edit
//depot/elm_proj/utils/elmalias.c # edit

Ed wants to use this changelist to submit only the fix to the filter problems. He changes the form, deleting the last file revision from the file list; when he's done, the form looks like this:

Change: new
Client: eds_elm
User: edk
Status: new
Description:
Fixes filtering problems Files:
//depot/elm_proj/filter/filter.c # edit
//depot/elm_proj/filter/lock.c # edit

When he quits from the editor, he's told

    Change 29 created with 2 open file(s).

The file that he removed from the list, utils/elmalias.c, is now found in the default changelist. He could include that file in another numbered changelist, but decides to leave it where it is.

He fixes both bugs at his leisure. He realizes that the filter problem will require updates to another file: filter/lock.c. He opens this file for edit with p4 edit -c 29 filter/lock.c; opening the file with the -c 29 flag puts the file in changelist 29, which he created above. (If the file had already been open for edit in the default changelist, he could have moved it to changelist 29 with p4 reopen -c 29 filter/lock.c).

Ed finishes fixing the aliasing bug; since the affected files are in the default changelist, he submits the changelist with a straightforward p4 submit. He'll finish fixing the filtering bug later.

Automatic Creation and Renumbering of Changelists

When Submit of the Default Changelist Fails,
the Changelist is Assigned a Number

Submits of changelists will occasionally fail. This can happen for a number of reasons:

If any file in a changelist is rejected for any reason, the entire changelist is backed out, and none of the files in the changelist are updated in the depot. If the submitted changelist was the default changelist, Perforce assigns the changelist the next change number in sequence, and this change number must be used from this point on to refer to the changelist.

If the submit failed because the client-owned revision of the file is not the head revision, a merge must be performed before the changelist will be accepted.

Perforce May Renumber a Changelist upon Submission

The change numbers of submitted changelists always reflect the order in which the changelists were submitted. Thus, when a changelist is submitted, it may be renumbered.

Ed has finished fixing the filtering bug that he's been using changelist 29 for. Since he created that changelist, he's since submitted another changelist (change 30), and two other users have submitted changelists. Ed submits change 29 with p4 submit -c 29, and is told

Deleting Changelists

To remove a pending changelist that has no files or jobs associated with it, use p4 change -d changenum. Pending changelists that contain open files or jobs must have the files and jobs removed from them before they can be deleted: use p4 reopen to move files to another changelist, p4 revert to remove files from the changelist (and revert them back to their old versions), or p4 fix -d to remove jobs from the changelist.

Changelists that have already been submitted can never be deleted.

Changelist Reporting

The two reporting commands associated with changelists are p4 changes and p4 describe. The former is used to view lists of changelists with short descriptions; the latter prints verbose information for a single changelist.

Command

Meaning

p4 changes

Displays a list of all pending and submitted changelists, one line per changelist, and an abbreviated description.


p4 changes -m numchanges

Limits the number of changelists reported on to the last numchanges changelists.


p4 changes -s status

Limit the list to those changelists with a particular status; for example,
p4 changes -s submitted will list only already-submitted changelists.




p4 describe changenum

Displays full information about a single changelist; if the changelist has already been submitted, the report will include a list of affected files and the diffs of these files. The -s flag can be used to exclude the diffs of the files.



[Top] [Prev] [Next]

Command Line User's Guide for PERFORCE
Copyright 1997 Perforce Software. Comments to [email protected].
Last updated: November 20, 1997