monotone-devel
[Top][All Lists]
Advanced

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

Re: [Monotone-devel] Non-modal merge


From: Ralf S. Engelschall
Subject: Re: [Monotone-devel] Non-modal merge
Date: Sun, 23 Sep 2007 15:01:30 +0200
User-agent: Mutt/1.5.16 OpenPKG/CURRENT (2007-06-09)

On Sun, Sep 23, 2007, Ralf S. Engelschall wrote:

> On Sun, Sep 23, 2007, Ralf S. Engelschall wrote:
> > On Sat, Sep 22, 2007, Stephen Leake wrote:
> >
> > > Stefan Monnier <address@hidden> writes:
> > >
> > > > Bak when I used monotone for the first time, I was surprised to see that
> > > > all the merge options provided were pretty much modal.  So I came up 
> > > > with
> > > > the code attached below (not on my own, it's largely copied from random
> > > > bits on the Web, it's probably hideous for Lua experts).
> > > >
> > > > Is there such a tool in standard now?
> > >
> > > Not in standard, but I put one in
> > > contrib/diff3_keep_conflicts_merger.lua
> > >
> > > The objection is that this allows conflicts to be commited to the
> > > database.
> > >
> > > In most situations, I don't have a problem with that, and I definitely
> > > prefer the non-modal behavior; often I don't have time to fix all
> > > the conflicts immediately.
> > >
> > > If you don't want the conflicts committed, you can use
> > > merge_into_workspace, although that has other problems. For one thing,
> > > it's undocumented :). For another, it leaves the workspace with two
> > > parents, which is not typical, and Emacs DVC can't handle it (yet).
> >
> > I've now improved my "diffutils" merger implementation in std_hook.lua.
> > One now can use MTN_MERGE_DIFFUTILS=partial to get the results
> > of contrib/diff3_keep_conflicts_merger.lua. When combined with
> > "merge_into_workspace" as in...
> >
> > $ MTN_MERGE=diffutils_new MTN_MERGE_DIFFUTILS=partial mtn 
> > merge_into_workspace
>
> Sorry, just remove the "_new" above. This was a copy & paste
> error from my session during development. "MTN_MERGE=diffutils
> MTN_MERGE_DIFFUTILS=partial" does the trick on h:n.v.m now.

I've played with this stuff a little further and with the
"register_command" stuff already present on h:n.v.m one can get two
rather nice "mtn" commands:

-----------------------------------------------------------------------------

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 " ..
        "mtn merge_into_workspace " .. revision
    )
    if rc ~= 0 then
        io.stderr:write("mtn: fuse: ERROR: failed to execute \"mtn\"\n")
    end
end

register_command(
    "conflicts",
    "Lists files in workspace containing conflict markers.",
    "Lists all files in the current workspace containing the " ..
    "conflict markers produced by GNU diffutils' \"diff3\" " ..
    "command. This indicates still unresolved merge conflicts.",
    "command_conflicts"
)
function command_conflicts()
    if program_exists_in_path("egrep") == 0 then
        io.stderr:write("mtn: conflicts: ERROR: require GNU grep command 
\"egrep\" in PATH\n")
        return
    end
    local rc = execute(
        "egrep",
        "--files-with-matches",
        "--recursive",
        "^(<<<<<<<|=======|>>>>>>>) ",
        "."
    )
    if rc ~= 0 then
        io.stderr:write("mtn: conflicts: ERROR: failed to execute \"egrep\"\n")
    end
end

-----------------------------------------------------------------------------

The first is a frontend which automates the use of "mtn
merge_into_workspace" together with the partial merging provided
by MTN_MERGE_DIFFUTILS=partial. A "mtn fuse <revision>" now merges
<revision> into the workspace and provides conflict markers for later
manual resolution before the workspace is comitted as the new merged
revision. The "mtn conflicts" command tells one which files in the
workspace still contain conflict markers.

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





reply via email to

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