June 16, 2011

Which type of label to use?


One of the most common questions I get in a training class is, "What's the difference between automatic and static labels? Which one should I use?" I've come up with a decision tree that helps to answer that question.

First, though, its worth mentioning that the real question is, "How do I identify some set of files that I need to reference again in the future?" Identifying old builds or important milestones is a common scenario that brings up this question.

As a quick review, here are the three usual ways of identifying a set of files.

  • Changelists are unique identification points in the history of the entire repository. At any time, I can ask Perforce for the state of any file or branch as of a particular changelist. Using changelists implies that I know where my files are at. Changelists are simple and efficient.
  • Automatic labels include a view and a revision. Using an automatic label, I can define where files are (the view) and what revision I need. Automatic labels are simple, but are less efficient than changelists.
  • Static labels include a view that defines which files the label could include. Files must be tagged with a static label, and I can tag files using different revisions if I want to. Static labels offer the most flexibility, but require the most setup work. Static labels can put quite a bit of data into Perforce's database, and so should be used carefully in scripting or automation. Old static labels should be archived.

And now here's the decision tree for identifying sets of files:


As with all advice, your mileage may vary depending on usage and requirements. But I find this decision tree to be a good start.

Of course, if you have any questions about label usage or performance, just contact us!