monotone-devel
[Top][All Lists]
Advanced

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

Re: [Monotone-devel] Re: Non-modal merge


From: Ralf S. Engelschall
Subject: Re: [Monotone-devel] Re: Non-modal merge
Date: Mon, 24 Sep 2007 22:43:26 +0200
User-agent: Mutt/1.5.16 OpenPKG/CURRENT (2007-06-09)

On Mon, Sep 24, 2007, Ralf S. Engelschall wrote:

> On Mon, Sep 24, 2007, Stefan Monnier wrote:
>
> > [...]
> > > I've not found an option combination for diff3(1)
> > > which shows the ancestors but not the non-overlapping parts. I've tried
> > > many combinations of --merge, -A, -E, -x and -X but have not found a
> > > solution.
> >
> > Indeed AFAIK there's no such solution.  It's easy to change diff3 to provide
> > this feature, and I proposed such a change to diff3's maintainer about 10
> > years ago, but I didn't have a clean patch back then and never got around to
> > write one.
>
> Ok, as I really want the most useful workspace-based merging for
> Monotone myself, I've investigated on this issue for us and crafted such
> a patch against GNU diffutils 2.8.7 -- I've now even already applied it
> to our official OpenPKG "diffutils" package, so I've it available in the
> OpenPKG world ;-) I append you the patch here, too...
> [...]

In order to allow one to use this patch and to allow you to have "-A" as
the default or me having "-E" the default and other having even "-X" the
default ;-) I've futher improved the "diffutils" merger in std_hooks.lua
to now take "partial", "diff3opts=[...]" and "sdiffopts=[...]" as the
options in the comma-separated environment variable MTN_MERGE_DIFFUTILS.
With this one now can do e.g...

$ MTN_MERGE=diffutils \
  MTN_MERGE_DIFFUTILS="partial,diff3opts=-E -O" \
  mtn merge_into_workspace <revision>

...and this way combine the merging into the workspace with the nice
consise conflict marking output of diff3(1) under option "-E" but still
with the ancestor/older information under my patched in version "-O".

And combined with the appended Lua register_command() stuff, one can now
simply say "mtn fuse b:<branch>" to merge a branch into the workspace
and then resolve the conflicts step-by-step there. I'm now really happy,
that's a major step forward on my personal Monotone agenda ;-)

Hopefully this stuff is useful for others, too.

                                       Ralf S. Engelschall
                                       address@hidden
                                       www.engelschall.com


register_command(
    "fuse",
    "Fuse a revision into workspace with conflict markers.",
    "Fuse a specified revision into the current workspace by merging " ..
    "the revision into the workspace while providing inline conflict " ..
    "markers for manually resolving the conflicts in the workspace " ..
    "before comitting the conflicts-resolved workspace as the new " ..
    "merged revision.",
    "command_fuse"
)
function command_fuse(revision)
    if revision == nil then
        io.stderr:write("mtn: fuse: ERROR: revision not given\n")
        return
    end
    if program_exists_in_path("mtn") then
        io.stderr:write("mtn: fuse: ERROR: require Monotone command \"mtn\" in 
PATH\n")
        return
    end
    local rc = execute(
        "sh", "-c",
        "MTN_MERGE=diffutils MTN_MERGE_DIFFUTILS=\"partial,diff3opts=-E -O\" " 
..
        "mtn merge_into_workspace " .. revision
    )
    if rc ~= 0 then
        io.stderr:write("mtn: fuse: ERROR: failed to execute \"mtn\"\n")
    end
end





reply via email to

[Prev in Thread] Current Thread [Next in Thread]