Jump to content

CLI - Solving conflicts before merge


DarkCamper

Recommended Posts

Hi,

I'm trying to do a merge operation that has an directory conflict (evil twin) and a file changed in both contributors with 'cm'. Something like this

image.png.011c80401221d4239d5af1203bd436b6.png

 

I think i've been able to solve the directory conflict using a mix of "--resolveconflict" ,"--conflict", "--resolutionoption" and "--solvedconflictsfile" (none of them show in the 'cm merge help' message btw). But I've been unable to do the equivalent of the following GUI action (just for one file, not the entire merge operation):

image.png.b9012f212296b5d9793e645b78801eaf.png

 

Could you give me some insight about how could I do that?

Regards,

Rubén.

 

Link to comment
Share on other sites

Hi Rubén,

The option equivalent to "Merge keeping source changes" is "--keepsource" and the option equivalent to "Merge keeping workspace changes" is "--keepdestination".

To solve only some file conflicts and not all, you can give specify the paths of the file conflicts to solve. Like this:

cm merge br:/main/task --merge --keepsource /fichero

This command and the "Merge selected files" or "Merge selected files choosing method" only allows leaving the other file conflicts pending to be resolved on a next call. But all the directory conflicts must be resolved first and all the changes to apply (added, deleted, moved & modified only on source) are applied before solve any file conflict. 

One question, why do you solve the directory conflict using all these hack options? Why don't you solve it using the interactive resolution of the default command?

cm merge br:/main/task --merge

You can also solve the directory conflicts using the default resolution and keep the source changes for the file conflict. Even more, as you have only one conflict you don't need to specify the path.

cm merge br:/main/task --merge --keepsource

The hack options that you are using are internal options using by our plugins and the merge resolution using them is much more complicated. You are missing the option "--mergeresultfile" that is also needed when " --solvedconflictsfile" is used. Anyway, they are not public because they have some known issues (when they are not used with care) and I will recommend you to not use them.

Best regards,

Borja

 

 

 

Link to comment
Share on other sites

12 hours ago, Borja said:

cm merge br:/main/task --merge --keepsource /fichero

I didn't know you could specify a file path. Already tried it and it works, thanks!

 

12 hours ago, Borja said:

One question, why do you solve the directory conflict using all these hack options? Why don't you solve it using the interactive resolution of the default command?

We're preparing some scripts for our CI pipeline that may take decisions about some directory conflicts automatically and they're run without human intervention. So there's no chance to use the UI, only the CLI tool with --nointeractiveresolution. Besides we are developing a Cakebuild addin to allow interaction with PlasticSCM in cake scripts, and we'd like it to be as much complete as possible (time constraints aside...). There are already addins for other VCS and we thought we could provide the cakebuild community with some Plastic love :D

 

12 hours ago, Borja said:

Anyway, they are not public because they have some known issues (when they are not used with care) and I will recommend you to not use them. 

Now, knowing I'm having to use the CLI (if there's another option I'm willing to use it), could you explain a bit those issues, or give me some tips about how to use those arguments? I'd rather not end up blowing up something when dir conflicts arise.

 

Thanks!

Link to comment
Share on other sites

Hi Rubén,

Well, in that case, you will need to use these hack options. As far as you don't have xlinks in the repository they will work. Anyway, we will try to fix them soon.

I will try to explain them to you:

  • --mergeresultfile & --solvedconflictsfile, are both used to store the merge info between different calls. You need to pass a path for each one, this path will be created on the first call and updated on each next call. After the last call, you need to delete both files. All the calls that you perform to do a merge need to use the same files.
  • To solve a directory conflict you need to use the following options:
    • --resolveconflict -> A flat to indicate that the call is to solve a directory conflict
    • --conflict -> The index of the conflict that you want to solve. Starting at 1.
    • --resolutionoption -> Indicate the conflict resolution it can be:
      • "src" to keep the source change and discard the destination change.
      • "dst" to keep the destination change and discard the source change
      • "rename", only if the conflict type support this resolution, to rename the destination to the given name provided on the option "--resolutioninfo"
    • -- resolutioninfo -> To provide the name to use on a rename resolution
  • --nointeractiveresolution -> A flag to make the command file when the user intervention is required to solve a directory or file conflict.
  • To print the output on a machine-readable way (much more easy to parse):
    • --machinereadable -> A flag to print the output in a machine-readable format
    • --startlineseparator -> Prefix for each output line. By default, it's a string empty
    • --endlineseparator -> Suffix for each output line. By default, it's a string empty.
    • --fieldseparator -> Field separator. By default, it's a space(' ').

Command sample:
cm merge  --machinereadable --startlineseparator=start@_@line --endlineseparator=new@_@line --fieldseparator=def#_#sep --mergeresultfile=C:\Users\Borja\AppData\Local\Temp\2tmp4D6C.tmp --solvedconflictsfile=C:\Users\Borja\AppData\Local\Temp\2tmp4D6D.tmp --resolveconflict --conflict =0 --resolutionoption=rename  -- resolutioninfo=bin_dst br:/main/task --merge

Anyway, I recommend you to take a look at:
* Server-side merge, a workspace less merge -> http://blog.plasticscm.com/2018/03/workspace-less-merge-to.html
* Devops, how to automatize a DevOps cycle including plugin code sample for some CI -> https://www.plasticscm.com/devops

I think that they could be interesting for you and what you are doing.

Best regards,

Borja

Link to comment
Share on other sites

Thanks a lot Borja! I'll make good use of this information :)

Just another thing. If I use "conflict=0" the operation ends with an error stating that '0' is not a valid conflict. But "conflict=1" works (and there's only one DIR_CONFLICT). I'm attaching a screenshot of the test I've done

image.png.2ff888fb1e0154a3b184921fcdc57069.png

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...