Execute "SVN Copy Versioned Items Here" within Powershell - powershell

Within a PowerShell script I need to do the following:
Execute the "SVN Copy Versions Items Here" RMB command for copying an earlier version of File A to a later version of File A in order to compare the before / after prior to a commit.
I know the full path of both files, and the paths / call look something like this:
$fromFile = C:\trunk\v100\fileA.txt
$toFile = C:\trunk\v200\fileA.txt
If I execute the following command:
svn copy $fromFile $toFile
I get the following error: svn: E155010: Path 'C:\trunk\v200\fileA.txt' is not a directory
I believe $fromFile and $toFile are both stored as text.
Any suggestions?

I was able to figure this out. Posting solution in the event anyone comes across the same issue. The error message displayed was a red herring - it has nothing to do with a directory.
Note: In my example, the $toFile had been added via a Subversion Add.
Resolved in the following manner:
svn revert $toFile
Remove-Item $toFile
svn copy $fromFile $toFile
It seems like if the file is present an error is thrown. The revert and remove calls fixed this.

Related

How to copy files in svn into a new directory that depends on a variable value?

I'm currently writing a script in PowerShell which calculates a new tag in the tag directory. I want to copy files from one SVN directory to another directory that depends on the new tag number I calculated.
Here are the lines from the script:
$tag = Write-Host "$($svnMavenTagPrefix)$($nextMavenTagVersion)"
svn copy http://tlvsvn1/svn/repos-bls/MassAnalytics/trunk/ http://tlvsvn1/svn/repos-bls/MassAnalytics/tags/${tag}
For some reason it doesn't work and I receive the following error:
svn: E205007: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) options
svn: E205007: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no 'editor-cmd' run-time configuration option was found
How can I copy the files to a new tag?
The Write-Host cmdlet prints the string you are passing as an argument but doesn't write anything to the output thus $tag is empty. I would recommend you to use a format string:
$tag = '{0}{1}' -f $svnMavenTagPrefix, $nextMavenTagVersion
$url = 'http://tlvsvn1/svn/repos-bls/MassAnalytics/tags/{0}' -f $tag
svn copy http://tlvsvn1/svn/repos-bls/MassAnalytics/trunk/ $url

Passing parameters to SVN in a PowerShell script

I am trying to automate a procedure that uses SVN, and I am trying to teach myself PowerShell (and scripting) in the process.
I set up a PowerShell script that reads values for revision numbers and my folder path, like this:
$GetSVN = read-host "Enter the SVN folder path: "
$RevStart = read-host "Enter the starting revision: "
$RevEnd = read-host "Enter the ending revision: "
It then calls SVN and (tries to) pass the parameters.
Here's my problem: When I try to call SVN as follows:
& "c:\Program Files\TortoiseSVN\bin\svn.exe" "-log -r $RevStart`:$RevEnd $GetSVN"
I get the following message:
svn: E205000: Non-numeric limit argument given
svn: E200004: Could not convert 'og -r BASE:#### [SVN file path]' into a number
Okay, fine. I tried adding an extra space before "-log". But when I do that, here's what happens:
Unknown subcommand: ' -log -r BASE:#### [SVN file path]'
Huh?!? What's going on with this? I've tried various variations of this, all to no avail. I can't find an answer to this anywhere. Does anyone have any insight?
I am a newbie to PowerShell scripting, so feel free to answer as such.
Thanks in advance . . .
Your call is wrong, multiple parameters are grouped as one. Better and correct way to do it is this:
set-alias svn "c:\Program Files\TortoiseSVN\bin\svn.exe"
svn log -r $RevStart`:$RevEnd $GetSVN
Setting alias is cosmetics. The real problem were " placement.

Matlab, dos() command : files remain "in use"

After executing some simple commands like
dos('copy *.txt new.txt', '-echo')
dos('echo. 2 > EmptyFile.txt', '-echo')
I tried to delete the folder in which these files were created. However, Windows gives me the message
"cannot delete "FolderName": the folder is being used by another person/program".
I have to close Matlab to make it work.
How do I solve this? I guess it's something like closing the "session" of cmd commands...
What you're not showing is the change of working directory to your folder. Windows won't let you delete a folder that a process has as a current working directory.
The solution is simple: change the working directory out of that folder. Say:
cd('..')

Team Explorer Everywhere (command line) lying?

I'm trying to get some code pulled down from a local TFS server onto my Mac. I've been fussing around with TEE for quite some time now and it seems it doesn't keep track of what I'm doing from one command to the next. I set a working folder, then try to to perform a get, and I'm met with odd messages:
GA8995AC511228:TEE-CLC-10.0.0 rr154459$ ./tf dir ../all -server:http://10.227.212.202:8080/tfs -login:rr154459#na
There is no working folder mapping for /Users/rr154459/tfs/all.
GA8995AC511228:TEE-CLC-10.0.0 rr154459$ ./tf workfold -map -login:rr154459#na -server:http://10.227.212.202:8080/tfs -workspace:GA8995AC511228 '$\' '../all'
An error occurred: The new working folder mapping of $\ to /Users/rr154459/tfs/all conflicts with the local path in the existing mapping of $/ to /Users/rr154459/tfs/all.
$\ is not a server path. You need to use $/.
Please remove your existing workspace mappings and set them using the correct path formatting.

TFS command line to get list of files checked in yesterday

I'm looking for a simple way to get a list of files that were checked in on a certain day. Is there a command line I can use? I don't want changesets just the file names.
A bit late, but for others asking the same question.
Open a Visual Studio Command Prompt (2010) and use the command:
tf history "local path" /version:D2011-03-29 /recursive /noprompt
Replace the date with the date you wan't information about and localpath to the local folder you bound to, you WILL get the changeset number, but also all items changes. It's also possible to use a collection and remote path instead of local path.
Naturally you can discard noprompt and login and put in that information in a prompt.
More information about the TFS 2010 commandline: http://msdn.microsoft.com/en-us/library/yxtbh4yh.aspx
Use tf command line. It may do what ever you want.