Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2012
    Posts
    3

    Default Merging line differences

    Hi,

    Whenever there is a conflict in a 3 way merging, Beyond Compare selects the base line (and marks the line as a conflict). At least in my case this is almost never what I need. The base contains the oldest version, and if both left and right changed, discarding both changes isn't a great default.

    What I would like to see is an "automatic" merging of the line as default, while still marking it as a conflict. For example, let's imagine we have:

    base.txt:
    procedure test(const a:integer; const b: integer);

    left.txt:
    procedure test(var a:integer; const b: integer);

    right.txt:
    procedure test(const a:integer; const arg2: integer);

    What I would like to see as default for the conflict would be:
    procedure test(var a:integer; const arg2: integer);


    Do you think it would be feasible? Due to my workflow I get many conflicts like this one, and currently it is a lot of effort to manually solve them all. A default like this (a 3way merge of the line) would help me a lot.

    Of course I don't know how much effort it would take (and I hope it isn't that much), but conceptually it would be the same algorithm you use for the 3way merge of lines, but applied to the characters in a single line, of the 3 versions (base, left, right)

    Thanks for doing such a great product. Even it this can't be implemented, it still saves me some hours every day. But if it can be implemented, it would just be fantastic!

    Adrian.

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,623

    Default

    Hello,

    We do have a method of automerging from the command line, using a combination of the /automerge and /force command lines. However, this results in CSV style text inserted into the file, in order to draw attention for the user to fix the conflict. As a conflict, we require user review or interaction to resolve, and want to avoid any indication that we may have merged things correctly or automatically. We do not default to both Left and Right text in a conflict section, since if the user wanted to manually pick only left or right, or merge all of the left and part of the right, they would need to remove much of the automerge first before proceeding. By starting with the common ancestor, any edits made (from ancestor to arrive at Left, or from the ancestor to arrive at Right) can also be re-applied to the output in part or fully.

    We do have quick "Take Left then Right" and "Take Right then Left" commands in the Edit menu (or Customize Commands dialog). Would either of these meet your needs when applied to each conflict line of your merge?
    Aaron P Scooter Software

  3. #3
    Join Date
    Sep 2012
    Posts
    3

    Default

    Hi,
    Command line won't work here, I need to manually examine every conflict, so I need the interactive version.

    I don't think that "take left then right" or "take right then left" would do what I need? I want a merge of the 3 lines, not one and then the other.
    Back in the example, if I have:

    base.txt:
    procedure test(const a:integer; const b: integer);

    left.txt:
    procedure test(var a:integer; const b: integer); //developer A changed "const" to "var"

    right.txt:
    procedure test(const a:integer; const arg2: integer); //developer B changed "b" to "arg2"

    Take left then right would get me:
    procedure test(var a:integer; const b: integer);
    procedure test(const a:integer; const arg2: integer);

    Which is not what I want. I want a single line which merges both changes made by developers A and B to the base file. In this case, a developer changed a const to a var and the other changed "b" to "arg2", so what would be logical in most cases is to apply both changes, with the final result being:

    procedure test(var a:integer; const arg2: integer);

    If this can't be the default (instead of the base.text line), then a command "merge changes from both sides" would do, I can press it every time and avoid manually merging all the same-line changes.

    But if you add this command, it would be cool if there is an option to make it the default. While some people might want the base line as default, in my case I always prefer to start with a merge of both, and I guess many people would like the same. If I want the base, left or right, I can just press the colored arrows in the gutter, or do "Take center". But I know from daily experience, I almost always want the merge of the 3. It would save me a lot of time if BC could provide me that merge, either through a "merge line" command or even better as default (which could be an option for people who prefers to have the base as default)

    As a side note, this behavior of choosing center by default gets worse because BC won't warn you when you save a file with conflicts. I review hundreds of files a day, and sometimes I press save when I shouldn't, and then all the changes are reverted to base and all modifications are lost. But I think this warning has been discussed in other post.

  4. #4
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,623

    Default

    We do not have an algorithm capable of determining which text to merge together within a single line. This would be a fairly complicated enhancement, and I'm not aware of another merge tool that offers this capability. This is why we mark the section as a Conflict and require user interaction to merge the text of the line together.

    We don't have a confirmation box if attempting to save a file with conflicts, but we do show a count of the current conflict sections in the lower left corner. As you resolve a conflict, you should click the conflict button to remove it as a conflict. This way, the count would be "0" (or just show "Different sections") once the file has no conflicts remaining. We also have "Next Conflict" and "Previous Conflict" commands, which can have keyboard shortcuts assigned to them, so you can quickly hop between Conflicts to see if any exist before a Save. We also have Next Difference/Prev Difference commands. Adding a confirmation box on Save with Conflicts is on our Customer Wishlist, and I'll add your notes to that entry.
    Aaron P Scooter Software

  5. #5
    Join Date
    Sep 2012
    Posts
    3

    Default

    Aaron,

    Quote Originally Posted by Aaron View Post
    We do not have an algorithm capable of determining which text to merge together within a single line. This would be a fairly complicated enhancement, and I'm not aware of another merge tool that offers this capability. This is why we mark the section as a Conflict and require user interaction to merge the text of the line together.
    Yep, I am not aware of any other tool doing this either, that's by I thought it would be a cool addition

    I am also aware that this wouldn't be trivial and I don't expect an immediate fix, it was more a suggestion to add to the wish list, as I think it can be useful and also a differentiator, since as you mentioned, no one else is doing it.
    Of course, implementing it or not would depend on how much people would find it useful. I surely would, but it might be because of my particular workflow.

    In the meantime, I think I will be able to workaround it this way:
    1)Create an application that I can call from BC, which takes the 3 files as input.
    2)This app would do a command line merge of the files
    3)Then It would scan for the <<<<< conflict symbols, and for each one, create 3 new files with one word per line. From my previous example, this tool would create the following baseNew.txt

    procedure
    test
    (
    const
    a
    :
    integer
    ;
    const
    b
    :
    integer
    );

    Same for LeftNew and RightNew. Then I will 3-way merge those files again with the command line, and if there aren't any conflicts, just create a merged file with the merged part of the original merge and the "resolved lines" from this second merge. This would be a "word" merge since I put a word per line, it could be indeed a character merge, but I think for my case a word merge is better. A character merge could automerge thing that shouldn't be merged.

    Well, it was a little long to explain, but I think once I implement it it will save me a lot of time.


    Quote Originally Posted by Aaron View Post
    We don't have a confirmation box if attempting to save a file with conflicts, but we do show a count of the current conflict sections in the lower left corner. As you resolve a conflict, you should click the conflict button to remove it as a conflict. This way, the count would be "0" (or just show "Different sections") once the file has no conflicts remaining. We also have "Next Conflict" and "Previous Conflict" commands, which can have keyboard shortcuts assigned to them, so you can quickly hop between Conflicts to see if any exist before a Save. We also have Next Difference/Prev Difference commands. Adding a confirmation box on Save with Conflicts is on our Customer Wishlist, and I'll add your notes to that entry.
    Thanks again for adding those to the wishlist. I am aware of the count in the status bar and the "next"/"previous" buttons, and of course I use them all the time. It is just that sometimes you are reviewing a hundred files and you press "escape->save" before realizing there was a conflict. (maybe because you had pressed "escape->save" 20 times before as there wasn't any conflict on the 20 previous files).

    It would be great to get an escape->save->are you sure? workflow for those files.

    Well, this got longer than I expected.
    For the last time, I wanted to thank you for a great product, which I think is the best file comparer-merger by a long margin.

    Regards,
    Adrian.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •