From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: GIT list <git@vger.kernel.org>
Subject: [PATCH 5/5] Add contrib/stg-cvs: helper script to manage a mixed cvs/stgit working copy
Date: Fri, 05 Jan 2007 00:47:03 +0100 [thread overview]
Message-ID: <20070104234703.13580.3781.stgit@gandelf.nowhere.earth> (raw)
In-Reply-To: <20070104233934.13580.17744.stgit@gandelf.nowhere.earth>
This is an early prototype only, use with care, and be sure to read the
LIMITATIONS section in the script comments.
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
contrib/stg-cvs | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 126 insertions(+), 0 deletions(-)
diff --git a/contrib/stg-cvs b/contrib/stg-cvs
new file mode 100755
index 0000000..ee3e7fa
--- /dev/null
+++ b/contrib/stg-cvs
@@ -0,0 +1,126 @@
+#!/bin/bash
+set -e
+
+# stg-cvs - helper script to manage a mixed cvs/stgit working copy.
+
+# Allows quick synchronization of a cvs mirror branch (does not try to
+# reconstruct patchsets, creates "jumbo" commits), and commits stgit
+# patches to CVS.
+
+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
+# Subject to the GNU GPL, version 2.
+
+# LIMITATIONS
+# - this is only a proof-of-concept prototype
+# - lacks an "init" command
+# - "commit" does not "cvs add/remove" any file or dir
+# - "commit" does not ensure the base is uptodate before trying to
+# commit (but hey, it's CVS ;)
+# - "commit" can only commit a single patch
+# - not much robustness here
+# - this only deals with CVS but could surely be extended to any other
+# VCS
+# - stg push/pop operations confuse cvsutils because of timestamp
+# changes
+# - lacks synchronisation of .cvsignore <-> .gitignore
+
+usage()
+{
+ [ "$#" = 0 ] || echo "ERROR: $*"
+ echo "Usage: $(basename $0) <command>"
+ echo " commands: $(do_commands)"
+ exit 1
+}
+
+do_commands()
+{
+ echo $(grep '^[a-z-]*)' $0 | cut -d')' -f1)
+}
+
+do_fetch()
+{
+ local return=0
+ local path
+
+ local parent="$1"
+ local branch="$2"
+
+ # record changes from cvs into index
+ stg branch "$parent"
+ cvs -fq update -dP | grep -v '^\? ' | tee /dev/tty | while read status path; do
+ if [ -e "$path" ]; then
+ git update-index "$path"
+ else
+ git rm "$path"
+ fi
+ done
+
+ # create commit
+ if git commit -m "stg-cvs sync"; then
+ :
+ else
+ return=$?
+ fi
+
+ # back to branch
+ stg branch "$branch"
+
+ return $return
+}
+
+# get context
+branch=$(stg branch)
+parent=$(git-repo-config "stgit.yd.${branch}.parent") ||
+ usage "no declared parent for '$branch' - set stgit.yd.${branch}.parent"
+
+# extract command
+
+[ "$#" -ge 1 ] || usage
+command="$1"
+shift
+
+case "$command" in
+fetch)
+ do_fetch "$parent" "$branch"
+ ;;
+
+pull)
+ if do_fetch "$parent" "$branch"; then
+ # update
+ stg pull --merged . "$parent"
+ stg clean --applied
+ fi
+ ;;
+
+commit)
+ # sanity asserts
+ [ $(stg applied | wc -l) = 1 ] ||
+ usage "you don't have exactly one patch applied"
+
+ # context
+ patch=$(stg top)
+
+ # commit
+ cvs -fq commit \
+ -F ".git/patches/$branch/patches/$patch/description" \
+ $(stg files --bare)
+
+ # sync the parent branch
+ stg branch "$parent"
+ git-cherry-pick "patches/${branch}/${patch}"
+ stg branch "${branch}"
+
+ # update
+ stg pull --merged . "$parent"
+ stg clean --applied
+ ;;
+
+_commands)
+ # hint for bash-completion people :)
+ do_commands
+ ;;
+
+*)
+ usage "unknown command '$command'"
+ ;;
+esac
next prev parent reply other threads:[~2007-01-04 23:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-04 23:39 [PATCH 0/5] My set of stgit companion scripts Yann Dirson
2007-01-04 23:46 ` [PATCH 1/5] Add contrib/stg-show-old: show old version of a patch Yann Dirson
2007-01-04 23:46 ` [PATCH 2/5] Add contrib/stg-whatchanged: look at what would be changed by refreshing Yann Dirson
2007-01-04 23:46 ` [PATCH 3/5] Add contrib/stg-fold-files-from: pick selected changes from a patch above current one Yann Dirson
2007-01-04 23:46 ` [PATCH 4/5] Add contrib/stg-swallow: completely merge an unapplied patch into " Yann Dirson
2007-01-04 23:47 ` Yann Dirson [this message]
2007-01-09 10:21 ` [PATCH 0/5] My set of stgit companion scripts Catalin Marinas
2007-01-09 22:26 ` Yann Dirson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070104234703.13580.3781.stgit@gandelf.nowhere.earth \
--to=ydirson@altern.org \
--cc=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).