Branch moved folder based on label or date - tfs

I've moved a folder in tfs using the "move" command but now I cannot create branches off the moved folder based on date or label (label was created when source was in the old folder). I can however create a branch based on "latest version". I get an error message "no items match in if I try to branch of a label. I'm guessing the label references files using the old folder before I moved it. I also get no files if I try to "get specific version" by either date or label.
I've tried to roll back moving the folder but this gives me errors such as "An unexpected error occured".

If you need to branch from points in time prior to the move, you need to specify the old name.
# fails
tf branch $/project/folder-newname $/project/folder-somebranch /version:Loldlabel
# should work
tf branch $/project/folder-oldname $/project/folder-somebranch /version:Loldlabel

The error related to rollback was that I had to roll back a folder rename first. I could then roll back moving the folder.

Related

How to refference a line of code in BitBucket from a selected commit but the line is not part of the change

We try to create a link to a selected line of code, but the code section where that line appears (and we what to show) is in a previous commit.
That section IS NOT part of the changes reflected in that commit, but is in the repository snapshot for that commit.
Is there a way to do that?
We found a way to do that, the trick is to reference your source code by using the commit whole hash as a branch name.
i.e. The following link gives you the source code of a public BitBucket repository in it's master branch:
https://bitbucket.org/teamsinspace/wally-learns-git/src/master/
but if you replace the "master" for the "<commit hash>" and more over, concatenate the "<file path>" and append "#lines-<the line number>", i.e.:
https://bitbucket.org/teamsinspace/wally-learns-git/src/6382d80b420b0a4e5aae204e2d9401021d2f677d/LICENSE.txt#lines-7
You get a link to the source code file, positioned showing the line, and this line remarked from the rest.
Notice that, if you look in that particular commit the LICENCE.txt file was not modified so not included in the commit changes display:
https://bitbucket.org/teamsinspace/wally-learns-git/commits/6382d80b420b0a4e5aae204e2d9401021d2f677d

TFS API Create Branch Programmatically visualization

I have a folder into tfs,and I want to take branch of this folder with creating new folder and put branch under this new folder programmatically.Normally when we do it in tfs it automatically change folder to branch.
When I use createbranch command ,it works ,create folder and under these new folder it create new branch,but branch seen like folder in tfs but I can merge it vs so it is working.If I want to change visualization I have to use second command CreateBranchObject.Is it possible to that in one command
Folder A-->take new branch
Folder A'(New Folder) --> Branch
Code Sample
int changesetId = VersionControlServer.CreateBranch(#"myfolder ", "mynewfolder\newbranch",
VersionSpec.Latest);
Changeset changeset = vcs.GetChangeset(changesetId);
changeset.Update();
This is not like in a single command and you will need to call both in sequence.

TF checkin ignore "no files to check in" error

Background: I am writing a batch files to create and check in some contract files (language agnostic representations of API files) whenever we check into an API project. I am checking in the files with the following command:
tf checkin /flags myContractFiles
Frequently the contract files do not change so I often get this error:
There are no remaining changes to check in.
As a result the build fails.
Question: Is there a way to avoid this particular error?
What I have tried: I am aware of the /force flag for tf checkin (as suggested here), but would rather not use it because I would prefer to only check in when there actually is a change (I do not want to pollute the branch history with changesets with no changes). I have also seen the tf diff and tf folderdiff commands, but it looks like they output their result to the command line, and I am unable to do something like this:
if tf folderdiff ... (
tf checkin ...
)
You will either have to parse the folderdiff result to do what you want or create a custom activity to detect the changes through the API.

TFS Label Inconsistency

I've been working with Team Foundation Server 2012 to get a Continuous Integration build for a data warehouse project working. In doing so I noticed that the labeling and building from a label wasn't yielding the results that I was expecting. In researching the problem I was able to replicate the issue using only the command line arguments provided by Team Foundation Servers Command Line tools. That helped me to eliminate anything in the build definition that may have been affecting the build.
So this is my problem:
I have a build that is building 2 different projects in a single build. It basically has two *.SLN files associated with it. I applied a label to 2 assets, one in each project. I can then execute the command to view which assets have the label. When doing this I get the expected result. However, when I execute the command to get the assets associated with this label it only pulls 1 of the two files. I've verified that I can pull both files, by removing one of the projects. This is the setup that I have with the build definition, work space and label
TFS Paths: $/Dev/Project1
$/Dev/Project2
Workspace Mapping
Project1: C:/SourceControl/Project1
Project2: C:/SourceControl/Project2
DeploymentFolder
Project1: //DevServer/SSIS/Project1
Project2: //DevServer/SSIS/Project2
Executed Commands:
Apply Label: tf label TestLabel $/DEV/Project1/PackageA.dtsx
tf label TestLabel $/DEV/Project2/PackageA.dtsx
Review Label: tf labels /format:Detailed LTestLabel
Get From Label:
tf get /r /version:LTestLabel
After executing the tf get command I get the following results
Deployment folder: //DevServer/SSIS/Project1 contains the file PackageA.dtsx
Deployment folder: //DevServer/SSIS/Project2 contains 0 Files.
It appears that there is a filter or restriction on pulling assets in different projects with the same label. I would expect that if I apply a label to any asset in TFS, then pull the labels, it should allow me to retrieve all assets with that applied label. Has anyone heard or experienced this? Any help provided would be appreciated.
You don't specify what (local) folder you're in when you execute the get: since you don't specify a folder to get, it implies the current one, equivalent to:
tf get /recursive /version:Llabelname .
If you want to get both, specify a directory containing both, for example:
tf get /recursive /version:Llabelname $/
This, of course, assumes that both the files in your label are mapped.

TFS Changeset history using QueryHistory after branch rename

I'm using the VersionControlServer.QueryHistory method to retrieve a list of files that have changed during a timespan that ranges from 5/1/2009 to 10/1/2009. My results unexpectedly only included items that had changed after 9/1/2009. I then realized that the path that I was using, $/Project/Reports/Main, didn't exist until 9/1/2009. Before 9/1/2009, there had been another node named $/Project/Main/Reports, which was renamed to $/Project/Reports/Main.
When I query from Source Control Explorer I can see the entire history (5/1/2009 - 10/1/2009) that I expect to see. However, I can't get the same results via the API. I've tried to specify the branch that no longer exists because it was renamed, but not surprisingly I get zero results. Any ideas?
I believe you need to pass the slotMode parameter as false; that instructs TFS that you want the history for the item that currently occupies that slot, even if it did not always do so (passing it as true gives you the history of that slot).
See the docs for more information.

Resources