monotone-devel
[Top][All Lists]
Advanced

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

[Monotone-devel] A useful hack...


From: Richard Levitte - VMS Whacker
Subject: [Monotone-devel] A useful hack...
Date: Wed, 22 Feb 2006 10:27:33 +0100 (CET)

Hi,

is someone else doing the same as me, playing with two versions of
monotone (0.25 and 0.26pre2 in my case) at once?  Are you sick and
tired of having to remember which version to use with the particular
workspace you're working with today?  So was I, so I hacked together a
small perl script that reads one line from MT/monotone-path and uses
that as the true monotone path.  Of course, I simply called the script
"monotone", but you can use it with several versions of monotone-viz
with a simple softlink:

        ln -s PATH/TO/monotone PATH/TO/monotone-viz

Of course, you'd better stick this script in a separate directory that
takes precedense before the directory where you installed the
different monotone and monotone-viz versions.

Anyway, script attached, just use it.

Cheers,
Richard

-----
Please consider sponsoring my work on free software.
See http://www.free.lp.se/sponsoring.html for details.

-- 
Richard Levitte                         address@hidden
                                        http://richard.levitte.org/

"When I became a man I put away childish things, including
 the fear of childishness and the desire to be very grown up."
                                                -- C.S. Lewis
#! /usr/bin/perl
#
# Copyright (c) 2006, Richard Levitte <address@hidden>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use strict;
use warnings;
use File::Basename;
use File::Spec;

my $root=undef;
my $i=0;

my $self=basename($0);

while ($i <= $#ARGV) {
    if ($ARGV[$i] =~ /^--root=(.*)$/) {
        $root=$1;
    } elsif ($ARGV[$i] =~ /^--root$/) {
        $i++;
        $root=$ARGV[$i];
    } elsif ($ARGV[$i] =~ 
/^--(dump|log|xargs|ticker|rcfile|key|db|keydir|confdir)$/) {
        $i++;
    }
    $i++;
}

my $myroot=File::Spec->rel2abs(File::Spec->curdir());
while (!defined $root && $myroot ne File::Spec->rootdir()) {
    if (-d File::Spec->catdir($myroot,"MT")) {
        $root=$myroot;
    }
    $myroot=dirname($myroot);
}

if (!defined $root) {
    print STDERR "No root found\n";
}

my $versionfile=File::Spec->catfile($root,"MT","$self-path");
my $monotonepath=undef;
if (-f $versionfile) {
    open VF,$versionfile || die "Couldn't open $versionfile: $!\n";
    $monotonepath=<VF>;
    chomp $monotonepath;
    close VF;
    if (! -x $monotonepath) {
        $monotonepath=undef;
    }
}
if (!defined $monotonepath) {
    print STDERR "Give the monotone program path by doing something like 
this:\n";
    print STDERR "  which <your-favorite-$self-version> > ",$versionfile,"\n";
    exit 1;
}

system($monotonepath,@ARGV);

reply via email to

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