From 39b8e316dc1e005c0994ae7c683ab07bbda20420 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Thu, 16 Jul 2020 12:06:28 +0200 Subject: [PATCH 01/19] [issue5] rename setup files --- setup-conversion.sh => setup-fast-export.sh | 0 setup-cleanup.sh => setup-mercurial.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename setup-conversion.sh => setup-fast-export.sh (100%) rename setup-cleanup.sh => setup-mercurial.sh (100%) diff --git a/setup-conversion.sh b/setup-fast-export.sh similarity index 100% rename from setup-conversion.sh rename to setup-fast-export.sh diff --git a/setup-cleanup.sh b/setup-mercurial.sh similarity index 100% rename from setup-cleanup.sh rename to setup-mercurial.sh From f34c2b4a66e536e45adb3a5751d2f157da77cdd8 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Thu, 16 Jul 2020 12:07:34 +0200 Subject: [PATCH 02/19] [issue5] Update setup-* calls --- run-cleanup-and-conversion.sh | 8 ++++---- run-cleanup.sh | 4 ++-- run-conversion.sh | 4 ++-- setup-fast-export.sh | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/run-cleanup-and-conversion.sh b/run-cleanup-and-conversion.sh index 0f1cf68..8654f5c 100755 --- a/run-cleanup-and-conversion.sh +++ b/run-cleanup-and-conversion.sh @@ -27,17 +27,17 @@ echo "Storing intermediate repository under ${TEMP_DIR}" # Generate a path to a non-existing temporary directory. INTERMEDIATE_REPOSITORY="${TEMP_DIR}/intermediate" BASE="$(realpath "$(dirname "$(readlink -f "$0")")")" -SETUP_CLEANUP="${BASE}/setup-cleanup.sh" -SETUP_CONVERSION="${BASE}/setup-conversion.sh" +SETUP_MERCURIAL="${BASE}/setup-mercurial.sh" +SETUP_FAST_EXPORT="${BASE}/setup-fast-export.sh" RUN_CLEANUP="${BASE}/run-cleanup.sh" RUN_CONVERSION="${BASE}/run-conversion.sh" -if ! /bin/bash "${SETUP_CLEANUP}"; then +if ! /bin/bash "${SETUP_MERCURIAL}"; then echo "Error during the setup for the cleaning script." exit 2 fi -if ! /bin/bash "${SETUP_CONVERSION}"; then +if ! /bin/bash "${SETUP_FAST_EXPORT}"; then echo "Error during the setup for the conversion script." exit 2 fi diff --git a/run-cleanup.sh b/run-cleanup.sh index 69cf9d1..7c81a42 100755 --- a/run-cleanup.sh +++ b/run-cleanup.sh @@ -23,10 +23,10 @@ fi BASE="$(dirname "$(readlink -f "$0")")" -SETUP_CLEANUP="${BASE}/setup-cleanup.sh" +SETUP_MERCURIAL="${BASE}/setup-mercurial.sh" VIRTUALENV="${BASE}/data/py3-env" -if ! /bin/bash "${SETUP_CLEANUP}"; then +if ! /bin/bash "${SETUP_MERCURIAL}"; then echo "Error during setup." exit 2 fi diff --git a/run-conversion.sh b/run-conversion.sh index 0d46e0d..e3f31b7 100755 --- a/run-conversion.sh +++ b/run-conversion.sh @@ -7,11 +7,11 @@ CONVERTED_REPOSITORY="$2" shift 2 BASE="$(dirname "$(readlink -f "$0")")" -SETUP_CONVERSION="${BASE}/setup-conversion.sh" +SETUP_FAST_EXPORT="${BASE}/setup-fast-export.sh" CONVERT="${BASE}/convert.py" VIRTUALENV="${BASE}/data/py3-env" -if ! /bin/bash "${SETUP_CONVERSION}"; then +if ! /bin/bash "${SETUP_FAST_EXPORT}"; then echo "Error during setup." exit 2 fi diff --git a/setup-fast-export.sh b/setup-fast-export.sh index 37bb062..1f2b2bd 100644 --- a/setup-fast-export.sh +++ b/setup-fast-export.sh @@ -1,12 +1,12 @@ #!/bin/bash BASE="$(dirname "$(readlink -f "$0")")" -SETUP_CLEANUP="${BASE}/setup-cleanup.sh" +SETUP_MERCURIAL="${BASE}/setup-mercurial.sh" FAST_EXPORT_REPO="${BASE}/data/fast-export" FAST_EXPORT_VERSION="v200213-23-g44c50d0" -if ! /bin/bash "${SETUP_CLEANUP}"; then +if ! /bin/bash "${SETUP_MERCURIAL}"; then echo "Error during Mercurial setup." fi From db083c74e077990142d60c80e971bd9c2821c850 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Thu, 16 Jul 2020 13:06:25 +0200 Subject: [PATCH 03/19] [issue5] add run-order.sh script --- run-order.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 run-order.sh diff --git a/run-order.sh b/run-order.sh new file mode 100755 index 0000000..1502702 --- /dev/null +++ b/run-order.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +set -euo pipefail + +if [[ $# -ne 2 ]]; then + echo "Invalid arguments. Use: $0 SRC DST" + exit 1 +fi + +SRC_REPOSITORY="$1" +ORDERED_REPOSITORY="$2" +shift 2 + +if [[ ! -d "${SRC_REPOSITORY}" ]]; then + echo "Invalid argument. ${SRC_REPOSITORY} has to be a directory." + exit 1 +fi + +if [[ -e "${ORDERED_REPOSITORY}" ]]; then + echo "Invalid argument. ${ORDERED_REPOSITORY} may not exist." + exit 1 +fi + + +BASE="$(dirname "$(readlink -f "$0")")" +SETUP_MERCURIAL="${BASE}/setup-mercurial.sh" +VIRTUALENV="${BASE}/data/py3-env" + +if ! /bin/bash "${SETUP_MERCURIAL}"; then + echo "Error during setup." + exit 2 +fi +source "${VIRTUALENV}/bin/activate" + +# Disable all extensions. +# (https://stackoverflow.com/questions/46612210/mercurial-disable-all-the-extensions-from-the-command-line) +HGRCPATH= hg clone "http://hg.fast-downward.org" "${ORDERED_REPOSITORY}" +set +e # hg incoming has an non-zero exit code if nothing is incoming +CHANGESETS="$(hg incoming -R "${SRC_REPOSITORY}" --template "{node} " --quiet "${ORDERED_REPOSITORY}")" +set -e +if [[ ! -z "${CHANGESETS}" ]]; then + HGRCPATH= hg --config extensions.strip= strip ${CHANGESETS} --nobackup -R "${ORDERED_REPOSITORY}" +fi +HGRCPATH= hg pull -R "${ORDERED_REPOSITORY}" "${SRC_REPOSITORY}" From a8f9256824b979351e26c083f9860c326d07f172 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Thu, 16 Jul 2020 13:17:17 +0200 Subject: [PATCH 04/19] [issue5] add run-order.sh to summary script and update README --- README.md | 23 ++++++++++++++++------- run-cleanup-and-conversion.sh | 17 ++++++++++++----- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index db93120..5beb252 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,14 @@ repository is compatible with the official Fast Downward Git repository. ./run-cleanup-and-conversion.sh MERCURIAL_REPOSITORY CONVERTED_GIT_REPOSITORY \ [--redirect-fast-export-stderr FILE] - The conversion is done in two steps that can also be run individually. In this case - CLEANED_MERCURIAL_REPOSITORY is a location where the intermediate cleaned up Mercurial - repository will be written to: - - ./run-cleanup.sh MERCURIAL_REPOSITORY CLEANED_MERCURIAL_REPOSITORY + The conversion is done in three steps that can also be run individually. In this case + ORDERED_REPOSITORY is an intermediate repository that ensures that the history + contains all commits in the same order as the Fast Downward master repository. + The CLEANED_MERCURIAL_REPOSITORY is a location where the intermediate cleaned + up Mercurial repository will be written to: + + ./run-order.sh MERCURIAL_REPOSITORY ORDERED_REPOSITORY + ./run-cleanup.sh ORDERED_REPOSITORY CLEANED_MERCURIAL_REPOSITORY ./run-conversion.sh CLEANED_MERCURIAL_REPOSITORY CONVERTED_GIT_REPOSITORY \ [--redirect-fast-export-stderr FILE] @@ -40,11 +43,17 @@ https://github.com/frej/fast-export.git). branch from the resulting Git repository by running `git branch -D subfeature`. ## Warnings -- Both scripts generate a lot of output on stdout and stderr. If you want - to analyze it, better redirect it into files. +- The `run-cleanup.sh` and `run-conversion.sh` scripts generate a lot of output + on stdout and stderr. If you want to analyze it, better redirect it into files. - The cleanup script generates repeated warnings about missing or invalid tags. These are caused by moved or broken tags and can be ignored. +## Details of the order process +- clone the (Mercurial) Fast Downward master repository +- strip all commits from the master repository that would be new to your + repository +- pull your repository in the master repository + ## Details of the cleanup process - fix and unify author names in commit message - fix typos in branch names diff --git a/run-cleanup-and-conversion.sh b/run-cleanup-and-conversion.sh index 8654f5c..f9a3ff2 100755 --- a/run-cleanup-and-conversion.sh +++ b/run-cleanup-and-conversion.sh @@ -25,29 +25,36 @@ fi TEMP_DIR="$(mktemp -d)" echo "Storing intermediate repository under ${TEMP_DIR}" # Generate a path to a non-existing temporary directory. -INTERMEDIATE_REPOSITORY="${TEMP_DIR}/intermediate" +ORDERED_REPOSITORY="${TEMP_DIR}/ordered" +CLEANED_REPOSITORY="${TEMP_DIR}/cleaned" BASE="$(realpath "$(dirname "$(readlink -f "$0")")")" SETUP_MERCURIAL="${BASE}/setup-mercurial.sh" SETUP_FAST_EXPORT="${BASE}/setup-fast-export.sh" +RUN_ORDER="${BASE}/run-order.sh" RUN_CLEANUP="${BASE}/run-cleanup.sh" RUN_CONVERSION="${BASE}/run-conversion.sh" if ! /bin/bash "${SETUP_MERCURIAL}"; then - echo "Error during the setup for the cleaning script." + echo "Error during the Mercurial setup." exit 2 fi if ! /bin/bash "${SETUP_FAST_EXPORT}"; then - echo "Error during the setup for the conversion script." + echo "Error during the 'fast-export' setup." exit 2 fi -if ! "${RUN_CLEANUP}" "${SRC_REPOSITORY}" "${INTERMEDIATE_REPOSITORY}"; then +if ! "${RUN_ORDER}" "${SRC_REPOSITORY}" "${ORDERED_REPOSITORY}"; then + echo "Ordering failed." + exit 2 +fi + +if ! "${RUN_CLEANUP}" "${SRC_REPOSITORY}" "${CLEANED_REPOSITORY}"; then echo "Cleanup failed." exit 2 fi -if ! "${RUN_CONVERSION}" "${INTERMEDIATE_REPOSITORY}" "${CONVERTED_REPOSITORY}" $@; then +if ! "${RUN_CONVERSION}" "${CLEANED_REPOSITORY}" "${CONVERTED_REPOSITORY}" $@; then echo "Conversion failed." exit 2 fi From 5679fa06b21f5f2ae94ceb2361b18373dcba4a86 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Thu, 16 Jul 2020 13:18:10 +0200 Subject: [PATCH 05/19] rename run-cleanup-and-conversion.sh to run-all-steps --- README.md | 2 +- run-cleanup-and-conversion.sh => run-all-steps.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename run-cleanup-and-conversion.sh => run-all-steps.sh (100%) diff --git a/README.md b/README.md index 5beb252..0a1a110 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ repository is compatible with the official Fast Downward Git repository. resulting Git repository will be written to. The optional parameter can be used to redirect the output of fast-export to a file. - ./run-cleanup-and-conversion.sh MERCURIAL_REPOSITORY CONVERTED_GIT_REPOSITORY \ + ./run-all-steps.sh MERCURIAL_REPOSITORY CONVERTED_GIT_REPOSITORY \ [--redirect-fast-export-stderr FILE] The conversion is done in three steps that can also be run individually. In this case diff --git a/run-cleanup-and-conversion.sh b/run-all-steps.sh similarity index 100% rename from run-cleanup-and-conversion.sh rename to run-all-steps.sh From e75f58f5581b2b0f9a4cc1d5457736c2f0b8367b Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Fri, 17 Jul 2020 11:54:13 +0200 Subject: [PATCH 06/19] [issue5] add HGPLAIN --- run-cleanup.sh | 9 ++++++--- run-conversion.sh | 3 ++- run-order.sh | 9 ++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/run-cleanup.sh b/run-cleanup.sh index 7c81a42..77c7860 100755 --- a/run-cleanup.sh +++ b/run-cleanup.sh @@ -34,7 +34,8 @@ source "${VIRTUALENV}/bin/activate" # Disable all extensions. # (https://stackoverflow.com/questions/46612210/mercurial-disable-all-the-extensions-from-the-command-line) -HGRCPATH= hg \ +HGRCPATH= HGPLAIN= \ +hg \ --config extensions.renaming_mercurial_source="${BASE}/renaming_mercurial_source.py" \ --config extensions.hgext.convert= \ --config format.sparse-revlog=0 \ @@ -46,5 +47,7 @@ HGRCPATH= hg \ --branchmap "${BASE}/data/downward_branchmap.txt" cd "${CLEANED_REPOSITORY}" -HGRCPATH= hg --config extensions.strip= strip "branch(issue323)" --nobackup -HGRCPATH= hg --config extensions.strip= strip "branch(ipc-2011-fixes)" --nobackup +HGRCPATH= HGPLAIN= \ +hg --config extensions.strip= strip "branch(issue323)" --nobackup +HGRCPATH= HGPLAIN= \ +hg --config extensions.strip= strip "branch(ipc-2011-fixes)" --nobackup diff --git a/run-conversion.sh b/run-conversion.sh index e3f31b7..f849b68 100755 --- a/run-conversion.sh +++ b/run-conversion.sh @@ -18,4 +18,5 @@ fi source "${VIRTUALENV}/bin/activate" -HGRCPATH= python3 "${CONVERT}" "${INTERMEDIATE_REPOSITORY}" "${CONVERTED_REPOSITORY}" $@ +HGRCPATH= HGPLAIN= \ +python3 "${CONVERT}" "${INTERMEDIATE_REPOSITORY}" "${CONVERTED_REPOSITORY}" $@ diff --git a/run-order.sh b/run-order.sh index 1502702..ad5fa03 100755 --- a/run-order.sh +++ b/run-order.sh @@ -34,11 +34,14 @@ source "${VIRTUALENV}/bin/activate" # Disable all extensions. # (https://stackoverflow.com/questions/46612210/mercurial-disable-all-the-extensions-from-the-command-line) -HGRCPATH= hg clone "http://hg.fast-downward.org" "${ORDERED_REPOSITORY}" +HGRCPATH= HGPLAIN= \ +hg clone "http://hg.fast-downward.org" "${ORDERED_REPOSITORY}" set +e # hg incoming has an non-zero exit code if nothing is incoming CHANGESETS="$(hg incoming -R "${SRC_REPOSITORY}" --template "{node} " --quiet "${ORDERED_REPOSITORY}")" set -e if [[ ! -z "${CHANGESETS}" ]]; then - HGRCPATH= hg --config extensions.strip= strip ${CHANGESETS} --nobackup -R "${ORDERED_REPOSITORY}" + HGRCPATH= HGPLAIN= \ + hg --config extensions.strip= strip ${CHANGESETS} --nobackup -R "${ORDERED_REPOSITORY}" fi -HGRCPATH= hg pull -R "${ORDERED_REPOSITORY}" "${SRC_REPOSITORY}" +HGRCPATH= HGPLAIN= \ +hg pull -R "${ORDERED_REPOSITORY}" "${SRC_REPOSITORY}" From bd442cb4b76b3fddd977cc77c3f426b8cfac1eeb Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Fri, 17 Jul 2020 12:02:51 +0200 Subject: [PATCH 07/19] [issue5] move -R option of hg to front --- run-order.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/run-order.sh b/run-order.sh index ad5fa03..2b87c5a 100755 --- a/run-order.sh +++ b/run-order.sh @@ -37,11 +37,12 @@ source "${VIRTUALENV}/bin/activate" HGRCPATH= HGPLAIN= \ hg clone "http://hg.fast-downward.org" "${ORDERED_REPOSITORY}" set +e # hg incoming has an non-zero exit code if nothing is incoming -CHANGESETS="$(hg incoming -R "${SRC_REPOSITORY}" --template "{node} " --quiet "${ORDERED_REPOSITORY}")" +CHANGESETS="$(hg -R "${SRC_REPOSITORY}" incoming --template "{node} " --quiet "${ORDERED_REPOSITORY}")" set -e if [[ ! -z "${CHANGESETS}" ]]; then + echo stripping HGRCPATH= HGPLAIN= \ - hg --config extensions.strip= strip ${CHANGESETS} --nobackup -R "${ORDERED_REPOSITORY}" + hg -R "${ORDERED_REPOSITORY}" --config extensions.strip= strip ${CHANGESETS} --nobackup fi HGRCPATH= HGPLAIN= \ -hg pull -R "${ORDERED_REPOSITORY}" "${SRC_REPOSITORY}" +hg -R "${ORDERED_REPOSITORY}" pull "${SRC_REPOSITORY}" From 684057313c51e527f1005513ce4f1aa40714ac59 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Fri, 17 Jul 2020 12:06:59 +0200 Subject: [PATCH 08/19] [issue5] made indentation consistent --- README.md | 56 +++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 0a1a110..2426512 100644 --- a/README.md +++ b/README.md @@ -23,50 +23,50 @@ repository is compatible with the official Fast Downward Git repository. ORDERED_REPOSITORY is an intermediate repository that ensures that the history contains all commits in the same order as the Fast Downward master repository. The CLEANED_MERCURIAL_REPOSITORY is a location where the intermediate cleaned - up Mercurial repository will be written to: + up Mercurial repository will be written to: ./run-order.sh MERCURIAL_REPOSITORY ORDERED_REPOSITORY ./run-cleanup.sh ORDERED_REPOSITORY CLEANED_MERCURIAL_REPOSITORY ./run-conversion.sh CLEANED_MERCURIAL_REPOSITORY CONVERTED_GIT_REPOSITORY \ [--redirect-fast-export-stderr FILE] -The scripts will automatically set up the required tools (a virtual -environment with compatible versions of Mercurial and the fast-export tool -https://github.com/frej/fast-export.git). + The scripts will automatically set up the required tools (a virtual + environment with compatible versions of Mercurial and the fast-export tool + https://github.com/frej/fast-export.git). ## Limitations -- Multiple Mercurial heads with the same branch name are not supported. If your - repository has those, you will see - `Error: repository has at least one unnamed head: hg rXXX`. -- If you have closed and merged a branch "subfeature" into a branch "feature" - and "feature" is not yet merged into "main", you might want to delete "subfeature" - branch from the resulting Git repository by running `git branch -D subfeature`. + - Multiple Mercurial heads with the same branch name are not supported. If your + repository has those, you will see + `Error: repository has at least one unnamed head: hg rXXX`. + - If you have closed and merged a branch "subfeature" into a branch "feature" + and "feature" is not yet merged into "main", you might want to delete "subfeature" + branch from the resulting Git repository by running `git branch -D subfeature`. ## Warnings -- The `run-cleanup.sh` and `run-conversion.sh` scripts generate a lot of output - on stdout and stderr. If you want to analyze it, better redirect it into files. -- The cleanup script generates repeated warnings about missing or invalid tags. - These are caused by moved or broken tags and can be ignored. + - The `run-cleanup.sh` and `run-conversion.sh` scripts generate a lot of output + on stdout and stderr. If you want to analyze it, better redirect it into files. + - The cleanup script generates repeated warnings about missing or invalid tags. + These are caused by moved or broken tags and can be ignored. ## Details of the order process -- clone the (Mercurial) Fast Downward master repository -- strip all commits from the master repository that would be new to your - repository -- pull your repository in the master repository + - clone the (Mercurial) Fast Downward master repository + - strip all commits from the master repository that would be new to your + repository + - pull your repository in the master repository ## Details of the cleanup process -- fix and unify author names in commit message -- fix typos in branch names -- remove large files from history that should not have been added -- change commit message to follow the new convention which is to start with -"`[BRANCH NAME] `" + - fix and unify author names in commit message + - fix typos in branch names + - remove large files from history that should not have been added + - change commit message to follow the new convention which is to start with + "`[BRANCH NAME] `" ## Details of the conversion process -- convert a Mercurial repository to Git with `fast-export` -- delete all Git branches that belong to Mercurial branches which have been - merged and closed -- remove empty commits -- run garbage collections + - convert a Mercurial repository to Git with `fast-export` + - delete all Git branches that belong to Mercurial branches which have been + merged and closed + - remove empty commits + - run garbage collections Let's rewrite history! From eac81b0da5e800c961cade1ebad24d5f72020e10 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Fri, 17 Jul 2020 12:11:11 +0200 Subject: [PATCH 09/19] [issue5] fix run-all-steps.sh usage of wrong directory --- run-all-steps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-all-steps.sh b/run-all-steps.sh index f9a3ff2..c971526 100755 --- a/run-all-steps.sh +++ b/run-all-steps.sh @@ -49,7 +49,7 @@ if ! "${RUN_ORDER}" "${SRC_REPOSITORY}" "${ORDERED_REPOSITORY}"; then exit 2 fi -if ! "${RUN_CLEANUP}" "${SRC_REPOSITORY}" "${CLEANED_REPOSITORY}"; then +if ! "${RUN_CLEANUP}" "${ORDERED_REPOSITORY}" "${CLEANED_REPOSITORY}"; then echo "Cleanup failed." exit 2 fi From 3fac1a2f5d6a673b42d2729e074df1f8ac1068e1 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Fri, 17 Jul 2020 13:15:46 +0200 Subject: [PATCH 10/19] [issue5] export HGRCPATH= HGPLAIN --- run-cleanup.sh | 7 +++---- run-order.sh | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/run-cleanup.sh b/run-cleanup.sh index 77c7860..47d562d 100755 --- a/run-cleanup.sh +++ b/run-cleanup.sh @@ -31,10 +31,11 @@ if ! /bin/bash "${SETUP_MERCURIAL}"; then exit 2 fi source "${VIRTUALENV}/bin/activate" - # Disable all extensions. # (https://stackoverflow.com/questions/46612210/mercurial-disable-all-the-extensions-from-the-command-line) -HGRCPATH= HGPLAIN= \ +export HGRCPATH= +export HGPLAIN= + hg \ --config extensions.renaming_mercurial_source="${BASE}/renaming_mercurial_source.py" \ --config extensions.hgext.convert= \ @@ -47,7 +48,5 @@ hg \ --branchmap "${BASE}/data/downward_branchmap.txt" cd "${CLEANED_REPOSITORY}" -HGRCPATH= HGPLAIN= \ hg --config extensions.strip= strip "branch(issue323)" --nobackup -HGRCPATH= HGPLAIN= \ hg --config extensions.strip= strip "branch(ipc-2011-fixes)" --nobackup diff --git a/run-order.sh b/run-order.sh index 2b87c5a..40fae42 100755 --- a/run-order.sh +++ b/run-order.sh @@ -31,18 +31,16 @@ if ! /bin/bash "${SETUP_MERCURIAL}"; then exit 2 fi source "${VIRTUALENV}/bin/activate" - # Disable all extensions. # (https://stackoverflow.com/questions/46612210/mercurial-disable-all-the-extensions-from-the-command-line) -HGRCPATH= HGPLAIN= \ +export HGRCPATH= +export HGPLAIN= + hg clone "http://hg.fast-downward.org" "${ORDERED_REPOSITORY}" set +e # hg incoming has an non-zero exit code if nothing is incoming CHANGESETS="$(hg -R "${SRC_REPOSITORY}" incoming --template "{node} " --quiet "${ORDERED_REPOSITORY}")" set -e if [[ ! -z "${CHANGESETS}" ]]; then - echo stripping - HGRCPATH= HGPLAIN= \ hg -R "${ORDERED_REPOSITORY}" --config extensions.strip= strip ${CHANGESETS} --nobackup fi -HGRCPATH= HGPLAIN= \ hg -R "${ORDERED_REPOSITORY}" pull "${SRC_REPOSITORY}" From 941c4453756c9e9cd0ad2a327c8121f2eec9bd7e Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Fri, 17 Jul 2020 13:17:57 +0200 Subject: [PATCH 11/19] [issue5] add echo --- run-order.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/run-order.sh b/run-order.sh index 40fae42..8d11cd6 100755 --- a/run-order.sh +++ b/run-order.sh @@ -36,6 +36,7 @@ source "${VIRTUALENV}/bin/activate" export HGRCPATH= export HGPLAIN= +echo "Cloning official repository" hg clone "http://hg.fast-downward.org" "${ORDERED_REPOSITORY}" set +e # hg incoming has an non-zero exit code if nothing is incoming CHANGESETS="$(hg -R "${SRC_REPOSITORY}" incoming --template "{node} " --quiet "${ORDERED_REPOSITORY}")" From 1272f3a564625bbf469c788d96bf2d583ac53c59 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Fri, 17 Jul 2020 13:36:06 +0200 Subject: [PATCH 12/19] [issue5] add troubleshooting to README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 2426512..5bd7d23 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,13 @@ repository is compatible with the official Fast Downward Git repository. - The cleanup script generates repeated warnings about missing or invalid tags. These are caused by moved or broken tags and can be ignored. +## Troubleshooting + If you have problems with the `run-all-steps.sh` script, try to run the steps + individually and carefully inspect the output of each step. Depending on your + problems it might help to first pull the changes from + `http://hg.fast-downward.org` in your repository and then start the conversion + process. + ## Details of the order process - clone the (Mercurial) Fast Downward master repository - strip all commits from the master repository that would be new to your From 01a28d7ddc4dcd57d75feca09e02eb5a58c2d9c0 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Fri, 17 Jul 2020 13:37:45 +0200 Subject: [PATCH 13/19] [issue5] also export HG* in run-conversion.sh --- run-conversion.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run-conversion.sh b/run-conversion.sh index f849b68..c901e40 100755 --- a/run-conversion.sh +++ b/run-conversion.sh @@ -17,6 +17,7 @@ if ! /bin/bash "${SETUP_FAST_EXPORT}"; then fi source "${VIRTUALENV}/bin/activate" +export HGRCPATH= +export HGPLAIN= -HGRCPATH= HGPLAIN= \ python3 "${CONVERT}" "${INTERMEDIATE_REPOSITORY}" "${CONVERTED_REPOSITORY}" $@ From e9e40c2f3af269e2ab3c5baff6a057ff8d2a6506 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Mon, 20 Jul 2020 10:31:52 +0200 Subject: [PATCH 14/19] [issue5] add branch check to cleanup script --- run-cleanup.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/run-cleanup.sh b/run-cleanup.sh index 47d562d..2df188f 100755 --- a/run-cleanup.sh +++ b/run-cleanup.sh @@ -36,6 +36,15 @@ source "${VIRTUALENV}/bin/activate" export HGRCPATH= export HGPLAIN= + +REGEX_BRANCHES="^$(hg branches --template "{branch}|" | \ + sed "s/|$//g" | sed "s/\-/\\\-/g" | sed "s/\./\\\./g")$" +if [[ ! "issue323" =~ ${REGEX_BRANCHES} ]] || \ + [[ ! "ipc-2011-fixes" =~ ${REGEX_BRANCHES} ]]; then + echo "Your repository is missing the branches 'issue323' and 'ipc-2011-fixes' for the conversion." + exit 3 +fi + hg \ --config extensions.renaming_mercurial_source="${BASE}/renaming_mercurial_source.py" \ --config extensions.hgext.convert= \ From b6c42d5e3c590ade74886b4de84f9d293f27b310 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Wed, 22 Jul 2020 09:43:47 +0200 Subject: [PATCH 15/19] [issue5] update repository check for cleanup --- run-cleanup.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/run-cleanup.sh b/run-cleanup.sh index 2df188f..6bf3133 100755 --- a/run-cleanup.sh +++ b/run-cleanup.sh @@ -37,11 +37,9 @@ export HGRCPATH= export HGPLAIN= -REGEX_BRANCHES="^$(hg branches --template "{branch}|" | \ - sed "s/|$//g" | sed "s/\-/\\\-/g" | sed "s/\./\\\./g")$" -if [[ ! "issue323" =~ ${REGEX_BRANCHES} ]] || \ - [[ ! "ipc-2011-fixes" =~ ${REGEX_BRANCHES} ]]; then - echo "Your repository is missing the branches 'issue323' and 'ipc-2011-fixes' for the conversion." +if hg -R "${SRC_REPOSITORY}" incoming http://hg.fast-downward.org; then + echo 1>&2 "Your repository is missing commits from http://hg.fast-downward.org." + echo 1>&2 "You must pull from http://hg.fast-downward.org first." exit 3 fi From 18084ee399f8a92adc66b0f36441cd342d540593 Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Thu, 23 Jul 2020 11:36:07 +0200 Subject: [PATCH 16/19] [issue5] merged run-order.sh into run-cleanup.sh --- README.md | 12 ++++-------- run-all-steps.sh | 8 +------- run-cleanup.sh | 25 +++++++++++++++++++------ run-order.sh | 47 ----------------------------------------------- 4 files changed, 24 insertions(+), 68 deletions(-) delete mode 100755 run-order.sh diff --git a/README.md b/README.md index 5bd7d23..e63551a 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,13 @@ repository is compatible with the official Fast Downward Git repository. ./run-all-steps.sh MERCURIAL_REPOSITORY CONVERTED_GIT_REPOSITORY \ [--redirect-fast-export-stderr FILE] - The conversion is done in three steps that can also be run individually. In this case + The conversion is done in two steps that can also be run individually. In this case ORDERED_REPOSITORY is an intermediate repository that ensures that the history contains all commits in the same order as the Fast Downward master repository. The CLEANED_MERCURIAL_REPOSITORY is a location where the intermediate cleaned up Mercurial repository will be written to: - ./run-order.sh MERCURIAL_REPOSITORY ORDERED_REPOSITORY - ./run-cleanup.sh ORDERED_REPOSITORY CLEANED_MERCURIAL_REPOSITORY + ./run-cleanup.sh MERCURIAL_REPOSITORY ORDERED_REPOSITORY CLEANED_MERCURIAL_REPOSITORY ./run-conversion.sh CLEANED_MERCURIAL_REPOSITORY CONVERTED_GIT_REPOSITORY \ [--redirect-fast-export-stderr FILE] @@ -55,18 +54,15 @@ repository is compatible with the official Fast Downward Git repository. `http://hg.fast-downward.org` in your repository and then start the conversion process. -## Details of the order process +## Details of the cleanup process - clone the (Mercurial) Fast Downward master repository - - strip all commits from the master repository that would be new to your - repository - pull your repository in the master repository - -## Details of the cleanup process - fix and unify author names in commit message - fix typos in branch names - remove large files from history that should not have been added - change commit message to follow the new convention which is to start with "`[BRANCH NAME] `" + - strip the open branches `issue323` and `ipc-2011-fixes` ## Details of the conversion process - convert a Mercurial repository to Git with `fast-export` diff --git a/run-all-steps.sh b/run-all-steps.sh index c971526..ff0a4fd 100755 --- a/run-all-steps.sh +++ b/run-all-steps.sh @@ -30,7 +30,6 @@ CLEANED_REPOSITORY="${TEMP_DIR}/cleaned" BASE="$(realpath "$(dirname "$(readlink -f "$0")")")" SETUP_MERCURIAL="${BASE}/setup-mercurial.sh" SETUP_FAST_EXPORT="${BASE}/setup-fast-export.sh" -RUN_ORDER="${BASE}/run-order.sh" RUN_CLEANUP="${BASE}/run-cleanup.sh" RUN_CONVERSION="${BASE}/run-conversion.sh" @@ -44,12 +43,7 @@ if ! /bin/bash "${SETUP_FAST_EXPORT}"; then exit 2 fi -if ! "${RUN_ORDER}" "${SRC_REPOSITORY}" "${ORDERED_REPOSITORY}"; then - echo "Ordering failed." - exit 2 -fi - -if ! "${RUN_CLEANUP}" "${ORDERED_REPOSITORY}" "${CLEANED_REPOSITORY}"; then +if ! "${RUN_CLEANUP}" "${SRC_REPOSITORY}" "${ORDERED_REPOSITORY}" "${CLEANED_REPOSITORY}"; then echo "Cleanup failed." exit 2 fi diff --git a/run-cleanup.sh b/run-cleanup.sh index 6bf3133..cb54a9e 100755 --- a/run-cleanup.sh +++ b/run-cleanup.sh @@ -2,20 +2,26 @@ set -euo pipefail -if [[ $# -ne 2 ]]; then - echo "Invalid arguments. Use: $0 SRC DST" +if [[ $# -ne 3 ]]; then + echo "Invalid arguments. Use: $0 SRC TMP DST" exit 1 fi SRC_REPOSITORY="$1" -CLEANED_REPOSITORY="$2" -shift 2 +ORDERED_REPOSITORY="$2" +CLEANED_REPOSITORY="$3" +shift 3 if [[ ! -d "${SRC_REPOSITORY}" ]]; then echo "Invalid argument. ${SRC_REPOSITORY} has to be a directory." exit 1 fi +if [[ -e "${ORDERED_REPOSITORY}" ]]; then + echo "Invalid argument. ${ORDERED_REPOSITORY} may not exist." + exit 1 +fi + if [[ -e "${CLEANED_REPOSITORY}" ]]; then echo "Invalid argument. ${CLEANED_REPOSITORY} may not exist." exit 1 @@ -37,17 +43,24 @@ export HGRCPATH= export HGPLAIN= -if hg -R "${SRC_REPOSITORY}" incoming http://hg.fast-downward.org; then +echo "Cloning official repository" +hg clone "http://hg.fast-downward.org" "${ORDERED_REPOSITORY}" + +if hg -R "${SRC_REPOSITORY}" incoming "${ORDERED_REPOSITORY}"; then echo 1>&2 "Your repository is missing commits from http://hg.fast-downward.org." echo 1>&2 "You must pull from http://hg.fast-downward.org first." exit 3 fi +echo "Enforce commit order" +hg -R "${ORDERED_REPOSITORY}" pull "${SRC_REPOSITORY}" + +echo "Clean up repository" hg \ --config extensions.renaming_mercurial_source="${BASE}/renaming_mercurial_source.py" \ --config extensions.hgext.convert= \ --config format.sparse-revlog=0 \ - convert "${SRC_REPOSITORY}" "${CLEANED_REPOSITORY}" \ + convert "${ORDERED_REPOSITORY}" "${CLEANED_REPOSITORY}" \ --source-type renaming_mercurial_source \ --authormap "${BASE}/data/downward_authormap.txt" \ --filemap "${BASE}/data/downward_filemap.txt" \ diff --git a/run-order.sh b/run-order.sh deleted file mode 100755 index 8d11cd6..0000000 --- a/run-order.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -if [[ $# -ne 2 ]]; then - echo "Invalid arguments. Use: $0 SRC DST" - exit 1 -fi - -SRC_REPOSITORY="$1" -ORDERED_REPOSITORY="$2" -shift 2 - -if [[ ! -d "${SRC_REPOSITORY}" ]]; then - echo "Invalid argument. ${SRC_REPOSITORY} has to be a directory." - exit 1 -fi - -if [[ -e "${ORDERED_REPOSITORY}" ]]; then - echo "Invalid argument. ${ORDERED_REPOSITORY} may not exist." - exit 1 -fi - - -BASE="$(dirname "$(readlink -f "$0")")" -SETUP_MERCURIAL="${BASE}/setup-mercurial.sh" -VIRTUALENV="${BASE}/data/py3-env" - -if ! /bin/bash "${SETUP_MERCURIAL}"; then - echo "Error during setup." - exit 2 -fi -source "${VIRTUALENV}/bin/activate" -# Disable all extensions. -# (https://stackoverflow.com/questions/46612210/mercurial-disable-all-the-extensions-from-the-command-line) -export HGRCPATH= -export HGPLAIN= - -echo "Cloning official repository" -hg clone "http://hg.fast-downward.org" "${ORDERED_REPOSITORY}" -set +e # hg incoming has an non-zero exit code if nothing is incoming -CHANGESETS="$(hg -R "${SRC_REPOSITORY}" incoming --template "{node} " --quiet "${ORDERED_REPOSITORY}")" -set -e -if [[ ! -z "${CHANGESETS}" ]]; then - hg -R "${ORDERED_REPOSITORY}" --config extensions.strip= strip ${CHANGESETS} --nobackup -fi -hg -R "${ORDERED_REPOSITORY}" pull "${SRC_REPOSITORY}" From e981f6c83d9305cb1c7cf2554b9c3a80a99ee11d Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Fri, 24 Jul 2020 17:18:21 +0200 Subject: [PATCH 17/19] [issue5] update Warning in ReadMe.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e63551a..a3387f4 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,9 @@ repository is compatible with the official Fast Downward Git repository. repository has those, you will see `Error: repository has at least one unnamed head: hg rXXX`. - If you have closed and merged a branch "subfeature" into a branch "feature" - and "feature" is not yet merged into "main", you might want to delete "subfeature" + and "feature" is not yet merged into "main", you will receive: + `error: The branch 'BRANCH' is not fully merged.` + Don't worry. You might want to delete "subfeature" branch from the resulting Git repository by running `git branch -D subfeature`. ## Warnings From 9c856a6b11d324bbc2122f2cb05c25070d6f4dbb Mon Sep 17 00:00:00 2001 From: Patrick Ferber Date: Tue, 28 Jul 2020 15:09:04 +0200 Subject: [PATCH 18/19] update README.md --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a3387f4..5970b52 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ repository is compatible with the official Fast Downward Git repository. - Git ## Usage - Run the script with the following command where MERCURIAL_REPOSITORY is the path to the + To prepare your repository for the conversion pull all changes from + `http://hg.fast-downward.org`. Then run the script with the following + command where MERCURIAL_REPOSITORY is the path to the repository you want to convert and CONVERTED_GIT_REPOSITORY is the location where the resulting Git repository will be written to. The optional parameter can be used to redirect the output of fast-export to a file. @@ -51,10 +53,7 @@ repository is compatible with the official Fast Downward Git repository. ## Troubleshooting If you have problems with the `run-all-steps.sh` script, try to run the steps - individually and carefully inspect the output of each step. Depending on your - problems it might help to first pull the changes from - `http://hg.fast-downward.org` in your repository and then start the conversion - process. + individually and carefully inspect the output of each step. ## Details of the cleanup process - clone the (Mercurial) Fast Downward master repository From 16bbca392c5f705ca3bb2ded493839da1a4c61a1 Mon Sep 17 00:00:00 2001 From: Malte Helmert Date: Tue, 28 Jul 2020 19:21:51 +0200 Subject: [PATCH 19/19] [issue5] fail early on incoming changes; make reordering implementation detail --- README.md | 99 +++++++++++++++++++++++++---------------------- run-all-steps.sh | 7 ++-- run-cleanup.sh | 41 +++++++++++--------- run-conversion.sh | 7 +++- 4 files changed, 83 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 5970b52..4129370 100644 --- a/README.md +++ b/README.md @@ -11,66 +11,71 @@ repository is compatible with the official Fast Downward Git repository. - Git ## Usage - To prepare your repository for the conversion pull all changes from - `http://hg.fast-downward.org`. Then run the script with the following - command where MERCURIAL_REPOSITORY is the path to the - repository you want to convert and CONVERTED_GIT_REPOSITORY is the location where the - resulting Git repository will be written to. The optional parameter can be used to - redirect the output of fast-export to a file. - - ./run-all-steps.sh MERCURIAL_REPOSITORY CONVERTED_GIT_REPOSITORY \ - [--redirect-fast-export-stderr FILE] - The conversion is done in two steps that can also be run individually. In this case - ORDERED_REPOSITORY is an intermediate repository that ensures that the history - contains all commits in the same order as the Fast Downward master repository. - The CLEANED_MERCURIAL_REPOSITORY is a location where the intermediate cleaned - up Mercurial repository will be written to: - - ./run-cleanup.sh MERCURIAL_REPOSITORY ORDERED_REPOSITORY CLEANED_MERCURIAL_REPOSITORY +To prepare your repository for the conversion pull all changes from +`http://hg.fast-downward.org`. Then run the script with the following +command where MERCURIAL_REPOSITORY is the path to the repository you +want to convert and CONVERTED_GIT_REPOSITORY is the location where the +resulting Git repository will be written to. The optional parameter +can be used to redirect the output of fast-export to a file. + + ./run-all-steps.sh MERCURIAL_REPOSITORY CONVERTED_GIT_REPOSITORY \ + [--redirect-fast-export-stderr FILE] + +The conversion is done in two steps that can also be run individually. +CLEANED_MERCURIAL_REPOSITORY is the location for the cleaned-up +Mercurial repository, which is the output of the first step and the +input of the second step. + + ./run-cleanup.sh MERCURIAL_REPOSITORY CLEANED_MERCURIAL_REPOSITORY ./run-conversion.sh CLEANED_MERCURIAL_REPOSITORY CONVERTED_GIT_REPOSITORY \ [--redirect-fast-export-stderr FILE] - The scripts will automatically set up the required tools (a virtual - environment with compatible versions of Mercurial and the fast-export tool - https://github.com/frej/fast-export.git). +The scripts will automatically set up the required tools (a virtual +environment with compatible versions of Mercurial and the fast-export tool +https://github.com/frej/fast-export.git). ## Limitations - - Multiple Mercurial heads with the same branch name are not supported. If your - repository has those, you will see - `Error: repository has at least one unnamed head: hg rXXX`. - - If you have closed and merged a branch "subfeature" into a branch "feature" - and "feature" is not yet merged into "main", you will receive: - `error: The branch 'BRANCH' is not fully merged.` - Don't worry. You might want to delete "subfeature" - branch from the resulting Git repository by running `git branch -D subfeature`. + +- Multiple Mercurial heads with the same branch name are not supported. If your + repository has those, you will see + `Error: repository has at least one unnamed head: hg rXXX`. +- If you have closed and merged a branch "subfeature" into a branch "feature" + and "feature" is not yet merged into "main", you will receive: + `error: The branch 'BRANCH' is not fully merged.` + Don't worry. You might want to delete "subfeature" branch from the + resulting Git repository by running `git branch -D subfeature`. ## Warnings - - The `run-cleanup.sh` and `run-conversion.sh` scripts generate a lot of output - on stdout and stderr. If you want to analyze it, better redirect it into files. - - The cleanup script generates repeated warnings about missing or invalid tags. - These are caused by moved or broken tags and can be ignored. + +- The scripts generate a lot of output on stdout and stderr. If you + want to analyze it, better redirect it into files. +- It is normal behavior that the cleanup script generates some + warnings about missing or invalid tags. ## Troubleshooting - If you have problems with the `run-all-steps.sh` script, try to run the steps - individually and carefully inspect the output of each step. - + +If you have problems with the `run-all-steps.sh` script, try to run the steps +individually and carefully inspect the output of each step. + ## Details of the cleanup process - - clone the (Mercurial) Fast Downward master repository - - pull your repository in the master repository - - fix and unify author names in commit message - - fix typos in branch names - - remove large files from history that should not have been added - - change commit message to follow the new convention which is to start with - "`[BRANCH NAME] `" - - strip the open branches `issue323` and `ipc-2011-fixes` + +- clone the official (Mercurial) Fast Downward repository +- pull the changes from your repository into the clone +- strip the open branches `issue323` and `ipc-2011-fixes` +- fix and unify author names in commit message +- fix typos in branch names +- remove files from history that should not have been added +- change commit messages to follow the new convention which is to + start with "`[BRANCH NAME] `" ## Details of the conversion process - - convert a Mercurial repository to Git with `fast-export` - - delete all Git branches that belong to Mercurial branches which have been - merged and closed - - remove empty commits - - run garbage collections + +- convert a Mercurial repository to Git with `fast-export` +- delete all Git branches that belong to Mercurial branches which have been + merged and closed +- remove empty commits +- run garbage collection Let's rewrite history! diff --git a/run-all-steps.sh b/run-all-steps.sh index ff0a4fd..962c856 100755 --- a/run-all-steps.sh +++ b/run-all-steps.sh @@ -23,9 +23,8 @@ if [[ -e "${CONVERTED_REPOSITORY}" ]]; then fi TEMP_DIR="$(mktemp -d)" -echo "Storing intermediate repository under ${TEMP_DIR}" +echo "Storing intermediate cleaned-up repository under ${TEMP_DIR}" # Generate a path to a non-existing temporary directory. -ORDERED_REPOSITORY="${TEMP_DIR}/ordered" CLEANED_REPOSITORY="${TEMP_DIR}/cleaned" BASE="$(realpath "$(dirname "$(readlink -f "$0")")")" SETUP_MERCURIAL="${BASE}/setup-mercurial.sh" @@ -43,7 +42,7 @@ if ! /bin/bash "${SETUP_FAST_EXPORT}"; then exit 2 fi -if ! "${RUN_CLEANUP}" "${SRC_REPOSITORY}" "${ORDERED_REPOSITORY}" "${CLEANED_REPOSITORY}"; then +if ! "${RUN_CLEANUP}" "${SRC_REPOSITORY}" "${CLEANED_REPOSITORY}"; then echo "Cleanup failed." exit 2 fi @@ -53,5 +52,5 @@ if ! "${RUN_CONVERSION}" "${CLEANED_REPOSITORY}" "${CONVERTED_REPOSITORY}" $@; t exit 2 fi -echo "Removing intermediate repository." +echo "Removing intermediate cleaned-up repository." rm -r "${TEMP_DIR}" diff --git a/run-cleanup.sh b/run-cleanup.sh index cb54a9e..f98f3bf 100755 --- a/run-cleanup.sh +++ b/run-cleanup.sh @@ -2,31 +2,28 @@ set -euo pipefail -if [[ $# -ne 3 ]]; then - echo "Invalid arguments. Use: $0 SRC TMP DST" +if [[ $# -ne 2 ]]; then + echo "Invalid arguments. Use: $0 SRC DST" exit 1 fi SRC_REPOSITORY="$1" -ORDERED_REPOSITORY="$2" -CLEANED_REPOSITORY="$3" -shift 3 +CLEANED_REPOSITORY="$2" +shift 2 if [[ ! -d "${SRC_REPOSITORY}" ]]; then echo "Invalid argument. ${SRC_REPOSITORY} has to be a directory." exit 1 fi -if [[ -e "${ORDERED_REPOSITORY}" ]]; then - echo "Invalid argument. ${ORDERED_REPOSITORY} may not exist." - exit 1 -fi - if [[ -e "${CLEANED_REPOSITORY}" ]]; then echo "Invalid argument. ${CLEANED_REPOSITORY} may not exist." exit 1 fi +ORDERED_REPOSITORY="$(mktemp -d)" +echo "Storing intermediate reordered repository under ${ORDERED_REPOSITORY}" + BASE="$(dirname "$(readlink -f "$0")")" SETUP_MERCURIAL="${BASE}/setup-mercurial.sh" @@ -42,20 +39,21 @@ source "${VIRTUALENV}/bin/activate" export HGRCPATH= export HGPLAIN= +echo "Looking for missing commits" -echo "Cloning official repository" -hg clone "http://hg.fast-downward.org" "${ORDERED_REPOSITORY}" - -if hg -R "${SRC_REPOSITORY}" incoming "${ORDERED_REPOSITORY}"; then +if hg -R "${SRC_REPOSITORY}" incoming http://hg.fast-downward.org; then echo 1>&2 "Your repository is missing commits from http://hg.fast-downward.org." echo 1>&2 "You must pull from http://hg.fast-downward.org first." exit 3 fi -echo "Enforce commit order" +echo "Cloning official repository" +hg clone http://hg.fast-downward.org "${ORDERED_REPOSITORY}" + +echo "Pulling own commits" hg -R "${ORDERED_REPOSITORY}" pull "${SRC_REPOSITORY}" -echo "Clean up repository" +echo "Creating cleaned-up repository" hg \ --config extensions.renaming_mercurial_source="${BASE}/renaming_mercurial_source.py" \ --config extensions.hgext.convert= \ @@ -67,6 +65,11 @@ hg \ --splicemap "${BASE}/data/downward_splicemap.txt" \ --branchmap "${BASE}/data/downward_branchmap.txt" -cd "${CLEANED_REPOSITORY}" -hg --config extensions.strip= strip "branch(issue323)" --nobackup -hg --config extensions.strip= strip "branch(ipc-2011-fixes)" --nobackup +echo "Stripping extraneous branches" +hg -R "${CLEANED_REPOSITORY}" \ + --config extensions.strip= \ + strip "branch(issue323)" "branch(ipc-2011-fixes)" \ + --nobackup + +echo "Removing intermediate reordered repository." +rm -r "${ORDERED_REPOSITORY}" diff --git a/run-conversion.sh b/run-conversion.sh index c901e40..a65a87f 100755 --- a/run-conversion.sh +++ b/run-conversion.sh @@ -2,6 +2,11 @@ set -euo pipefail +if [[ $# -lt 2 ]]; then + echo "Invalid arguments. Use: $0 SRC DST [optional args for fast-export]" + exit 1 +fi + INTERMEDIATE_REPOSITORY="$1" CONVERTED_REPOSITORY="$2" shift 2 @@ -20,4 +25,4 @@ source "${VIRTUALENV}/bin/activate" export HGRCPATH= export HGPLAIN= -python3 "${CONVERT}" "${INTERMEDIATE_REPOSITORY}" "${CONVERTED_REPOSITORY}" $@ +python3 "${CONVERT}" "${INTERMEDIATE_REPOSITORY}" "${CONVERTED_REPOSITORY}" "$@"