monotone-devel
[Top][All Lists]
Advanced

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

Re: [Monotone-devel] ikiwiki monotone support


From: Brian May
Subject: Re: [Monotone-devel] ikiwiki monotone support
Date: Sat, 23 Feb 2008 11:40:55 +1100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

>>>>> "Brian" == Brian May <address@hidden> writes:

    Brian> Ok, will have a look.

Seems to work fine. I wrote a simple test case to illustrate:

--- cut ---
#!/bin/sh -ex

DIR=/tmp/xyz
rm -rf "$DIR"
mkdir "$DIR"
cd "$DIR"

mtn db init --db="$DIR/test.mtn"

mkdir "$DIR/a"
cd "$DIR/a"
mtn setup --db="$DIR/test.mtn" --branch="branch"
echo "hello world" > file.txt
mtn add file.txt
mtn commit --message "first version"
rev=`mtn automate get_base_revision_id`

echo "my first change" > file.txt
mtn commit --message "second version"

mtn update -r "$rev"

echo "my second change" > file.txt
mtn commit --message "second version"

export MTN_MERGE=fail
mtn merge || false  && true

export MTN_MERGE=diffutils
export MTN_MERGE_DIFFUTILS=partial=true
mtn merge

mtn update
cat file.txt
--- cut ---

Which means, based on my current confusion regarding the
note_netsync_revision_received hook, the following patch (untested)
should simplify things a bit (although it still isn't work base
merges):

...and no, I don't particular care to complicate the code for backward
compatibility with old versions of monotone either...

diff --git a/IkiWiki/Rcs/monotone.pm b/IkiWiki/Rcs/monotone.pm
index 6a15689..bfbb8c4 100644
--- a/IkiWiki/Rcs/monotone.pm
+++ b/IkiWiki/Rcs/monotone.pm
@@ -18,10 +18,6 @@ sub check_config() { #{{{
                error("Ikiwiki srcdir does not seem to be a Monotone workspace 
(or set the mtnrootdir)!");
        }
        
-       if (!defined($config{mtnmergerc})) {
-               $config{mtnmergerc} = "$config{mtnrootdir}/_MTN/mergerc";
-       }
-       
        chdir $config{srcdir}
            or error("Cannot chdir to $config{srcdir}: $!");
 } #}}}
@@ -59,13 +55,11 @@ sub mtn_merge ($$$$) { #{{{
     
        my $mergeRev;
 
-       my $mergerc = $config{mtnmergerc};
-    
        my $child = open(MTNMERGE, "-|");
        if (! $child) {
                open STDERR, ">&STDOUT";
-               exec("mtn", "--root=$config{mtnrootdir}", "--rcfile",
-                    $mergerc, "explicit_merge", $leftRev, $rightRev,
+               exec("mtn", "--root=$config{mtnrootdir}",
+                    "explicit_merge", $leftRev, $rightRev,
                     $branch, "--author", $author, "--key", 
                     $config{mtnkey}) || error("mtn merge failed to run");
        }
@@ -130,21 +124,6 @@ sub commit_file_to_new_rev($$$$$$$$) { #{{{
        return $newRevID;
 } #}}}
 
-sub check_mergerc () { #{{{
-       my $mergerc = $config{mtnmergerc};
-       if (! -r $mergerc ) {
-               debug("$mergerc doesn't exist. Creating file with default 
mergers.");
-               open (my $out, ">", $mergerc) or error("can't open $mergerc: 
$!");
-               print $out <DATA>;
-               print $out <<"EOF";
-       function note_netsync_revision_received(new_id, revision, certs, 
session_id)
-               execute("$config{mtnrootdir}/_MTN/ikiwiki-netsync-hook", new_id)
-       end
-EOF
-               close $out;
-       }
-} #}}}
-
 sub read_certs ($$) { #{{{
        my $automator=shift;
        my $rev=shift;
@@ -280,8 +259,6 @@ sub rcs_commit ($$$;$$) { #{{{
                        }
                        debug("Divergence created! Attempting auto-merge.");
 
-                       check_mergerc();
-
                        # see if it will merge cleanly
                        $ENV{MTN_MERGE}="fail";
                        my $mergeResult = mtn_merge($newRevID, $rev, $branch, 
$author);
@@ -304,9 +281,11 @@ sub rcs_commit ($$$;$$) { #{{{
                        else {
                                debug("Auto-merge failed.  Using diff-merge to 
add conflict markers.");
                                
-                               $ENV{MTN_MERGE}="diffutils_force";
+                               $ENV{MTN_MERGE}="diffutils";
+                               $ENV{MTN_MERGE_DIFFUTILS}="partial=true";
                                $mergeResult = mtn_merge($newRevID, $rev, 
$branch, $author);
                                $ENV{MTN_MERGE}="";
+                               $ENV{MTN_MERGE_DIFFUTILS}="";
                                
                                if (!defined($mergeResult)) {
                                        debug("Unable to insert conflict 
markers!");
@@ -527,55 +506,3 @@ sub rcs_getctime ($) { #{{{
 } #}}}
 
 1
-
-# default mergerc content
-__DATA__
-       function local_execute_redirected(stdin, stdout, stderr, path, ...)
-          local pid
-          local ret = -1
-          io.flush();
-          pid = spawn_redirected(stdin, stdout, stderr, path, unpack(arg))
-          if (pid ~= -1) then ret, pid = wait(pid) end
-          return ret
-       end
-       if (not execute_redirected) then -- use standard function if available
-          execute_redirected = local_execute_redirected
-       end
-       if (not mergers.fail) then -- use standard merger if available
-          mergers.fail = {
-             cmd = function (tbl) return false end,
-             available = function () return true end,
-             wanted = function () return true end
-          }
-       end
-       mergers.diffutils_force = {
-          cmd = function (tbl)
-             local ret = execute_redirected(
-                 "",
-                 tbl.outfile,
-                 "",
-                 "diff3",
-                 "--merge",
-                 "--show-overlap",
-                 "--label", string.format("[Yours]",     tbl.left_path ),
-                 "--label", string.format("[Original]",  tbl.anc_path  ),
-                 "--label", string.format("[Theirs]",    tbl.right_path),
-                 tbl.lfile,
-                 tbl.afile,
-                 tbl.rfile
-             )
-             if (ret > 1) then
-                io.write(gettext("Error running GNU diffutils 3-way difference 
tool 'diff3'"))
-                return false
-             end
-             return tbl.outfile
-          end,
-          available =
-             function ()
-                 return program_exists_in_path("diff3");
-             end,
-          wanted =
-             function ()
-                  return true
-             end
-       }
diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup
index 2c9b020..0d0b384 100644
--- a/doc/ikiwiki.setup
+++ b/doc/ikiwiki.setup
@@ -57,12 +57,6 @@ use IkiWiki::Setup::Standard {
        # The path to your workspace (defaults to the srcdir itself)
        # e.g. use if your srcdir is a subdirectory of the workspace.
        #mtnrootdir => "path/to/root/of/workspace",
-       # This is a monotone lua hook file used by ikiwiki for
-       # inserting conflict markers. By default it will use
-       # mtnrootdir/_MTN/mergerc. This hook will be populated with
-       # default code the first time you use ikiwiki.  You can
-       # change it to alter how conflict markers are inserted.
-       #mtnmergerc => "path/to/mergerc",
 
        wrappers => [
                #{
@@ -90,11 +84,6 @@ use IkiWiki::Setup::Standard {
                #       wrapper => "/git/wiki.git/hooks/post-update",
                #       wrappermode => "06755",
                #},
-               #{
-               #       # The monotone netsync hook.
-               #       wrapper => 
"path/to/root/of/workspace/_MTN/ikiwiki-netsync-hook",
-               #       wrappermode => "06755",
-               #},
        ],
 
        # Default to generating rss feeds for blogs?


-- 
Brian May <address@hidden>




reply via email to

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