Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue5 #6

Merged
merged 19 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ 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 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:
PatrickFerber marked this conversation as resolved.
Show resolved Hide resolved

./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]

Expand All @@ -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.
PatrickFerber marked this conversation as resolved.
Show resolved Hide resolved
- 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
Expand Down
25 changes: 16 additions & 9 deletions run-cleanup-and-conversion.sh → run-all-steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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_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_ORDER="${BASE}/run-order.sh"
RUN_CLEANUP="${BASE}/run-cleanup.sh"
RUN_CONVERSION="${BASE}/run-conversion.sh"

if ! /bin/bash "${SETUP_CLEANUP}"; then
echo "Error during the setup for the cleaning script."
if ! /bin/bash "${SETUP_MERCURIAL}"; then
echo "Error during the Mercurial setup."
exit 2
fi

if ! /bin/bash "${SETUP_CONVERSION}"; then
echo "Error during the setup for the conversion script."
if ! /bin/bash "${SETUP_FAST_EXPORT}"; then
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
PatrickFerber marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
4 changes: 2 additions & 2 deletions run-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions run-conversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions run-order.sh
Original file line number Diff line number Diff line change
@@ -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}"
PatrickFerber marked this conversation as resolved.
Show resolved Hide resolved
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}"
PatrickFerber marked this conversation as resolved.
Show resolved Hide resolved
fi
HGRCPATH= hg pull -R "${ORDERED_REPOSITORY}" "${SRC_REPOSITORY}"
4 changes: 2 additions & 2 deletions setup-conversion.sh → setup-fast-export.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down
File renamed without changes.