[Top] [Prev] [Next]

Job Tracking


A job is a written description of some modification to be made to a source code set. A job might be a bug description, like "the system crashes when I press return", or it might be a system improvement request, like "please make the program run faster."

Whereas a job represents work that is intended, a changelist represents work actually done. Perforce's job tracking mechanism allows jobs to be linked to the changelists that implement the work requested by the job. A job can later be looked up to determine if and when it was fixed, which file revisions implemented the fix, and who fixed it. A jobs linked to a particular changelist is marked as completed when the changelist is submitted.

Jobs perform no functions internally to Perforce; rather, they are provided as a method of keeping track of what changes to the source are needed, which user is responsible for implementing the job, and which file versions contain the implementation of the job. Since jobs do nothing more than provide this information to the user, the job reporting facilities are particularly important.

The job facilities in Perforce do not provide a full-scale job tracking system. They can be used as is, or integrated with another system via a daemon.

Creating and Editing Jobs

Jobs are created with the p4 job command.

Sarah, who shares the same Perforce server as Ed, has found a bug in Elm's filtering code. Ed is fixing code, so Sarah creates a new job with p4 job and fills in the resulting form as follows:
Job:    job000125

User: edk

Status: open

Description:
Filters on the "Reply-To:" field
don't work.

The p4 job fields are:

Field Name

Description

Default

Job The name of the job. Whitespace is not allowed in the name. new
User The user whom the job is assigned to, usually the username of the person assigned to fix this particular problem. Perforce username of the person
creating the job.
Status open, closed, or suspended. An open job is one that has been created but has not yet been fixed. A closed job is one that has been completed. A suspended job is an open job that is not currently being worked on. open
Description Arbitrary text assigned by the user. Usually a written description of the problem that is meant to be fixed. text that must be changed

If p4 job is called with no parameters, a new job is created. The name that appears on the form is new, but this can be changed by the user to any desired string. If the Name field is left as new, or is blank, Perforce will assign the job the name jobN, where N is a sequentially-assigned six-digit number.

Existing jobs can be edited with p4 job jobname. The owner and description can be changed arbitrarily; the status can be changed to any of the three valid status values open, closed, or suspended. If p4 job jobname is called with a non-existing jobname, a new job is created.

Linking Jobs to Changelists,
and Changing a Job's Status

Automatically Performed Functions

All open jobs owned by a particular user will appear in all Perforce changelists subsequently created by that user. A job is automatically closed when one of its associated changelists is successfully submitted. Jobs can be disassociated from changelists by deleting the job from the changelist's change form.

Ed is unaware of the job that Sarah has assigned to him. He is currently working on an unrelated problem; he types p4 submit and sees the following:
Change: new
Client: edk
User: edk
Status: new
Description:
Updating "File" files
Jobs:
job000125 # Filters on the "Reply-To" field d

Files:
//depot/src/file.c # edit
//depot/src/file_util.c # edit
//depot/src/fileio.c # edit

Since this job is unrelated to the work he's been doing, and since it hasn't been fixed, he deletes it from the form and then quits from the editor. The changelist is submitted; the job is not associated with it.

Ed uses the reporting commands to read the details about the job. He fixes this problem, and a number of other filtering bugs; when he next types p4 submit, he sees
Change: new
Client: edk
User:   rlo
Status: new
Description:
        Fixes a number of filter problems
Jobs:
        job000125                  # Filters on the "Reply-To" field d

Files:  //depot/filter/actions.c   # edit
        //depot/filter/audit.c     # edit
        //depot/filter/filter.c    # edit

Since the job is fixed in this changelist, Ed leaves the job on the form. When he quits from the editor, the job is marked as closed, and will not appear in any subsequent changelists unless it is reopened.

Manually Associating Jobs with Changelists

p4 fix -c changenum jobname can be used to link any job, whether open, closed, or submitted, to any Perforce changelist, whether pending or submitted. If the job is open but the changelist has already been submitted, the job is closed. If the job has been closed but the changelist is pending, the job is reopened. Otherwise, the job keeps its current status.

Sarah has submitted a job called options-bug to Ed. Unbeknownst to Sarah, the bug reported by the job was fixed in Ed's previously submitted changelist 18. Ed links the job to the previously submitted changelist with p4 fix -c 18 options-bug. Since the changelist has already been submitted, the job's status is changed to closed.

It is never necessary to use p4 fix to link an open job to a changelist newly created by the owner of the job, since this is done automatically. However, p4 fix can be used to link a changelist to a job owned by another user.

Arbitrarily Changing a Job's Status

We've already seen two ways of changing a job's status:

  1. A job is automatically closed when an associated changelist is submitted.
  2. p4 fix will change the status of an open job to closed if the associated changelist has already been submitted, and will change the status of a closed job to open when the job is linked to a pending changelist.
The status of any job can also be changed by bringing up the job definition form with p4 job jobname, and then changing the status to one of the three allowed values. This is the only way of changing a job's status to suspended.

Suspending Jobs to Prevent Job Proliferation

An open job will appear on every new Perforce change form until the job is closed. If your site is making extensive use of the Perforce job functionality, this can make working with change forms unwieldy: a single changelist might list many unassociated jobs, all of which need to be deleted from the changelist before the changelist is submitted.

A simple remedy is to change the status of any job to suspended. This can be done when the job is created, or after job creation with p4 job jobname. A suspended job will not appear in any change form until the job is reopened, but it will still appear in the job reports generated by p4 jobs.

Deleting Jobs

A job that has been linked to a changelist can be unlinked from that changelist with p4 fix -d -c changenum jobname. Jobs can be deleted entirely with p4 job -d jobname.

Integrating to External Defect Tracking Systems

The Perforce job reporting functionality can be used to integrate jobs into external programs, such as defect tracking systems, via daemons. Please see the next chapter for more information on daemons.

Job Reporting

The commands that generate reports on jobs are:

Command

Description

p4 jobs Generates a report of all jobs on the server. Prints the job name, date modified, owner, status, and the first 32 characters of the description for each job. p4 jobs -l outputs the full description of each job. p4 jobs -s statusvalue can be used to limit the report to only those jobs with a particular status. If any filepatterns are provided on the command line with
p4 jobs filepatterns, the report will be limited to jobs linked to those changelists that affected files that match the filepatterns.
p4 fixes
[ -j jobName ]
[ -c change# ]
[ file ... ]
Lists each job along with the change numbers they've been linked to. p4 -j jobname provides information only for changelists linked to that particular job. p4 -c changenum lists only those jobs associated with the given change number. Any file arguments provided limits the listing to changelists that affect those files.



[Top] [Prev] [Next]

[email protected]
Copyright © 1997, Perforce Software. All rights reserved.