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?
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?
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).
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.
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.
Related
Another developer has some test files in a new directory in their branch. They're useful to me as well but I'm working in a totally independent, newer branch and he's not likely to merge his branch anytime soon.
I am able to branch his "test-data" directory into my branch but I really want to break the branch association so they're treated as new files in my branch, i.e. so TFS thinks our branches independently added the same new files and we resolve conflicts later since our test data is likely to diverge.
Is there a way to "orphan" the branched files somehow?
You can just get files in TFS using the web access component. Just browse to the folder through the code portion of web access and right click > get as zip.
You can do it from the command line as well but I am not familiar with that. SO has a lot of resources on how to do that from what I have seen.
It is possible to break the branching relationship in TFS and there are many questions on SO on how to do that. But your branch wouldn't initially treat them as 'added' and the history will be in TFS. I would recommend branching just the folder his useful code into your branch and leaving that relationship for posterities sake.
That being said, depending on your situation it may not make sense. If you want to remove the branching relationship immediately, then I don't think you need to use TFS.
In TFS, if you want to create a personal branch to try out an idea you
have, you will have to create a branch on the TFS server – even if no
one else needs access to your code. And when you create this branch,
every single file in your project will be duplicated – even if your
branch has very few changes compared to the original one. Now you’re
using twice the amount of disk space both on the server and locally!
Is this true, and one of the downsides of a non-distributed VCS?
Both statements are wrong. (Where did you read this?)
In TFS, if you want to create a personal branch to try out an idea you have, you will have to create a branch on the TFS server
No you don't always need a branch if you're just "trying out an idea". Of course it depends on what you want to do. Saving your work on the server to secure it against drive crashes is what shelvesets are for in TFS (other VCSs may not provide anything similar, which is why you need to create a branch for every idea there). You can even share your code with others without actually checking it in using shelvesets. Even a simple kind of versioning can be done by including the timestamp in the names of the shelvesets, but this is tedious, probably more so than creating a branch ;) Building your code on the server is another thing you can do with shelvesets.
You should read up on when to use shelvesets over changesets on MSDN (there is an article somewhere) to decide whether you need a new branch.
Now you’re using twice the amount of disk space both on the server and locally!
The copying of the code only happens virtually. The SQL Server behind the TFS Server will not use up twice the space, unless every file actually changes on either one of these branches. Until then, both files on the two branches will "point" to the exact same memory on the SQL Server. If you need to work on both branches simultaneously and map them into your workspace, then of course you need twice the amount of space locally. Both is true for any VCS I am aware of, so this is not a TFS-specific issue.
I am pretty new to TFS but I have some experience with VSS. I like to know your opinions of what would be the best way of working with TFS in the following scenario:
We are a group of developers working on projects. All projects starts from a common base code. All projects are one man only, no code sharing until the project is done. A project can last from a few hours to several months, no code is merged until done. Any developer works simultaneously on more than one project, usually 7-10 projects at a time. Usually the projects only involve a small numbers of files that are changed/created (10-20) but rely on a large group of infrastructure files that change quite often. However, any change in infrastructure is not considered until the merge, so we don't get latest version from server until the final build.
An additional request is that, when merged, we’d like to use a 3 way merge tool. We use this approach in VSS, via a custom made application and it works very well. However this involves special file management, for example every file that has to be changed must have an original version saved somewhere that will be used as the “root” file for the 3 way merge process.
What do you think?
You should take a look at the Visual Studio TFS Branching Guide 2010. (direct download). In that package, there is a PowerPoint deck that walks you through a series of possible branching structures.
It sounds like you want either "Branch by project" or "Branch by developer" (since you only have one developer per project, these are effectively the same).
Regarding the 3-way merge tool, take a look at this list to see how to configure your favorite diff/merge tools.
I am working with my co-worker on some files, that are in TFS repository. We have to share these files frequently, however, in the process of our development they are neither compilable, nor working properly. We don't want to put them in the repository, because the rest of the crew shall have problems with compiling the solution. However, the manual sharing would be rather painful. Is there a way to put files on TFS, but not inside repository? (mark as temporary, not finished or something like that).
You can use a shelveset - if you shelve your set of changes then your colleague can pick them up and the other members of the team will never see them. It is a bit of a PITA as you need to have 2 shelvesets (1 each as you can only update your own). The only other way is to branch and then merge when you have compilable code.
Another option is to branch the code into a new branch that the two of you use. When you are done working on the file, and it will no longer break the main build, you can then merge that file back down to the development branch.
What is the best way to create a completely new project in TFS by copying an existing one?
I have an ASP.NET project that will have 50+ "releases" per year. Each release is a distinct entity that needs to remain independent of all others. Once created, I want to make sure that any change to one (the source project or the copy) does not affect the other.
This is for source control only. I do not need to copy any work items.
In the pre-TFS world I would do this by simply copying the folder that contained all of the project files. This had me 90% of the way to the new app, which I could then tailor for the new release. It is very rare that I need to actually add functionality to the base application, and even when I do it never affects existing apps. Is this still possible using TFS, by copying my local folders and then adding the copy into TFS as a new project?
Any suggestions? One branch per release looks like the "standard" way of doing this but I will quickly end up with dozens of branches that really aren't related, and I'd rather keep each new project as it's own distinct project, with no chance of changes in one affecting the other.
Thanks!
Thanks for the responses. I think you've all given me enough insight to get started. Richard, thanks for the detail. I was a bit concerned that it might be too easy to accidentally merge the branches.
There are really two questions here:
1) Is it better to copy/paste or branch?
I'd venture to say that copy/paste is never appropriate. Unless you are very careful (at minimum, run 'tfpt treeclean' immediately before copying), it's likely you'll end up checking in some inappropriate files to the new location. In addition, you will be using up FAR more disk space on the server, since it must store 50+ full copies instead of just diffs.
There is virtually no danger that branches will "accidentally" become comingled down the line. Merging branches back together involves at least 3 deliberate steps: pend the merge (itself a 4-page wizard), then resolve all conflicts, then checkin.
Nor are you likely to get confused as to your place in the tree. TFS uses "path space" branching. That means branches appear to the user as separate physical locations in the source tree, rather than mere version-tags on top of the same path. Since branches look like folders, you can do all the normal folder operations on them: Cloak (don't download them to your local workspace), Permission (in particular, removing someone's Read permission will ensure they can't even see it), Delete or Destroy (when you're truly done with them).
2) When is it appropriate to create a new Team Project?
This is a more complex topic in general. Official guidance. My opinion.
However, I'd say your case is easy: don't do it. Team Projects have a lot of overhead. There is a finite number you can create on a server...ever. Don't forget about other forms of overhead too, like the time it takes for the project admin to port over all your settings, and the time every developer on your team spends reconnecting his Team Explorer.
All for what? The links above go into great detail about the forms of sub-structure that can be created inside a single Team Project. In short, almost anything is possible. The only areas that are somewhat lacking are Team Queries and Build Definitions, which are restricted to a single container folder, and a few settings like Exclusive Checkout which are all-or-nothing. Unless you have a very large or very diverse team, the benefits of separate team projects per release are very unlikely to outweigh the drawbacks.
Of course, if a "release" is a major event that signals a change in your SCM practices , that's a whole other story. New SCM => new process template => new team project. But I doubt you do that 50+ times a year :)
I would recommend using branching. Create a branch for each release from the main branch. As long as you do not merge the branches they will remain independent. Changes to the main branch will only affect releases created after the those changes were made.
You could copy the files and create a new project, but you may run into a couple of problems:
The projects "remember" that they were in TFS, there is a bit of manual work to clean up special files etc.
TFS may slow down when you have many projects, compared with a single project with branches
This might sound obvious but you should only create a new project for a "new project". It sounds like what you are talking about are different versions of the same project.
If you want to maintain separate codebases for previous releases then as the other answerers have said, branching the code is your best option. This works nicely when you want to merge bug fixes from your latest version into older releases too.
However if you really really must have new projects, you still use branching in the same manner.