No announcement yet.

Horizontal Merge Within a Line

  • Filter
  • Time
  • Show
Clear All
new posts

  • Horizontal Merge Within a Line

    I'm often doing complex merges, and I'm generally very much pleased with how Beyond Compare helps me handle conflicts in code blocks.
    Until it comes down to conflicting edits to the same single line.
    An example would be adding a new function parameter in two branches I'm trying to merge.

    common base: f(a)
    ours: f(a, b)
    theirs: f(a, c)

    If if were for added whole lines, I would just hit "Use left then right" or something like that, and the problem would have been solved in an instant.
    But with the line, I can't even see the difference visually! This is a simple case, but when a function has ten parameters and something has been changed in the middle, it's very hard to tell. And even harder to merge.
    You can look at the current lines in their special view one under another, and try to notice the diff. It's only highlighted in red and there is no fancy "added/removed" highlighting for text parts like there is for whole lines.
    Then there's another problem to apply the edits, I often end up picking both lines into the merge pane (by "use left then right" on the line) and then manually copypasting pieces of text between them to make a single version.

    So, is there a mode for merging within the line -- Horizontal Merge -- where I can see added/moved blocks and pick actions like "use left then right" for blocks of characters within the line?
    If not, can you add one?

  • #2

    Thanks for the feedback. Short answer is, no, BC4 does not have this style of merging a line's content. This would require manual editing into the edit pane (either copying and pasting from the inputs to alter the output, or take both and then work manually, deleting and cutting text around).
    Aaron P Scooter Software


    • #3
      Any chance on seeing this as a feature in some not too distance future?)


      • #4
        Sorry, probably not. This requires some smart, in-line handling that we don't currently support, so it is not a small or quick feature change to implement. I've added notes to our Customer Wishlist, but it's more in line with larger projects and not something that would be coming short-term.
        Aaron P Scooter Software


        • #5
          Ah I've got into this again.
          I've tried again Araxis to see if they have anything to offer.
          There's a bonus that they have wrapping in the diff views, this is a huge advantage for longs lines… well, even for regular lines, because looking at a three-way diff view makes the lines three times shorter, so lines are likely to not fit.

          Click image for larger version

Name:	MergeWrapped.png
Views:	112
Size:	116.8 KB
ID:	84067
          Still no controls for helping with merge... this should have been easy to merge, one addition on each side and one replacement. When same happens to lines, Beyond Compare does everything on its own, you just accept. But within the same line — it's a fatal conflict

          And this is how this looks in BC:

          Click image for larger version

Name:	MergeBc.png
Views:	80
Size:	90.8 KB
ID:	84068

          I have to edit into the common version in this view somehow The diffs within the lines are less visual, and missing any wrapping makes it very inconveinent. Not to say that it should have been able to automerge.

          In all other aspects of working with conflicts I like Beyond Compare best. I can do most of the job for me when opening the view, and within conflicting blocks you can select some of the lines and apply operations (like "use left" or "use left then right") to selected sub-block, sounds simple, but it's fantastic and missing from most other tools. Keyboard shortcuts are handy, like goto next conflict — use left — mark resolve and goto next conflict — etc etc. All is rather good, but for merging within the lines, there I get stuck every time.

          Well you need to be making new major features from time to time, maybe you'd consider?


          • #6
            Here is another example of a real-life line merge.

            Click image for larger version  Name:	LineMerge2Horz.png Views:	0 Size:	192.3 KB ID:	84071

            The actual change (base to theirs) after I've taken the line out to a separate differ session and replaced commas with newlines is:

            Click image for larger version  Name:	LineMerge2Vert.png Views:	0 Size:	70.5 KB ID:	84072

            This turns from a mess into a trivial merge item, when viewed in a proper form.
            So you can see why I'm asking so much for some help with merging within lines.

            After some more thought, it looks like this should be not just for a line but for a text range (covering a few lines), so that it were able to match newlines in the right pane to whitespace in the left pane as a "modified" block of characters.

            As a minimal feature (not involving creation of any separate UI mode for line merge) I think I'd do it like this:

            1) Add text wrapping within panes, see a screenshot from a prev post for a possible example. Usually this is done as wrapping by words though, not characters. Diff viewer in IntelliJ IDEA could be a better example of wrapping, though it's not ideal in other aspects.

            2) Highlight added/removed/modified text ranges within lines: current BC just paints them in red forecolor regardless of what change there were, could be presenting them as added/removed/modified blocks to make it more visual. Some example in prior screenshots as well.

            3) Enable merge actions ("Take left", "Take left then right", etc) on individual blocks within a line. Just like you now can select some partial lines of a block and act specifically on them (so many thanks for this!)— allow acting on character blocks when caret is on them or something like this.

            4) Don't isolate text diffing on line boundary, consider that text might have partly moved to another line. It's veeery customary that when a parameter is added, the line gets too long and it gets wrapped. Classic differs would take it as "one line shortened, another new line appeared, and these things are totally independent", while a smarter diff would match the newly-added CRLF to a space in the former line text as a modified piece of text, and most of the other text would be shown unchanged. This makes diffing way smarter, yet does not require any parsing and understanding the language of the file, still works on plain text.

            5) For conflicting lines, show them as a conflict, but still make a guess for merge (like you (BC) do when two adjacent lines are changed on different sides — it's a conflict, but everything is already done for me, I just have to review and accept). Say, if a block of characters were inserted into the line on the left side, and another block inserted on the right side, show a proposed merge result where both insertions were made, I'd just have to decide if the outcome is valid (in C#, it would usually be).

            These are no revolutionary changes (maybe but for the inter-line differ algorithm), but they'd totally change the experience of merging the conflicted lines.
            What do you think?
            Last edited by hypersw; 04-Sep-2020, 09:30 PM. Reason: improve text


            • #7

              These are good suggestions, but the amount of work to implement them wouldn't be minimal. Wrapping text alone is a large project, as are most of the other tasks such as comparing across line breaks. I'll add all of these ideas to our wishlist entry on the subject, although it's unlikely we'll be able to tackle them any time soon given our current development schedule.
              Aaron P Scooter Software