# Copyright (C) 2015 Facebook, Inc # Maintained by Ryan McElroy # # Distributed under the GNU General Public License, version 2.0. # #!/bin/bash -e if [[ $# -ne 2 ]]; then PROGNAME="$(basename $0)" cat < This script enables the Mercurial share extension, shares a repository from 'src' to 'dst', and copies the .hg/hgrc configuration from 'src' to 'dst'. This allows sharing repositories with non-standard configurations like we have here at Facebook. In the future, this functionality will probably be folded into the share extension directly. END exit 1 fi src="$1" dst="$2" hg --config "extensions.share=" share --noupdate --bookmarks "$src" "$dst" echo "Setting up configuration..." cp "$src/.hg/hgrc" "$dst/.hg/hgrc" # Force share on in this repo, regardless of global setting. # This ensures that bookmark shares will work # (basic sharing works even without extension). if [[ ! $(grep -q "^share=$" "$dst/.hg/hgrc") ]]; then cat >> "$dst/.hg/hgrc" <> "$dst/.hg/shared" # Copy over svn metadata since hgsvn and share are not aware of each other if [[ -d $src/.hg/svn ]]; then echo "Copying svn metadata..." cp -R $src/.hg/svn $dst/.hg/ fi if [[ -e $src/.hg/sparse ]]; then echo "Copying sparse profile..." cp $src/.hg/sparse $dst/.hg/ fi echo "Updating new repository..." hg --cwd "$dst" update $(hg --cwd "$src" log -r . -T '{node}') echo "Set up new Mercurial Working Directory in '$dst' based on '$src'..."