Labels are an interesting part of version control system. In version 1 of TFS Version Control, labels do not contain deleted items.
Here's an example sequence of commands that shows this behavior:
mkdir direcho dir\a.cs > dir\a.csecho dir\b.cs > dir\b.cstf add dir /rtf checkin /itf delete dir\a.cstf checkin /itf label label1 $/;T /rtf lables label1 /format:detailed
The labels command returns this data:
Label : label1Scope : $/Owner : billDate : Thursday, March 22, 2007 4:04:34 PMComment:
Changeset Item--------- ------------------1 $/2 $/13 $/1/dir3 $/1/dir/b.cs
As you can see $/1/dir/a.cs;X1 is not returned from the label. There is an ambiguity when you compare the items in a label against another version specification (changeset, label, etc...) When you do the comparison it is not possible to determine if an item is missing from the label because it was deleted, or because the item was deliberately excluded.
Merging with a label will not merge file/folder deletes into the target tree.
Here is an example that shows you what I mean:
mkdir srcecho src\a.cs > src\a.csecho src\b.cs > src\b.cstf add src /rtf checkin /itf branch src tgttf checkin /itf delete src\a.cstf checkin /itf label label2 $/;T /rtf merge src tgt /r /version:Llabel2
The merge command will report correctly that there is nothing to merge because src\a.cs does not exist in label2.
Team Build runs into the same issue when it computes the changesets that are new with the current build. In order to do this Team Build compares the label for the last successful build and the label for the current buld. A heuristic is used to determine what it treats as deletes when comparing two labels. If an item is in the first label and not in the second label then the version control server is asked if the item's path exists at the latest changeset in a non-deleted state. (VersionControlServer.ServerItemExists) If the item doesn't exist then it is reported as deleted. If the item does exist then it isn't reported as a difference at all. If you currently merge using labels you could implement the same heuristic in order to ensure that deletes get merged. You would probably want to review the suggested deletes manually before checking in the merge.
Bill