[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mercurial
Subject:    Re: How to debug merge algorithm for binary files?
From:       Sietse Brouwer <sbbrouwer () gmail ! com>
Date:       2018-03-16 13:35:28
Message-ID: CAF=dkzwnQ4SgjDDvYR36MRg8Q0J2hRmp+jCsBi8yZ7ry5JW0HQ () mail ! gmail ! com
[Download RAW message or body]

Dear Ivan,

On 15 March 2018 at 12:55, Лежанкин Иван <abyss.7@gmail.com> wrote:

> How can I debug the merge, so that I will understand why Hg tries to merge
> those files instead of just fast-forward the changes from default branch -
> like many other changes to other binary files?

You could checkout the last commit version in your branch, in the
branch you're merging in, and the last common version. That way you
could see whether your branch introduced any changes by comparing your
local version to the common ancestor; you could see whether the other
branch introduced changes by comparing the other version to the
ancestor; and you could see whether the changes conflict by looking at
the region both changes happened (I don't know how to do that, I have
never done a binary diff.)

These commands let you checkout the three versions. p2() gives the
second parent (the incoming commit) of the working directory, if your
merge is initiated but not yet committed. If you already committed the
merge, use p1(99) (and p2(99)) instead, where 99 identifies the merge
commit.

hg cat some_file -r 'p1()' > some_file.local
hg cat some_file -r 'p2()' > some_file.other
hg cat some_file -r 'ancestor(p1(), p2())' > some_file.ancestor

I have an alias for this in my hgrc, because there was a while when I
had to solve a lot of merge conflicts. It assumes a bash-like shell,
but perhaps someone has a use for it.

# usage: hg versions some_file
# creates
# - some_file.local (version in your branch)
# - some_file.other (version in the incoming branch)
# - some_file.base (version in the last common ancestor)
versions = ! \
    f=${HG_ARGS#versions } && \
    p1=$($HG id --id -r 'p1()') && \
    p2=$($HG id --id -r 'p2()') && \
    $HG cat -r $p1 $f > $f.local && \
    echo $f.local; \
    $HG cat -r $p2 $f > $f.other && \
    echo $f.other; \
    $HG cat -r "ancestor($p1, $p2)" $f > $f.base && \
    echo $f.base

Kind regards,
Sietse
_______________________________________________
Mercurial mailing list
Mercurial@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic