4 # stg-cvs - helper script to manage a mixed cvs/stgit working copy.
6 # Allows quick synchronization of a cvs mirror branch (does not try to
7 # reconstruct patchsets, creates "jumbo" commits), and commits stgit
10 # Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
11 # Subject to the GNU GPL, version 2.
14 # - you want to add a "CVS" line to .git/info/exclude
15 # - you may want to add a ".git" line to the top .cvsignore
18 # - ensure the cvs wc is clean (eg. with "cvsco")
20 # $ echo CVS >> .git/info/exclude
22 # $ git commit -m "Initial import."
23 # $ git branch -m master cvs
24 # $ stg branch -c master cvs
25 # $ git config branch.master.stgit.parentbranch cvs (0.12.1 and earlier only)
26 # $ git config branch.cvs.description "CVS $(cat CVS/Root) $(cat CVS/Repository) $(cat CVS/Tag 2>/dev/null | echo HEAD)"
27 # $ git config branch.master.description "Changes for $(cat CVS/Repository) $(cat CVS/Tag 2>/dev/null | echo HEAD)"
30 # - this is only a proof-of-concept prototype
31 # - lacks an "init" command (see above)
32 # - "commit" does not ensure the base is uptodate before trying to
33 # commit (but hey, it's CVS ;): better "stg-cvs pull" first
34 # - "commit" can only commit a single patch
35 # - not much robustness here
36 # - still no support for files removed in cvs (should catch "no
37 # longer in the repository" message)
38 # - this only deals with CVS but could surely be extended to any other
40 # - lacks synchronisation of .cvsignore <-> .gitignore
41 # - no support for filenames with spaces (stg lacks --zero output format)
42 # - git-commit is too chatty when it finds nothing to commit
43 # - lacks a "quick cvs commit" feature
46 # - while fetching, if a file change was not git-update-index'd when
47 # cvs-update'd (eg. because of a stg-cvs bug), it is not seen on further
48 # fetches until it changes again, since we scan "cvs update" output.
49 # This yields possible inconsistencies with CVS.
50 # - similarly, any conflict while cvs-updating (whether due to illegal
51 # changes to the cvs-mirror-branch, or due to files added to cvs but
52 # already-existing in working copy, or to directory moves inside the
53 # cvs repository, or <fill here>) has to be dealt with by hand (although
54 # the situation is better here: cvs sees the conflict on subsequent tries)
55 # - bad/no support for cvsutils:
56 # - stg push/pop operations confuse cvsu because of timestamp changes
57 # - cvspurge/cvsco would nuke .git => does not make it easy to ensure
59 # - should use a separate workspace for cvs branch like tailor does
60 # - confused by cvs keyword substitution
64 [ "$#" = 0 ] ||
echo "ERROR: $*"
65 echo "Usage: $(basename $0) <command>"
66 echo " commands: $(do_commands)"
72 echo $
(grep '^[a-z-]*)' $0 | cut
-d')' -f1)
83 # record changes from cvs into index
84 stg branch
"$parent" ||
exit $?
85 cvs
-fq update
-dP |
grep -v '^\? ' |
tee /dev
/tty |
while read status path
; do
86 if [ -e "$path" ]; then
87 git update-index
--add "$path" ||
exit $?
89 git update-index
--remove "$path" ||
exit $?
91 # cvs update: `FELIN1_PEP/src/java/com/sagem/felin/ui/widget/PEPRifStateIcon.java' is no longer in the repository
95 if git commit
-m "stg-cvs sync"; then
102 stg branch
"$branch" ||
exit $?
109 local parent
=$
(dirname "$1")
110 if [ ! -e "$parent/CVS" ]; then
111 cvs_add_dir
"$parent"
119 parent
=$
(git-config
"branch.${branch}.stgit.parentbranch") ||
120 usage
"no declared parent for '$branch' - set branch.${branch}.stgit.parentbranch"
124 [ "$#" -ge 1 ] || usage
130 do_fetch
"$parent" "$branch"
134 if do_fetch
"$parent" "$branch"; then
144 [ $
(stg applied |
wc -l) = 1 ] ||
145 usage
"you don't have exactly one patch applied"
151 stg files |
grep ^A | cut
-c3- |
while read file; do
152 parent
=$
(dirname "$file")
153 if [ ! -e "$parent/CVS" ]; then
154 cvs_add_dir
"$parent"
160 stg files |
grep ^D | cut
-c3- |
xargs -r cvs
-f remove
163 stg files
--bare |
xargs -r cvs
-fq commit \
164 -F ".git/patches/$branch/patches/$patch/description"
166 # sync the parent branch
168 git-cherry-pick
"patches/${branch}/${patch}"
169 stg branch
"${branch}"
178 # hint for bash-completion people :)
183 usage
"unknown command '$command'"