monotone-devel
[Top][All Lists]
Advanced

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

Re: [Monotone-devel] Re: New commands (for mtn, in lua)


From: Eric Anderson
Subject: Re: [Monotone-devel] Re: New commands (for mtn, in lua)
Date: Wed, 5 Sep 2007 18:32:32 -0700

Nathaniel Smith writes:
 > On Tue, Sep 04, 2007 at 09:57:24PM +1000, William Uther wrote:
 > > On 04/09/2007, at 6:51 PM, Nathaniel Smith wrote:
 > > >Everyone has this problem, i.e., this is a bug in 'mtn up'.  Let's not
 > > >use extensibility as a way to plaster over problems in the core :-).
 > > 
 > > There was talk of adding a new option to sync before updating.  Not  
 > > sure that's a
 > > good solution.  A better solution would be to sync by default and  
 > > have an option
 > > to turn it off.
 > > 
 > > I'm not sure I like either of those.  I really think of them as two  
 > > separate commands - remote update and local update.
 > 
 > I think my preferred behavior would be:
 >   mtn update  -> like current 'mtn pull ; mtn update'

I'd be happy with this if the default was mtn pull <default_host>
<current-branch>, but the current setup which has the pull use the
first branch ever pulled doesn't work well if you're working on
multiple projects.  I also wouldn't want it to do a mtn update unless
there are currently no differences because it's much cleaner to do
merges between committed revisions than with an existing workspace,
and it's also possible to undo mistakes if it's committed and harder
if it's not.

The reason I would want the pull based on the current branch is as
follows.  In the setup we have at work, we have a central server that
has all the branches anyone wants to make public.  Most people only
keep a single personal database of all of their monotone work, and so
their database will have a subset of the branches on the central
machine.  They don't want everything, so pull of all branches would be
bad, similarly their current directory may be a branch that wasn't the
original branch they pulled so that would also be wrong.

Below is the script I wrote that does all this, since our naming
convention has sub-branches as bits after the current branch, the
script appends a \* to the branch to pull sub-branches, but that
probably shouldn't be the default.

As for the question of a big delay if you're disconnected, you could
print a message when it starts trying to connect and say 'Ctrl-C to
skip the pull' or something like that.
        -Eric

mt_op () {
    if [[ "$1" = "pull" || "$1" = "push" || "$1" = "sync" ]]; then
        :
    else
        echo "mt_op needs an argument of pull push or sync"
        return 1
    fi
    MTDIR=_MTN
    i=0 
    while [[ $i -lt 10 && ! -d $MTDIR ]]; do
        MTDIR=../$MTDIR
        i=$(( $i + 1 ))
    done
    if [[ ! -d $MTDIR ]]; then 
        echo "Unable to find monotone dir _MTN in anywhere up to 10 parents"
        return
    fi
    if [[ ! -f $MTDIR/options ]]; then
        echo "Error, missing $MTDIR/options file"
        return
    fi
    BRANCH=`grep branch $MTDIR/options | awk '{print $2}' | sed 's/"//g'`
    case $BRANCH in 
        # naming convention is uniqueifier/project/sub-branch
        */*/*) BRANCH=`dirname $BRANCH` ;;
    esac
    echo "Running $1 for $BRANCH*"
    mtn $1 usi.hpl.hp.com $BRANCH\*
    mtn heads
}





reply via email to

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