TF checkin ignore "no files to check in" error - tfs

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.

Related

Is it possible to compare files using Plastic SCM Command Line 'cm diff' function?

I'd like to compare two files at particular changesets to see if they are identical or not.
Something like:
>> cm diff rev:Folder\MyFile.py#cs:5 rev:Folder\MyFile.py#cs:10
<< True
I'm getting an error (can't find revision of file I specify) and I think I might not be using diff as it's intended. I've worked around my confusion by using getfile on the particular file and changesets I'm comparing and using a python library file compare.
Thanks.
The Plastic SCM default diff tool will open a GUI showing you the file differences.
But you can manually configure a different one (eg. diff.exe) manually editing the "/home/user/.plastic/client.conf" or using the Plastic SCM GUI:
<DiffToolData>
<FileType>enTextFile</FileType>
<FileExtensions>*</FileExtensions>
<Tools>
<string>diff.exe #sourcefile #destinationfile</string>
</Tools>
</DiffToolData>
This way, you can run diffs through the command line and based on the output, determine if the files are identical or not.
You can use cm patch command
reference : https://blog.plasticscm.com/2018/11/unified-diff-of-branch.html

Appending line in file when changes were made

I am looking for a file comparison tool (like WinMerge) that will compare the text of the files AND on the lines that were changed let me append a comment to the end of the line such as "//changed by bob".
The file would then be saved with the changes the developer made and with the added comment on every line changed.
I have found ways to log changes to a file but not a way to append the file that is being committed.
We are using ClearCase as source control so we have access to cleartool.
I am not aware of such a tool.
The closest you might consider would be cleartool annotate (see "How to use ClearCase Annotate").
You could process the output of this command in order to regenerate the file content with the right information added to each line.

TFS workfold /unmap "Multiple workspaces exist with the name XYZ"

I am trying to understand how to solve the following situation.
I have a TFS 2012 server with three collections, say;
- http://tfs2012:8080/tfs/DefaultCollection/
- http://tfs2012:8080/tfs/CollectionOne/
- http://tfs2012:8080/tfs/CollectionTwo/
In CollectionOne and CollectionTwo I have a workspace of the same name, lets call it "TestWorkspace".
When I run a map command for that workspace on CollectionOne it works perfectly (can get, delete, update, etc). The issue comes when I try to unmap the workspace as I am done using it (think build machine), the following call fails.
tf.exe workfold /unmap /workspace:TestWorkspace E:\Temp
It fails with;
Multiple workspaces exist with the name TestWorkspace.
Please specify the Team Foundation Server or qualify the name with the owner.
Therefore I try the following;
tf.exe workfold /unmap /workspace:TestWorkspace E:\Temp /collection:http://tfs2012:8080/tfs/CollectionOne/
Which fails with the following;
The option collection is not allowed.
Also specifying the owner of the workpsace doesn't help as they are owned by the same user.
How do I unmap a workspace which exists in two or more collections?
This has been reported as a bug here: https://connect.microsoft.com/VisualStudio/feedback/details/574162/tf-workfold-unmap-not-accepting-collection-option
See here for a workaround: http://wiert.me/2012/08/29/vs2010-workfold-command-allows-moving-a-local-working-folder-for-a-workspace-but-not-unmapping-it-when-you-have-multiple-workspaces-with-the-same-name/
This is indeed an annoying defect. Here's a simple workaround I've used successfully.
# Rename existing workspace to something unique
tf workspace /collection:http://yourserver:8080/tfs/DefaultCollection /newname:TEMPORARY /noprompt DEVBOX-SGY
# Unmap based on new (unique) name
tf workfold /unmap /workspace:TEMPORARY C:\Code\Tools
# Rename workspace back to original name to avoid side-effects
tf workspace /newname:DEVBOXSGY /noprompt TEMPORARY
Personally I was not able to use the workaround mentioned by sparkplug, because I needed something automation friendly.

Can I create a selector file using the Plastic command line utility?

I am attempting to write a batch file for my developers to run that sets up workspaces. The batch file will use Plastic's command line utility, cm.exe.
When I create a workspace in the Plastic client GUI, there is a combo box that allows me to select the repository. This generates a plastic.workspace file, and a plastic.selector file that contains a reference to the selected repository.
However, when I use the command line utlity to make a workspace, I have to specify an existing selector:
cm mkwk MyWorkspace c:\MyWorkspacePath --selector=my.selector
or edit the selector when prompted:
cm mkwk MyWorkspace c:\MyWorkspacePath --selector
Ideally, I would like to be able to do something like
cm mkwk MyWorkspace c:\MyWorkspacePath MyRepository#MyServer:8888
and have the files generated the same way that they are done by the GUI.
Is there a way to do this using cm.exe, or do I have to write all the selectors beforehand?
Although it's not documented, you can issue the "mkwk" command with the "--repository" parameter. For example:
cm mkwk code c:\code --repository=code#localhost:8087
Hope it helps!

"tfpt online" with -diff... can it ignore the "Read Only" attribute?

I figured that adding the -diff option meant that it ignored the "Read Only" flag. What it actually does is get the union of 2 sets of files 1) those files that have their "Read Only" flag unset AND 2) those files that have been modified ("Read Only" flag can remain set)
$ tfpt online "D:\a\b\c.txt" -diff -preview
Getting your pending changes from the server...
Checking the status of D:\a\b\c.txt... Done
Walking D:\a\b\c.txt... Found 1
Showing potential changes only. No changes made.
Edits:
edit: D:\a\b\c.txt
Showing potential changes only. No changes made.
$ tf diff "D:\a\b\c.txt"
Comparing local to latest: D:\a\b\c.txt
$
What I'd really like is for tfpt online to ignore the "Read Only" flag and ONLY list files that have actually been modified. Is this possible?
Unfortunately, there's no way to simply exclude the list of files that are not read-only from being pended as edits. However, you can use the "undo unchanged" command of the power tool to undo those edits that were writable but did not have content differences:
tfpt online /diff [itemspec]
tfpt uu [itemspec]
tfpt uu will compare the hashes again to determine what's unchanged from the server, so it's obviously less efficient than if you were to ignore the read-only attribute the first time, but it should ultimately solve your problem.

Resources