pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

cvs2fossil: put script into files/ for easier editing



Module Name:	pkgsrc-wip
Committed By:	Thomas Klausner <wiz%gatalith.at@localhost>
Pushed By:	wiz
Date:		Wed Jun 28 09:40:46 2023 +0200
Changeset:	d4014d0fc56308c94ed4e1c758981dded2744e8f

Modified Files:
	cvs2fossil/Makefile
	cvs2fossil/files/cvs2fossil.1
Added Files:
	cvs2fossil/files/cvs2fossil

Log Message:
cvs2fossil: put script into files/ for easier editing

Add -f flag to support running an SQL fixup script; intended
to fix timewarp issues.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=d4014d0fc56308c94ed4e1c758981dded2744e8f

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 cvs2fossil/Makefile           |  8 +++-
 cvs2fossil/files/cvs2fossil   | 88 +++++++++++++++++++++++++++++++++++++++++++
 cvs2fossil/files/cvs2fossil.1 | 22 ++++++++++-
 3 files changed, 115 insertions(+), 3 deletions(-)

diffs:
diff --git a/cvs2fossil/Makefile b/cvs2fossil/Makefile
index fb0a8ff376..dae2fd2f3a 100644
--- a/cvs2fossil/Makefile
+++ b/cvs2fossil/Makefile
@@ -10,17 +10,21 @@ COMMENT=	Tool to convert from CVS to fossil
 #LICENSE=	2-clause-bsd AND mit
 
 DEPENDS+=	fossil1-[0-9]*:../../wip/fossil1
+DEPENDS+=	sqlite3-[0-9]*:../../databases/sqlite3
 
 WRKSRC=		${WRKDIR}/cvs2fossil
 
 INSTALLATION_DIRS+=	bin libexec/cvs2fossil ${PKGMANDIR}/man1
 
 SUBST_CLASSES+=		prefix
-SUBST_FILES.prefix=	convert.sh
+SUBST_FILES.prefix=	cvs2fossil
 SUBST_VARS.prefix=	PREFIX
 SUBST_STAGE.prefix=	post-build
 SUBST_MESSAGE.prefix=	Fixing PATH in example file.
 
+post-extract:
+	${CP} ${FILESDIR}/cvs2fossil ${WRKSRC}
+
 do-build:
 	cd ${WRKSRC} && ./build.sh
 
@@ -28,7 +32,7 @@ do-install:
 .for file in 01-import 02-vendorbranches 03-branchtime 04-commit 99-warnings
 	${INSTALL_PROGRAM} ${WRKSRC}/${file}/${file} ${DESTDIR}${PREFIX}/libexec/cvs2fossil
 .endfor
-	${INSTALL_SCRIPT} ${WRKSRC}/convert.sh ${DESTDIR}${PREFIX}/bin/cvs2fossil
+	${INSTALL_SCRIPT} ${WRKSRC}/cvs2fossil ${DESTDIR}${PREFIX}/bin
 	${INSTALL_DATA} ${FILESDIR}/cvs2fossil.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
 
 .include "../../mk/bsd.pkg.mk"
diff --git a/cvs2fossil/files/cvs2fossil b/cvs2fossil/files/cvs2fossil
new file mode 100755
index 0000000000..da2c112ade
--- /dev/null
+++ b/cvs2fossil/files/cvs2fossil
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+set -e
+
+USAGE="usage: $0 [-f fixup-sql-script] [-m] source-cvs-rsync-path target-path"
+fixup=""
+strip=""
+while getopts f:m f
+do
+    case $f in
+	f)      fixup="$OPTARG";;
+        m)      strip=-m;;
+        \?)     echo "$USAGE" >&2; exit 1;;
+    esac
+done
+shift $((OPTIND - 1))
+
+if [ -n "$fixup" ] && [ ! -f "$fixup" ]
+then
+	echo "\"$fixup\" not found" >&2
+	exit 1
+fi
+
+if [ "$#" != 2 ]
+then
+	echo "$USAGE" >&2
+	exit 1
+fi
+
+PATH=@PREFIX@/libexec/cvs2fossil:$PATH
+db="$2"
+repo="$1"
+fossil="$db.fossil"
+
+#
+# If you want the module name itself to be skipped, add -m.
+# Instead of e.g. src/bin/... as path, this will create only bin/...
+#
+time 01-import "$strip" "$db" "$repo"
+oldest=$(echo 'SELECT datetime(r.date,"-1 second") FROM revision r ORDER BY r.date LIMIT 1;' | sqlite3 "$db")
+
+#
+# Check output of "fossil test-timewarp-list --detail" and compare with
+# SELECT revision.date, file.path, revision.revision
+# FROM branchpoints, branches, revision, file
+# WHERE branchpoints.branch=branches.id AND
+#       branchpoints.revision=revision.id AND
+#       branchpoints.file=file.id AND
+#       branches.symbol=XXX
+# ORDER BY revision.date DESC
+#
+# The following command can be used to fix up "cvs add" commands on "broken-branch"
+# matching the timewarp list above. This can be be used if they disturbed the automic
+# branch time computation.
+#
+#sqlite3 $db << EOF
+#DELETE FROM branchpoints WHERE
+#  branch IN (SELECT id FROM branches WHERE symbol="broken-branch") AND
+#  revision IN (SELECT revision.id FROM revision WHERE date > "1998-05-01");
+#EOF
+if [ -n "$fixup" ]
+then
+	echo "Fixing up SQL issues"
+	sqlite3 "$db" < "$fixup"
+fi
+
+time 02-vendorbranches "$db"
+time 03-branchtime "$db"
+rm -f "$fossil"
+fossil1 new -A root --date-override "$oldest" "$fossil"
+# this is a random value used to identify repository groups in
+# fossil. it will complain if you try to pull/push changes across
+# different projects. Use the same value for incremental runs.
+# project=eeb7e06236b08dc4b57b6ab3b957fe5756c64f5b
+# sqlite3 $fossil 'UPDATE config SET value="'$project'" WHERE name="project-code"'
+initial=$(sqlite3 "$fossil" 'SELECT uuid FROM blob WHERE rid=1')
+TMPDIR=. time 04-commit -b "$initial" "$db" "$fossil"
+du -h "$fossil"
+time fossil1 rebuild --noverify "$fossil"
+#TMPDIR=. time sqlite3 $fossil 'pragma synchronous=off; pragma journal_mode=off; vacuum'
+
+echo Checking for possible problems
+99-warnings "$db" || true
+echo End of warnings
+
+echo Checking for timewarp issues
+fossil1 test-timewarp-list --detail -R "$fossil"
+echo End of timewarp issues
diff --git a/cvs2fossil/files/cvs2fossil.1 b/cvs2fossil/files/cvs2fossil.1
index 076db6f034..f28d9f3b9c 100644
--- a/cvs2fossil/files/cvs2fossil.1
+++ b/cvs2fossil/files/cvs2fossil.1
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd June 27, 2023
+.Dd June 28, 2023
 .Dt CVS2FOSSIL 1
 .Os
 .Sh NAME
@@ -35,6 +35,8 @@
 .Nd convert CVS repository to fossil
 .Sh SYNOPSIS
 .Nm
+.Op Fl m
+.Op Fl f Ar fixup-sql-script
 .Ar source
 .Ar destination
 .Sh DESCRIPTION
@@ -57,6 +59,24 @@ database, and
 .Ar destination Ns Pa .fossil ,
 the fossil conversion.
 It will also run some tests on the conversion to report possible problems.
+.Pp
+Supported options:
+.Bl -tag -width 8n
+.It Fl f Ar fixup-sql-script
+Run the SQL code in
+.Ar fixup-sql-script
+early in the conversion.
+This script should be used to fix timewarp issues in the repository.
+See the
+.Nm
+source code for details.
+.It Fl m
+Remove the top-level directory from the imported file paths,
+i.e. when converting
+.Pa foo/bar/*
+the path names in the result will start with
+.Pa bar .
+.El
 .Sh WARNINGS
 These warnings usually indicate that some manual changes were done
 to the RCS files.


Home | Main Index | Thread Index | Old Index