Jump to content

How to export file diffs via the CLI?


Graeme

Recommended Posts

How can I export diffs for each file that's changed in a branch (or between changesets) via the CLI?

I don't mind whether the export goes to a file or stdout.

The documentation for cm diff seems to suggest using --download will write the diff ("differences content") to the specified path... but all I get when using this is the latest versions of the files.

I don't want a patch, although I could possibly make a patch work if it has full context for each file.

Currently I'm resorting to trying to export each file's current and previous version with getfile and then generating the diff from those with gnu diff - but I'm struggling to use getfile to retrieve the previous version (I'm not able to easily determine the previous version).

I'm currently using client 10.0.16.5882 (had to revert to this version following an issue with the latest 10.x client).

 

EDIT:

It would be trivial if cm diff --download worked, but there must be bug with this currently as the command currently only downloads the files as they appear at the changeset specified second.

For example: cm diff 123 124 --download=c:\tmp\ will download the files as they are at changeset 124.

For branches: cm diff br:/main/someBranch simply downloads the files as they appear on the branch /main/someBranch.

Link to comment
Share on other sites

  • 1 month later...

Hi,

Sorry for the delayed response, you are right about what the cm diff --download suggests, let me bring this up to the Development Team, I will update you soon.

Is it possible to you to use the output of the command? Or do you need to download a file specifying the changes? Maybe you can use the --format option to get the needed information from the output?

Regards,
 
Rafael
Unity Plastic SCM Support
Virtualize your Workspace. Make it dynamic.

Link to comment
Share on other sites

Hi Rafael

Yeah within the context of the diff command what the --download option currently does doesn't make sense.

However... the problem I was trying to solve was to do with code reviews and that the Plastic code review tool still doesn't work with x-links. Initially I wanted to export the diffs and import them into an external review tool. But, I realised I could leverage the weird behaviour of the --download option to instead replicate files (including those x-link'd into a repo) to a "code review" repo and create a review there using the Plastic code review tool.

In the long term I still need a better solution as the Plastic code review tool is very basic.

Link to comment
Share on other sites

Hi,

For getting a file with the differences downloaded you can use:

cm diff br:/main/taskFeature > diff.txt

I agree with you about the help of --download as it can be misleading, we will update the help message for it.

15 hours ago, Graeme said:

In the long term I still need a better solution as the Plastic code review tool is very basic.

We are currently working on improving the system so we can offer a richer and improved review experience. You can check this on the public roadmap:

https://portal.productboard.com/m8i3g2dqrmywvbqnkdmzeauv/tabs/96-version-control/tabs/87-plastic-scm-for-unity

Regards,
 
Rafael
Unity Plastic SCM Support
Virtualize your Workspace. Make it dynamic.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...