Skip to content

Instantly share code, notes, and snippets.

@yuki-takei
Created June 27, 2015 21:37
Show Gist options
  • Save yuki-takei/b91e4da0219429ec99b3 to your computer and use it in GitHub Desktop.
Save yuki-takei/b91e4da0219429ec99b3 to your computer and use it in GitHub Desktop.
devide Marcurial repository
#!/bin/sh
TMPDIR=/tmp
# check args
if [ $# != 2 ]; then
echo "usage: $0 SRCREPOS DESTDIR" 1>&2
exit 0
fi
SRCREPOS=$1
DESTDIR=$2
# make DESTDIR if not exists
if [ ! -d $DESTDIR ]
then
mkdir $DESTDIR;
fi
DESTDIR_FULL=`pwd`/$DESTDIR
cd $SRCREPOS
# main loop
for subdir in *;
do
FILEMAP=$TMPDIR/$subdir.filemap
# generate filemap
echo include $subdir > $FILEMAP;
echo rename $subdir . >> $FILEMAP;
# convert
hg convert --filemap=$FILEMAP . $DESTDIR_FULL/$subdir;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment