Jump to content

Can I get a file on label changeset with command line?


Aaron K

Recommended Posts

Hi there.

 

Is there a way to use the plastic command line to retrieve a file from a specific label? I'm looking at adding some automated tools that need to be able to grab source code files based on a path and a label. I don't want to create a workspace and then sync the entire repository. All I want is one file at a time. Something like this

 

cm getfile some\path@somelabel@repo

 

 

Can this be done?

 

Thanks

 

Link to comment
Share on other sites

Hello Aaron,

 

yes! you can specify labels, branches and labels.

 

The "--help" option of the "cm cat" command will give you some examples.

 

So in you case I think you are looking for something like this: 

cm cat serverpath:/src/foo.c#lb:5.4.16.773@rep:code@repserver:orion:9095

Hope it helps!

Link to comment
Share on other sites

Hi Manu, thanks for that! That ALMOST does what I want, but I was wondering if there's a way to have the case of the path ignored? What I'm doing is retrieving information from a .PDB file via the dbghelp API and unfortunately it is returning to me a lowercased version of the original file path. If I pass that to your command line, it doesn't find it. I can understand why it'd do that (For case sensitive filesystems) but is there a way around it?

 

Alternatively, is there a Microsoft source server plugin for Plastic so I could just run the source server tools and have the correct information embedded into the PDBs?

 

Thanks

Aaron

Link to comment
Share on other sites

I'm afraid I can't think in any better way than this:

 

1) Run a "cm ls / --tree=6982805@codice@diana:9095 -R > tree.txt" for the changeset number you want to get items from.

    This should be pretty fast, it's a recursive ls, you can even customize it with "--format={path}" in order to get only the path.

2) Run a case insensitive search for the tree.txt file in order to get your paths in the right case.

3) Run the cm cat command in order to get the right file.

 

I'll keep thinking about this in order to find a better way. As this is going to be automatized, I guess, it shouldn't be a hard problem. 

Link to comment
Share on other sites

Thanks, yeah I've resorted to something similar. One more question. Now I have my tool on a real server that's calling my utility from PHP (IIS user) I think I'm running into auth problems when invoking CM from code. Is there a way to specify credentials to a CM command? That way I can make a special Plastic user for my utility and use that.

 

Thanks

Aaron

Link to comment
Share on other sites

Hi!

 

it's possible to provide credentials on every cm command, you can do it like follows:

 

cm xxxxxxxxx -clientconf=c:\Path\to\client.conf

 

the client.conf is a file where the credentials are specified along with other parameters, it's default location is "c:\Users\<Your_win_user>\AppData\Local\plastic4".

 

There's another way to have all the Windows users configured to work with plastic at once, it's done by moving the "c:\Users\<Your_win_user>\AppData\Local\plastic4\client.conf" inside the "C:\Program Files\PlasticSCM5\client" directory, if you do this it's not needed to use the -clientconf parameter on every cm command.

Link to comment
Share on other sites

Thanks I'll try that.  What fields do I need to set for user creds?

 

 

Another related question....should I have any problem launching cm from another application with something like std::system (Like exec()). My tool needs to launch cm to retrieve source code but when I do this (Windows) when the user is not logged in (I am running my tool on a task schedule) I get no output, nothing, nada. I can run the same command from a command prompt or from the scheduler when logged in and it all works but when launched from another program whilst logged out it gets nothing.

 

Cheers

Aaron

Link to comment
Share on other sites

Hi!

 

You'll need to have the user name and the encrypted password, both of them are stored inside the "client.conf" file, check the "SecurityConfig" XML tag. You can crypt the password using the "cm crypt" command.

cm crypt mypasswordinplaintext

You shouldn't have any problem running the command using an external tool, we daliy do it using the CmdRunner project: https://github.com/PlasticSCM/plastic-cmdrunner, it's great and works for Windows, Mac and Linux, it suses the "cm shell" mode of the "cm" tool boosting the speed a LOT.

 

Can you tell me if you are using the client.conf parameter? If not check the user running the scheduler, he needs to have Plastic properly configured. Another option is enable the "cm.log.conf" file to get the log working (https://www.plasticscm.com/documentation/technical-articles/kb-enabling-logging-for-plastic-scm-part-i.html), we should see more information there.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...