tags:

views:

201

answers:

4

We are allowing external consultants to work on a portion of our source. We created a new TFS project and granted them rights to that. Branching does work between TFS projects, so we can branch the "real" TFS project they're working on to the consultant project. However, we only want to expose portions of it. Here's what we want (simplified):

OurProject
  Mainline
    Applications
      Secret1
      NewApp
    Libraries
      Secret2
      Shared

ConsultantProject
  Mainline-Branch
    Applications
      NewApp
    Libraries
      Shared

If we simply branch Mainline and delete the Secret folders on the branch, merging back must be done carefully to avoid deleting the Mainline Secret folders. We want to simplify future merges (both ways) while minimizing risk.

How can this be accomplished?

+1  A: 

Instead of branching and then deleting files/folders from the branch, branch only the files that you want them to have access to.

eg:

  • Branch Mainline -> $/ConsultantProject/Mainline-Branch.
  • Right click on $/ConsultantProject/Mainline-Branch/Applications/Secret1 and undo your checkout.
  • Similarly undo checkout on $/ConsultantProject/Mainline-Branch/Libraries/Secret2.
  • Check in your branch ($/ConsultantProject/).

With this completed, merges from one to the other will not affect the files/folders that you didn't branch.

Chris Shaffer
Richard Berg
Sorry, it's been a while since I merged the project that we have handled in this way. You are correct, merging trunk to branch will try to branch Secret1 However, it is not difficult to repeat the "Undo Checkout" step on those folders whenever you merge this direction. This method does simplify merging branch to trunk however, so is still a valid solution to his issue.
Chris Shaffer
+1 for effort - thanks!
TrueWill
A: 

TFS really likes for all dependencies of a project to be inside one folder. I would restructure your folder layout quite a bit. Here's how I would do it.

TeamProject
    SecretApplication
        SharedLibrary1
    Application1
        SharedLibrary1
    SharedLibrary1
    ConsultantApplication1
        SharedLibrary1

Here's the detail...

Notice how all the apps are peers? SharedLibraries are shared/branched into the apps that use them. That way apps can move forward at their own pace and pull down shared changes at their own pace, and merge their changes to shared code back at their own pace. TeamProject->SharedLibrary1 is the "mainline" for SharedLibrary1. Everywhere else you see SharedLibrary1, it's a branch. Each application folder is its own "mainline", making your structure more app-centric than "all our work" centric.

With this setup, you merely make a branch of Application1 and call it ConsultantApplication1. That way you can setup your security to allow your consultants to only see that one app and all its dependencies. They can merge and pull at will. Well, they won't be able to merge without seeing the source project, but you can. All other apps in your team project will be invisible to them.

Let me know if I've misunderstood something or there are some requirements preventing you from using a structure like this. If there's a secret shared library under Application1, we'll have to think on this some more, but I think that would have compilation issues anyway. Regardless, placing all dependencies for an app under a single folder helps a ton and is a great practice.

Tim Hardy
It would be nice, but it's simply not feasible in our situation. We have a project/folder structure that works well for our developers; this is a new requirement that we didn't foresee.
TrueWill
Incidentally, doing it like this means that SecretApplication and Application1 cannot share a library project unless it's copied (shudder) or pre-compiled. VS has no problem compiling projects from another folder.
TrueWill
VS can compile projects from another folder, but you won't get any of the source control benefits with that setup. If SecretApplication and Application1 both have branches of SharedLibrary1, then they can diverge in their development. They're shielded from the changes some other app might have had to make in the library and can get latest or merge when they are ready. This is the major benefit of not simply linking to the library in its home/source folder. I hear you on pre-existing conditions though. It can be hard to restructure your source folders on a large legacy app.
Tim Hardy
@Tim - since we've got everything under a folder (Mainline in the above example) we just branch all of that to work on a feature in an application. It's branching stuff we don't care about, but since it's all deltas on the server, it's no big deal. We do use pre-built assemblies from a separate TFS project for our base shared code.
TrueWill
+2  A: 

I know this may not be answering your question, but rather the intent of your question. Why not just set permissions to hide those secret items from the consultants and branch as you would any other time?

Alex
+1, keep it simple
Richard Berg
+1  A: 

I agree with Alex. TFS doesn't have any built-in mechanisms to handle sparse branches. The closest analogue in TFS is branching/merging by label, but that strategy brings a ton of management overhead which is very error prone.

So, just let the branch/merge system do its thing and use ACLs to ensure your consultants can't see the Secret Sauce.

Note that for complete security, you'll need to create a 2nd solution for them that does not include any of the Secret projects, then ACL the main (all inclusive) solution out of sight. Do any non-Secret projects depend on the Secret projects? If so you'll have to do something similar (though slightly more involved).

Richard Berg
+1 - thanks for the details!
TrueWill