Recommendations for developing a Pull model with access rights

Michael Smith michael.smith at thalesatm.com
Thu Jan 3 15:43:03 CST 2008


Daniel Pittman wrote:

>> I have written a simple system to synchronize repositories between
>> home and work by email. It uses a local tag in each repository to show
>> the revision of the other repository.
> 
> Er, would you mind sharing that?  I have a task on my todo list to
> enable automatic (and offline compatible) pushing of changes to my todo
> list between home and the office.  (it lives in Hg, of course. :)

Sure, not a problem.

This script is called synchg. Usage

To send changes after the REMOTE tag to the other system:

cd /path/to/repo
synchg

To incorporate changes from a remote system:

cd /path/to/repo
synchg /path/to/bundles/appname-changeset-*
rm /path/to/bundles/appname-changeset-*

It assumes that you extracted bundles from your email inbox and put them 
into /path/to/bundles

A local tag in each repo marks the current known revision of the other 
repo. This tag is updated on send and receive. It doesn't scale very 
well because it has to make a temporary clone in order the build the 
bundle correctly. There may be a better way to do this now.

#! /bin/ksh
if [ "$*" ]
then
     for arg in $*
     do
         echo "unbundling $arg"
         hg unbundle $arg
     done
     hg update
     hg tag --local REMOTE
else
     APP=`basename $PWD`
     NUMBER=`date "+%G%m%d%H%M"`
     CHANGESET="/tmp/$APP-changeset-$NUMBER.hg"
     temprepo=`mktemp -d /tmp/$APP.XXXXXX`
     hg init $temprepo
     hg push -q -r REMOTE $temprepo
     if [ "`hg outgoing -q $temprepo`" ]
     then
         hg bundle -q $CHANGESET $temprepo
         synchmail $CHANGESET $APP
         echo "changeset: " $CHANGESET
         hg tag --local REMOTE
     else
         echo "No changes to send"
     fi
     rm -rf $temprepo
fi

This is the synchmail script

This script sends an email message to a hard coded address. The file to 
attach is $1 and the subject is $2. I use this one on ubuntu at home.

#! /bin/ksh
sylpheed-claws-gtk2 --compose "mailto:my.name at work.domain?subject=[$2] 
$1" --attach $1

This is a different version which uses nail to send the message. I use 
this one on suse at work.

#! /bin/ksh
nail -s "[$2] $1" -a $1 -A username user at home.domain < /dev/null

I have sent a bundle directly to Daniel.
-- 
Michael Smith               | 61 386 304 560
Team Leader, Case and Tools | 61 416 062 898
Thales Australia TCC        |    S  37.82329
Melbourne, Victoria         |    E 144.95426
--------------------------------------------
Confidentiality Notice: This e-mail may contain confidential and/or 
privileged information and is intended solely for the addressee(s) 
named. If you have received this information in error, or are advised 
that you have been posted this e-mail by accident, please notify the 
sender by return e-mail, do not redistribute it, delete the e-mail and 
keep no copies.


More information about the Mercurial mailing list