Jump to content

Noninteractive cm merge


Morton

Recommended Posts

Hi,

Is it possible to run cm merge in a way so any conflict that cannot be solved automatically will cause error (non 0 return value)?

I'm trying to create automatic merging script. It tries merge-to and if it fails, it would switch to the target branch and perform merge in the workspace using cm merge. Everything works fine for most cases, but if there is a conflict that cannot be solved automatically, it will open merge tool window, waiting for user input.

Because my intent is to run this on our build server, I really need some way to run this in a noninteractive way and reject any merge that have conflict like this.

The exact command I'm running is: cm merge br:<SourceBranch> --merge -c <comment>

Thanks.

Link to comment
Share on other sites

Hi Morton,

 

I understand that you're trying to perform a merge from a different branch to your current one, right? The merge-to functionality you mentioned works in the opposite direction and it doesn't allow non-automatic conflicts.

So, to perform a merge from any given branch or changeset and avoid prompting the user for manual conflict resolution, you can add the --nointeractiveresolution parameter. It's not currently added to the documentation, but I've notified the team to update it. If this parameter is present no directory conflict will be solved; also, if the default mergetool is configured, the CLI client will try to solve file conflicts using it with the --silent parameter, so automatic file conflicts can be solved but the GUI is not opened if there are manual conflicts.

After a merge with conflicts, however, the client doesn't return a non-zero exit code. You can run the 'cm merge' command without the --merge argument to display the list of remaining conflicts. If that list is empty, it means that the merge operation could be completed without human intervention!

Please try using the --nointeractiveresolution argument and tell us if that worked for your scenario!

 

Regards,

Miguel

Link to comment
Share on other sites

Hi Morton,

I would like to add two extra tips to Miguel's answer to improve merge resolution. With the following configuration, the merge operation will try to automatically
resolve conflicts in files even if source and destination contributors modified the same file. They are valid if you are using built-in PlasticSCM mergetool.exe application or SemanticMerge.

1- Edit the "Preferences" > "Merge tools" and add the "-a" "--silent" flags to "$text" file types entry. In my case, the "Diff/Merge tool command line" entry for text files looks like the following line:
 

mergetool -a --silent -b="@basefile" -bn="@basesymbolic" -bh="@basehash" -s="@sourcefile" -sn="@sourcesymbolic" -sh="@sourcehash" -d="@destinationfile" -dh="@destinationhash" -r="@output" -t="@filetype" -i="@comparationmethod" -e="@fileencoding" -m="@mergetype" -re="@resultencoding" --progress="@progress" --extrainfofile="@extrainfofile"

2- If you have SemanticMerge, you can add the following line for supported language files. Look at the following example for ".cs" file types (C#):

semanticmergetool.exe  -a --silent --progress="@progress" --extrainfofile="@extrainfofile"  -b="@basefile" -bn="@basesymbolic" -s="@sourcefile" -sn="@sourcesymbolic" -d="@destinationfile"  -dn="@destinationsymbolic" -r="@output" -i="@comparationmethod" -e="@fileencoding"  --merge-decl --include-format-change  -emt="c:\PlasticSCM\client\bmergetool.exe -a --silent -b=""#basefile"" -bn=""#basesymbolic"" -s=""#sourcefile"" -sn=""#sourcesymbolic"" -d=""#destinationfile"" -dn=""#destinationsymbolic"" -r=""#output"" -t=""#filetype"" -i=""#comparationmethod"" -e=""#fileencoding""" -edt="c:\PlasticSCM\client\bmergetool.exe  -s=""#sourcefile"" -sn=""#sourcesymbolic"" -d=""#destinationfile"" -dn=""#destinationsymbolic"" -t=""#filetype"" -i=""#comparationmethod"" -e=""#fileencoding"""

(semanticmerge will increase the rate of automatic merges compared with the regular, text-based mergetool.exe app)


Binary files cannot automatically be resolved if the same file was changed by both contributors (a contributor must be manually selected).
But, to ensure the merge operation won't launch any interactive screen at least, add/edit the "$binary" file types entry like this:

c:\PlasticSCM\client\return1.bat

And the contents of "return1.bat" file script:
 

@echo off
exit /B 1

Hope you find it useful!
-Jesús M.

Link to comment
Share on other sites

  • 1 year later...

Hi,

I know this thread is more than a year old but I have a related question. Is there any way of knowing if there are non-automatic conflicts without having to parse the plain text response that "cm merge" is writing to the standard output? That text depends on Plastic SCM installation language, making it difficult to build automated solutions that would work in different environments.

Thanks.

 

Link to comment
Share on other sites

Hi,

With the "cm merge" command, you can check if a file has been changed in both contributors but won't know if the merge will be automatic or not because it depends on the external merge tool.

Regarding the information that shows the "cm merge" command (eg: the file has been changed in both contributors), I'm afraid it's only shown in plain text as an output.

Regards,

Carlos.

Link to comment
Share on other sites

I've found that using "--machinereadable" and "--fieldseparator" I can easily parse each returned line, and look for lines starting with "DIR_CONFLICT" to easily detect changes in both contributors. I almost forgot "--machinereadable" exists (I was looking for something like "--xml" or "--format", but hey that are not usable with "cm merge")

Thanks for your quick response!

Regards,

Rubén.

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...