summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/hg-incremental.script53
-rwxr-xr-xtests/hg-incremental.setup47
-rw-r--r--tests/hg-incremental.stdout5
-rwxr-xr-xtests/hg-incremental.teardown21
-rwxr-xr-xtests/hg-single-commit.teardown21
-rwxr-xr-xtests/hg-unnamed-head.script52
-rwxr-xr-xtests/hg-unnamed-head.setup58
-rw-r--r--tests/hg-unnamed-head.stdout7
-rwxr-xr-xtests/hg-unnamed-head.teardown21
9 files changed, 285 insertions, 0 deletions
diff --git a/tests/hg-incremental.script b/tests/hg-incremental.script
new file mode 100755
index 0000000..16ca350
--- /dev/null
+++ b/tests/hg-incremental.script
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Tests incremental conversion of a simple hg repository to git.
+#
+# Copyright (C) 2012, 2020 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -e
+
+repo="$DATADIR/hg-test-repo"
+
+logfile="$DATADIR/hg-test-repo.log"
+workdir="$DATADIR/work-dir"
+
+"${SRCDIR}/test-lorry" --verbose --pull-only --log="$logfile" --working-area="$workdir" \
+ "$DATADIR/hg-test-repo.lorry" > /dev/null 2> /dev/null
+
+# make a second commit
+(
+ cd "$repo"
+ echo "second line" >> test.txt
+ hg commit --user lorry-test-suite --quiet -m "second commit"
+)
+
+"${SRCDIR}/test-lorry" --verbose --pull-only --log="$logfile" --working-area="$workdir" \
+ "$DATADIR/hg-test-repo.lorry" > /dev/null 2> /dev/null
+
+# verify that the git repository was created correctly
+(
+ cd "$workdir/hg-test-repo/git/"
+
+ # list the branches
+ git show-ref | cut -d' ' -f2
+
+ # cat the test file
+ git cat-file blob master:test.txt
+
+ # list the commit messages
+ git log --pretty='%s' master
+)
diff --git a/tests/hg-incremental.setup b/tests/hg-incremental.setup
new file mode 100755
index 0000000..1f965b3
--- /dev/null
+++ b/tests/hg-incremental.setup
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# Tests incremental conversion of a simple hg repository to git.
+#
+# Copyright (C) 2012 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -e
+
+# create the repository
+repo="$DATADIR/hg-test-repo"
+mkdir "$repo"
+cd "$repo"
+hg init --quiet
+
+# add the test file
+echo "first line" > test.txt
+hg add --quiet test.txt
+
+# make a commit
+hg commit --user lorry-test-suite --quiet -m "first commit"
+
+# create the .lorry file for the repository
+cat <<EOF > $DATADIR/hg-test-repo.lorry
+{
+ "hg-test-repo": {
+ "type": "hg",
+ "url": "file://$repo"
+ }
+}
+EOF
+
+# create the working directory
+test -d "$DATADIR/work-dir" || mkdir "$DATADIR/work-dir"
diff --git a/tests/hg-incremental.stdout b/tests/hg-incremental.stdout
new file mode 100644
index 0000000..dffabe8
--- /dev/null
+++ b/tests/hg-incremental.stdout
@@ -0,0 +1,5 @@
+refs/heads/master
+first line
+second line
+second commit
+first commit
diff --git a/tests/hg-incremental.teardown b/tests/hg-incremental.teardown
new file mode 100755
index 0000000..409c26b
--- /dev/null
+++ b/tests/hg-incremental.teardown
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# Tests incremental conversion of a simple hg repository to git.
+#
+# Copyright (C) 2020 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+rm -rf "$DATADIR/hg-test-repo" "$DATADIR/hg-test-repo.lorry" "$DATADIR/work-dir"
diff --git a/tests/hg-single-commit.teardown b/tests/hg-single-commit.teardown
new file mode 100755
index 0000000..5a6aa57
--- /dev/null
+++ b/tests/hg-single-commit.teardown
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# Tests converting a simple hg repository to git.
+#
+# Copyright (C) 2020 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+rm -rf "$DATADIR/hg-test-repo" "$DATADIR/hg-test-repo.lorry" "$DATADIR/work-dir"
diff --git a/tests/hg-unnamed-head.script b/tests/hg-unnamed-head.script
new file mode 100755
index 0000000..512938f
--- /dev/null
+++ b/tests/hg-unnamed-head.script
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# Regression test for https://gitlab.com/CodethinkLabs/lorry/lorry/-/issues/7
+#
+# Copyright (C) 2012, 2020 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -e
+
+
+logfile="$DATADIR/hg-test-repo.log"
+workdir="$DATADIR/work-dir"
+
+"${SRCDIR}/test-lorry" --verbose --pull-only --log="$logfile" --working-area="$workdir" \
+ "$DATADIR/hg-test-repo.lorry" > /dev/null 2> /dev/null
+grep -o 'pruned [0-9]* unreachable commit' < "$logfile" || true
+
+# verify that the git repository was created correctly
+(
+ cd "$workdir/hg-test-repo/git/"
+
+ # check number of commits generated
+ wc -l hg2git-marks
+
+ # list the branches
+ git show-ref | cut -d' ' -f2
+
+ # cat the test file
+ git cat-file blob master:test.txt
+
+ # list the commit messages
+ git log --pretty='%s' master
+)
+
+# check that we can another incremental conversion succeeds, and
+# that this involves pruning an unreachable commit
+"${SRCDIR}/test-lorry" --verbose --pull-only --log="$logfile" --working-area="$workdir" \
+ "$DATADIR/hg-test-repo.lorry" > /dev/null 2> /dev/null
+grep -o 'pruned [0-9]* unreachable commit' < "$logfile"
diff --git a/tests/hg-unnamed-head.setup b/tests/hg-unnamed-head.setup
new file mode 100755
index 0000000..31105f5
--- /dev/null
+++ b/tests/hg-unnamed-head.setup
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# Regression test for https://gitlab.com/CodethinkLabs/lorry/lorry/-/issues/7
+#
+# Copyright (C) 2012, 2020 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -e
+
+# create the repository
+repo="$DATADIR/hg-test-repo"
+mkdir "$repo"
+cd "$repo"
+hg init --quiet
+
+# add the test file
+echo "first line" > test.txt
+hg add --quiet test.txt
+
+# make a commit
+hg commit --user lorry-test-suite --quiet -m "first commit"
+
+base=$(hg id -n)
+
+# make a second commit
+echo "second line" >> test.txt
+hg commit --user lorry-test-suite --quiet -m "second commit"
+
+# make a third, divergent, commit
+hg update -r$base
+echo "third line" >> test.txt
+hg commit --user lorry-test-suite --quiet -m "third commit"
+
+# create the .lorry file for the repository
+cat <<EOF > $DATADIR/hg-test-repo.lorry
+{
+ "hg-test-repo": {
+ "type": "hg",
+ "url": "file://$repo"
+ }
+}
+EOF
+
+# create the working directory
+test -d "$DATADIR/work-dir" || mkdir "$DATADIR/work-dir"
diff --git a/tests/hg-unnamed-head.stdout b/tests/hg-unnamed-head.stdout
new file mode 100644
index 0000000..029b454
--- /dev/null
+++ b/tests/hg-unnamed-head.stdout
@@ -0,0 +1,7 @@
+3 hg2git-marks
+refs/heads/master
+first line
+third line
+third commit
+first commit
+pruned 1 unreachable commit
diff --git a/tests/hg-unnamed-head.teardown b/tests/hg-unnamed-head.teardown
new file mode 100755
index 0000000..8b8cee1
--- /dev/null
+++ b/tests/hg-unnamed-head.teardown
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# Regression test for https://gitlab.com/CodethinkLabs/lorry/lorry/-/issues/7
+#
+# Copyright (C) 2020 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+rm -rf "$DATADIR/hg-test-repo" "$DATADIR/hg-test-repo.lorry" "$DATADIR/work-dir"