To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / extra / fast-export / hg-reset.sh @ 1574:7b23adecd963
History | View | Annotate | Download (1.82 KB)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
|
| 3 |
# Copyright (c) 2007, 2008 Rocco Rutte <pdmef@gmx.net> and others. |
| 4 |
# License: MIT <http://www.opensource.org/licenses/mit-license.php> |
| 5 |
|
| 6 |
ROOT="`dirname $0`" |
| 7 |
REPO="" |
| 8 |
PFX="hg2git" |
| 9 |
SFX_MARKS="marks" |
| 10 |
SFX_MAPPING="mapping" |
| 11 |
SFX_HEADS="heads" |
| 12 |
SFX_STATE="state" |
| 13 |
QUIET="" |
| 14 |
PYTHON=${PYTHON:-python}
|
| 15 |
|
| 16 |
USAGE="[-r <repo>] -R <rev>" |
| 17 |
LONG_USAGE="Print SHA1s of latest changes per branch up to <rev> useful |
| 18 |
to reset import and restart at <rev>. |
| 19 |
If <repo> is omitted, use last hg repository as obtained from state file, |
| 20 |
GIT_DIR/$PFX-$SFX_STATE by default. |
| 21 |
|
| 22 |
Options: |
| 23 |
-R Hg revision to reset to |
| 24 |
-r Mercurial repository to use |
| 25 |
" |
| 26 |
|
| 27 |
IS_BARE=$(git rev-parse --is-bare-repository) \ |
| 28 |
|| (echo "Could not find git repo" ; exit 1) |
| 29 |
if test "z$IS_BARE" != ztrue; then |
| 30 |
# This is not a bare repo, cd to the toplevel |
| 31 |
TOPLEVEL=$(git rev-parse --show-toplevel) \ |
| 32 |
|| (echo "Could not find git repo toplevel" ; exit 1) |
| 33 |
cd $TOPLEVEL || exit 1 |
| 34 |
fi |
| 35 |
GIT_DIR=$(git rev-parse --git-dir) || (echo "Could not find git repo" ; exit 1) |
| 36 |
|
| 37 |
while case "$#" in 0) break ;; esac |
| 38 |
do |
| 39 |
case "$1" in |
| 40 |
-r|--r|--re|--rep|--repo) |
| 41 |
shift |
| 42 |
REPO="$1" |
| 43 |
;; |
| 44 |
-*) |
| 45 |
# pass any other options down to hg2git.py |
| 46 |
break |
| 47 |
;; |
| 48 |
*) |
| 49 |
break |
| 50 |
;; |
| 51 |
esac |
| 52 |
shift |
| 53 |
done |
| 54 |
|
| 55 |
# for convenience: get default repo from state file |
| 56 |
if [ x"$REPO" = x -a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then |
| 57 |
REPO="`grep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`" |
| 58 |
echo "Using last hg repository \"$REPO\"" |
| 59 |
fi |
| 60 |
|
| 61 |
# make sure we have a marks cache |
| 62 |
if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then |
| 63 |
touch "$GIT_DIR/$PFX-$SFX_MARKS" |
| 64 |
fi |
| 65 |
|
| 66 |
GIT_DIR="$GIT_DIR" $PYTHON "$ROOT/hg-reset.py" \ |
| 67 |
--repo "$REPO" \ |
| 68 |
--marks "$GIT_DIR/$PFX-$SFX_MARKS" \ |
| 69 |
--mapping "$GIT_DIR/$PFX-$SFX_MAPPING" \ |
| 70 |
--heads "$GIT_DIR/$PFX-$SFX_HEADS" \ |
| 71 |
--status "$GIT_DIR/$PFX-$SFX_STATE" \ |
| 72 |
"$@" |
| 73 |
|
| 74 |
exit $? |