monotone-devel
[Top][All Lists]
Advanced

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

Re: [Monotone-devel] [PATCH] add xemacs and rcs merge commands to lua me


From: Nathaniel Smith
Subject: Re: [Monotone-devel] [PATCH] add xemacs and rcs merge commands to lua merge2/merge3 hooks; fix bug 8550
Date: Tue, 20 Apr 2004 17:19:43 -0700
User-agent: Mutt/1.5.5.1+cvs20040105i

On Tue, Apr 20, 2004 at 10:58:53AM +0200, Christof Petig wrote:
> It is a shame that people developing a distributed version control 
> system exchange and apply patches by hand ... any ideas on how to make 
> this more efficient, Graydon?

Out-of-line servers aren't really very convenient for quick one-off
patches.  How about a little script?

#!/bin/sh
# Command to run monotone:
MONOTONE="monotone"
if [ "$#" -ne 3 ]; then
    echo "Usage: $0 /path/to/database.db branch-name commit-msg < patchfile"
    exit 2
fi
DB="$1"; BRANCH="$2"; MSG="$3"
TMPDIR=/tmp/monotone-import.$$
mkdir $TMPDIR || (echo "Can't mkdir."; exit 1)
PATCH=$TMPDIR/patch
cat > $PATCH
if grep -qE '# *(delete|move|add) ' $PATCH; then
    echo "Oops, looks there are tree changes, and I can't handle those."
    echo "Continuing anyway, cross your fingers..."
fi
NUM_ID_LINES=`grep "Old manifest" $PATCH | wc -l`
if [ "$NUM_ID_LINES" -ne 1 ]; then
    echo "Corrupt patch, giving up."
    echo "(Not produced by Monotone, or multiple patches concatenated?)"
    rm -rf $TMPDIR
    exit 1
fi
PARENT_ID=`grep "Old manifest" $PATCH | cut -f4 -d' '`
CHILD_ID=`grep "New manifest" $PATCH | cut -f4 -d' '`
CODIR=$TMPDIR/co
if ! $MONOTONE --db="$DB" --branch="$BRANCH" checkout $PARENT_ID $CODIR; then
    echo "Failed to check out manifest id '$PARENT_ID', giving up."
    rm -rf $TMPDIR
    exit 1
fi
cd $CODIR
if ! patch < $PATCH; then
    echo "Error patching files, mess left in $TMPDIR"
    exit 1
fi
if ! $MONOTONE status | grep -q "New manifest: $CHILD_ID"; then
    echo "Patch did not result in claimed ID, how fishy..."
    echo "Mess left in $TMPDIR"
    exit 1
fi
if ! $MONOTONE commit "$MSG"; then
    echo "Failed to commit; mess left in $TMPDIR"
    exit 1
fi
rm -rf $TMPDIR
echo "All done."
    

Save as mt-import or something, then in mutt when you see a patch you
like on the list you do
  |mt-import ~/src/monotone/monotone.db net.venge.monotone "Bob's cool patch"
(Be careful to review the patch _before_ doing this, of course, since
it'll be committed with your cert and your name.)

Do also note that it's all gloriously untested, at the "has never
existed outside this email message" level, so it almost certainly has
at least 2 stupid typoes to prevent it working, but you get the idea.
Making it work better (handle deletes and moves, say) is left as an
exercise for the reader.

-- Nathaniel

-- 
"But in Middle-earth, the distinct accusative case disappeared from
the speech of the Noldor (such things happen when you are busy
fighting Orcs, Balrogs, and Dragons)."




reply via email to

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