Re: Unresolved issues #3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <junkio@xxxxxxx> wrote:
> * Martin Langhoff proposed git-xxdiff as a helper after a failed
>   merge.
>
>   Message-ID: <11546492331601-git-send-email-martin@xxxxxxxxxxxxxxx>
>
>   I like the general idea of this a lot, but am having a bit of
>   trouble envisioning how we can integrate this while making
>   sure mergers other than xxdiff can be added easily without
>   disrupting the end user experience.

In StGIT I can configure the merge command and I currently use the
attached script (I need to add it to the StGIT repository). It tries
diff3 first and, if that fails, invokes emacs' merge (can use xxdiff
as well). It also checks whether the file was modified in case I want
to exit and solve the conflict later (maybe after getting conflict
information for the other files).

-- 
Catalin

#!/usr/bin/env python
"""Run diff3 and an interactive tool if this fails.
"""

__copyright__ = """
Copyright (C) 2006, Catalin Marinas <catalin.marinas@xxxxxxxxx>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""

import sys, os

if len(sys.argv) != 5:
    print >> sys.stderr, 'Usage: %s ancestor branch1 branch2 output' \
          % sys.argv[0]
    sys.exit(1)

ancestor = sys.argv[1]
branch1  = sys.argv[2]
branch2  = sys.argv[3]
output   = sys.argv[4]

# default merger
if os.system('diff3 -L current -L ancestor -L patched -m -E '
             '"%s" "%s" "%s" > "%s"'
             % (branch1, ancestor, branch2, output)):
    # interactive merge
    if os.path.exists(output):
        mtime = os.path.getmtime(output)
    else:
        mtime = 0

    ret = os.system('emacs --eval \'(ediff-merge-files-with-ancestor '
                    '"%s" "%s" "%s" nil "%s")\''
                    % (branch1, branch2, ancestor, output))

    #ret = os.system(
    #    'xxdiff --title1 current --title2 ancestor --title3 patched '
    #    '--show-merged-pane -m -E -O -X -M "%s" "%s" "%s" "%s"'
    #    % (output, branch1, ancestor, branch2))

    # error in the interactive merger, just exit
    if ret:
        sys.exit(2)

    # check for file modification
    if not os.path.exists(output) or mtime == os.path.getmtime(output):
        sys.exit(3)

# everything's fine
sys.exit(0)

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]