[Debtags-commits] [svn] r1615 - tagdb
Enrico Zini
enrico at costa.debian.org
Thu Mar 2 10:09:09 UTC 2006
Author: enrico
Date: Thu Mar 2 10:09:09 2006
New Revision: 1615
Modified:
tagdb/process
Log:
Strong redesign after giving quite some more thought to the process
Modified: tagdb/process
==============================================================================
--- tagdb/process (original)
+++ tagdb/process Thu Mar 2 10:09:09 2006
@@ -17,7 +17,7 @@
# Approved
# Changes between subversion and the central database that have been approved
# file: approved/*
-# Hand patches
+# Corrections
# Reverse patch for those changes that have not been approved
# file: corrections/*
@@ -26,18 +26,19 @@
# Downloading
# 1) download from central database
# 2) remove data from those packages that do not exist anymore
-# 3) apply the existing hand patches
+# 3) apply the existing corrections
# 4) save to unchecked
#
# Editing
# 1) extract the subset to edit from the unchecked/svn patch
# 2) invoke editor (repeat as long as needed)
# 3) compare again with the unchecked/svn patch and generate a new addition
-# for approved and hand patches
-# 4) svn += approved
-# 5) central database += hand patches
-# 6) unchecked += hand patches
-# 7) remove editing copy
+# for approved and corrections
+# 4) svn += approved+corrections
+# 5) central database += corrections
+# 6) unchecked += corrections
+# 7) file the approved and corrected patches into the edits archive
+# 8) remove editing copy
#
@@ -57,246 +58,251 @@
# corrections are sent to the central database.
#
-TOCHECK=tags-alioth
-TOCHECK_URL=http://debtags.alioth.debian.org/tags/tags-current.gz
-
-CHECKED=tags
-
+UNCHECKED=tags-unchecked
+SVN=tags
MAINPATCH=patch
-
PATCHDIR=corrections
-
CACHEDIR=cache
-# Rebuild the main patch
-make_mainpatch() {
- echo "Generating the list of valid packages..."
+do_downloads() {
+ UNCHECKED_URL=http://debtags.alioth.debian.org/tags/tags-current.gz
+ ALLPKGS_URL=http://people.debian.org/~enrico/AllPackages.gz
+
mkdir -p $CACHEDIR
+
+ echo "Downloading new unchecked version from $UNCHECKED_URL ..."
+ wget -O- "$UNCHECKED_URL" | gunzip > $CACHEDIR/$UNCHECKED
+
if [ -e $CACHEDIR/AllPackages.gz ] && [ $((`date +%s` - `date +%s -r $CACHEDIR/AllPackages.gz`)) -le 86400 ]
then
# Reuse the existing file if it was downloaded less than one day ago
true
else
- wget -O- http://people.debian.org/~enrico/AllPackages.gz > $CACHEDIR/AllPackages.gz
+ echo "Downloading new version of all packages list..."
+ wget -O- $ALLPKGS_URL > $CACHEDIR/AllPackages.gz
fi
+}
+
+# Rebuild the main patch
+do_cleandata() {
PKGS=`mktemp`
cat $CACHEDIR/AllPackages.gz | gunzip | grep-dctrl -sPackage -n . > $PKGS
- CLEANOLD=`mktemp`
- CLEANNEW=`mktemp`
-
- # Remove from CHECKED the data about packages that are not present in the
- # archive anymore, tags without facets and special::not-yet-tagged*
- ./filterpkgs $PKGS < $CHECKED | tagcoll --remove-unfaceted --remove-tags="special::not-yet-tagged*" copy > $CLEANOLD
- ./filterpkgs $PKGS < $TOCHECK | tagcoll --remove-unfaceted --remove-tags="special::not-yet-tagged*" copy > $CLEANNEW
- tagcoll diff $CLEANOLD $CLEANNEW > $MAINPATCH
- rm $CLEANOLD $CLEANNEW
+ # Remove the data about packages that are not present in the archive
+ # anymore, tags without facets and special::not-yet-tagged*.
+ # In the case of $UNCHECKED, also apply previous corrections.
+
+ ./filterpkgs $PKGS < $CACHEDIR/$UNCHECKED | \
+ tagcoll --remove-unfaceted \
+ --remove-tags="special::not-yet-tagged*" \
+ --patch-with=corrections copy > $CACHEDIR/$UNCHECKED-clean
+
+ ./filterpkgs $PKGS < $SVN | \
+ tagcoll --remove-unfaceted \
+ --remove-tags="special::not-yet-tagged*" copy > $CACHEDIR/$SVN-clean
+ rm $PKGS
}
# Get a new version of the database from the packagebrowser and generate a
# patch for review
do_getnew() {
- echo "Downloading new version from $TOCHECK_URL ..."
- wget -O- "$TOCHECK_URL" | gunzip > $TOCHECK
+ # 1) download from central database
+ do_downloads
+
+ # 2) remove data from those packages that do not exist anymore
+ # 3) apply the existing hand patches
+ # 4) save to unchecked
+ do_cleandata
+}
+
+# Edit a patch file
+# Returns true if the file has been successfully modified
+do_edit() {
+ FILE=${1:?"Usage: do_edit file"}
+ cp $FILE $ORIG
+ vi $FILE
+ diff -q $ORIG $FILE > /dev/null
+ RES=$?
+ rm $ORIG
+ return $RES
+}
+
+# Extract one kind of change from the main patch and verify it by hand
+do_extract_onechange() {
+ # 1) extract the subset to edit from the unchecked/svn patch
+ # file: "editing-{bytag/byfacet}-{facet or tag name}"
+ BIGPATCH=`mktemp`
+ tagcoll diff $CACHEDIR/$SVN-clean $CACHEDIR/$UNCHECKED-clean > $BIGPATCH
+ STATS=`mktemp`
+ ./stattags $MAINPATCH | sort -nr > $STATS
+
+ ANS=""
+ COUNT_SHOW=20
+ while [ -z "$ANS" ]
+ do
+ echo ""
+ echo "Top $COUNT_SHOW changes (`wc -l $STATS | cut -d' ' -f1` in total):"
+ echo ""
+ head -$COUNT_SHOW $STATS | perl -e 'while (<STDIN>) { printf "%2d. %s", ++$count, $_ }'
+ echo ""
+ echo " q. Exit"
+ echo ""
+ echo -n "> "
+ read ANS
+ case $ANS in
+ [0-9]*)
+ ANS="`head -$ANS $STATS | tail -1 | cut -d' ' -f2`"
+ ;;
+ q)
+ rm $BIGPATCH
+ rm $STATS
+ return
+ ;;
+ *)
+ ANS=""
+ esac
+ done
+
+ EDITPATCH="editing-bychange-$ANS"
+ tagcoll --remove-tags="! $ANS" copy $BIGPATCH | grep -v ': $' > $EDITPATCH
+ cp $EDITPATCH orig-$EDITPATCH
+ rm $BIGPATCH
+ rm $STATS
- if [ -d $PATCHDIR ]
+ # 2) invoke editor (repeat as long as needed)
+ #do_edit $EDITPATCH
+}
+
+# Delete an edit and all its related files
+do_delete() {
+ FILE=${1:?"Usage: do_delete file"}
+ if [ ! -f $FILE ]
then
- echo "Applying the existing corrections..."
- TMPCOLL=`mktemp`
- tagcoll --patch-with=$PATCHDIR copy $TOCHECK > $TMPCOLL
- mv $TMPCOLL $TOCHECK
+ echo "$FILE does not exist." >&2
+ return
fi
-
- echo "Rebuilding the main patch"
- make_mainpatch
+ rm $FILE
+ rm orig-$FILE
+ rm corrections-$FILE
+ rm approved-$FILE
}
# Submit the approved changes to the svn repository and the corrections to the
# debtags database
do_submit() {
- if [ ! -d "$PATCHDIR" ] || [ -z "`find $PATCHDIR -type f | grep -v '/sent-'`" ]
+ FILE=${1:?"Usage: do_submit file"}
+ if [ ! -f $FILE ]
then
- echo "No uncommitted patches found" >&2
+ echo "$FILE does not exist." >&2
return
fi
- echo ""
- echo "Changes to submit:"
- echo ""
- (cd $PATCHDIR; ls -l `ls | grep -v '^sent-'`)
- echo ""
- ANS=""
- while [ "$ANS" != quit ]
- do
- echo -n "Should I commit them to svn and submit them to the central database? [Y/n] "
- read ANS
- case "$ANS" in
- n|N)
- ANS=quit
- ;;
- y|Y)
- COMMITMSG=`mktemp`
- echo "Reviewed:" >> $COMMITMSG
- (cd $PATCHDIR && ls | grep -v '^sent-' | sed 's/^/ - /') >> $COMMITMSG
- vi $COMMITMSG
- ANS=""
- GO=no
- while [ "$ANS" != quit ]
- do
- echo -n "Finally send? [Y/n/e] "
- read ANS
- case "$ANS" in
- n|N)
- ANS=quit
- GO=no
- ;;
- y|Y)
- ANS=quit
- GO=yes
- ;;
- e|E)
- vi $COMMITMSG
- ANS=""
- ;;
- esac
- done
- if [ "$GO" = yes ]
- then
- svn commit tags --file=$COMMITMSG
- rm $COMMITMSG
- for i in `find $PATCHDIR -type f | grep -v '/sent-'`
- do
- debtags submit $i
- mv $i "$PATCHDIR/sent-`basename $i`"
- done
- echo "Submitted."
- else
- echo "Aborted."
- fi
- ANS=quit
- ;;
- *)
- ANS=""
- ;;
- esac
- done
+ if [ ! -f corrections-$FILE ]
+ then
+ echo "corrections-$FILE does not exist." >&2
+ return
+ fi
+ if [ ! -f approved-$FILE ]
+ then
+ echo "approved-$FILE does not exist." >&2
+ return
+ fi
+
+ # 4) svn += approved+corrections
+ TMP=`mktemp`
+ tagcoll --patch-with=corrections-$FILE copy $SVN > $TMP
+ mv $TMP $SVN
+ tagcoll --patch-with=approved-$FILE copy $SVN > $TMP
+ mv $TMP $SVN
+
+ # 5) central database += corrections
+ debtags submit corrections-$FILE
+
+ # 6) unchecked += corrections
+ tagcoll --patch-with=corrections-$FILE copy $CACHEDIR/$UNCHECKED-clean > $TMP
+ mv $TMP $CACHEDIR/$UNCHECKED-clean
+
+ # 7) file the approved and corrected patches into the edits archive
+ cp corrections-$FILE corrections/`date +%Y%m%s-%H%M%S`-$FILE
+ cp approved-$FILE approved/`date +%Y%m%s-%H%M%S`-$FILE
+
+ # 8) remove editing copy
+ do_delete $FILE
}
-# Edit a patch file and generate accepted changes and corrections from the
-# editing
-do_edit() {
+do_review_edit() {
+ FILE=${1:?"Usage: do_review_edit file"}
ANS=""
- FILE=${1:?"Usage: do_edit file"}
- ORIG=`mktemp`
- CHANGES=""
- cp $FILE $ORIG
- vi $FILE
- while [ "$ANS" != quit ]
+ while [ -z "$ANS" ]
do
- if ! diff -q $ORIG $FILE > /dev/null
- then
- echo "Computing changes..."
- PREV=`mktemp`
- NEXT=`mktemp`
- CHANGES=`mktemp`
- tagcoll --patch-with=$ORIG copy tags > $PREV
- tagcoll --patch-with=$FILE copy tags > $NEXT
- tagcoll diff $PREV $NEXT > $CHANGES
- rm $PREV $NEXT
-
- echo ""
- echo "-- Your changes were: ---------------------"
- cat $CHANGES
- echo "-------------------------------------------"
- echo -n "Do you accept them? [Y/n/q] "
- read ANS
- else
- echo ""
- echo "You made no changes"
- echo -n "Accept the changes as they are? [Y/n/q] "
- read ANS
- fi
- APPLY=no
- case "$ANS" in
- n|N)
+ # 3) compare again with the unchecked/svn patch and generate a new addition
+ # for approved and corrections
+
+ # Compute approved and corrections
+ echo "Computing changes..."
+ PREV=`mktemp`
+ NEXT=`mktemp`
+ # Compute corrections
+ tagcoll --patch-with=orig-$FILE copy $SVN > $PREV
+ tagcoll --patch-with=$FILE copy $SVN > $NEXT
+ tagcoll diff $PREV $NEXT > corrections-$FILE
+ # Compute approvals
+ tagcoll --patch-with=corrections-$FILE copy $SVN > $PREV
+ tagcoll --patch-with=$FILE copy $PREV > $NEXT
+ tagcoll diff $PREV $NEXT > approved-$FILE
+ rm $PREV $NEXT
+
+ # Ask about further actions
+ echo ""
+ echo "Review edits in $FILE (`wc -l $FILE | cut -d ' ' -f 1` lines, `wc -l corrections-$FILE | cut -d ' ' -f 1` corrected, `wc -l approved-$FILE | cut -d ' ' -f 1` approved)"
+ echo ""
+ echo " 1) Edit again"
+ echo " 2) Submit patch"
+ echo " 3) Give up edits and delete the file"
+ echo ""
+ echo " q. Exit"
+ echo ""
+ echo -n "> "
+ read ANS
+ case $ANS in
+ 1)
+ # 2) invoke editor (repeat as long as needed)
vi $FILE
ANS=""
;;
- q|Q)
- echo "Quitting as requested."
- ANS=quit
- ;;
- y|Y)
- APPLY=yes
- ANS=quit
+ 2)
+ do_submit $FILE
;;
- *)
- ANS=""
+ 3)
+ do_delete $FILE
+ ;;
+ q)
+ return
;;
esac
done
+}
+
+# Select an edit to work on
+# Return the name of the file to edit in the variable $EDITPATCH
+do_review_edits() {
+ EDITPATCH=""
- if [ $APPLY = yes ]
+ # If there is only one file being edited, autoselect it
+ if [ `ls editing-* | wc -l` = 1 ]
then
- if [ -z "$CHANGES" ]
- then
- NEWCHECKED=`mktemp`
- tagcoll --patch-with=$FILE copy $CHECKED > $NEWCHECKED
- if [ -s $NEWCHECKED ]
- then
- mv $NEWCHECKED $CHECKED
- else
- rm $NEWCHECKED
- fi
- else
- echo "Applying changes..."
- PATCHNAME=""
- while [ "$PATCHNAME" = "" ]
- do
- echo -n "Please enter a file name for your manual changes: "
- read PATCHNAME
- done
- if [ $PATCHNAME != q ]
- then
- NEWCHECKED=`mktemp`
- tagcoll --patch-with=$FILE copy $CHECKED > $NEWCHECKED
- if [ -s $NEWCHECKED ]
- then
- mv $NEWCHECKED $CHECKED
-
- # Archive the patch
- mkdir -p $PATCHDIR
- cp $CHANGES $PATCHDIR/$PATCHNAME
-
- # Apply the corrections to $TOCHECK
- TMPCOLL=`mktemp`
- tagcoll --patch-with=$CHANGES copy $TOCHECK > $TMPCOLL
- mv $TMPCOLL $TOCHECK
-
- # Rebuild the main patch
- make_mainpatch
- else
- rm $NEWCHECKED
- fi
- fi
- fi
+ EDITPATCH=editing-*
+ echo "Only $EDITPATCH exists: autoselecting it."
+ do_review_edit $EDITPATCH
+ return
fi
-
- rm $ORIG
- test -z "$CHANGES" || rm $CHANGES
-}
-
-# Extract one kind of change from the main patch and verify it by hand
-do_onechange() {
- STATS=`mktemp`
- ANS=""
- COUNT_SHOW=20
- while [ "$ANS" != quit ]
+
+ # Else, ask
+ while [ -z "$EDITPATCH" ]
do
- ./stattags $MAINPATCH | sort -nr > $STATS
echo ""
- echo "Top $COUNT_SHOW changes (`wc -l $STATS | cut -d' ' -f1` in total):"
+ echo "Currently editing `ls editing-* | wc -l` files:"
echo ""
- head -$COUNT_SHOW $STATS | perl -e 'while (<STDIN>) { printf "%2d. %s", ++$count, $_ }'
+ ls editing-* | sort | perl -e 'while (<STDIN>) { printf "%2d. %s", ++$count, $_ }'
echo ""
echo " q. Exit"
echo ""
@@ -304,20 +310,13 @@
read ANS
case $ANS in
[0-9]*)
- CHANGE="`head -$ANS $STATS | tail -1 | cut -d' ' -f2`"
- EDITPATCH=`mktemp`
- tagcoll --remove-tags="! $CHANGE" copy $MAINPATCH > $EDITPATCH
- do_edit $EDITPATCH
- rm $EDITPATCH
- ANS=quit
+ EDITPATCH="`ls editing-* | head -$ANS | tail -1`"
+ do_review_edit $EDITPATCH
;;
q)
- ANS=quit
+ return
;;
- *)
- ANS=""
esac
- rm $STATS
done
}
@@ -341,16 +340,24 @@
echo "---------"
echo ""
echo -n " 1. Download new tags (last download: "
- if [ -e $TOCHECK ]
+ if [ -e $CACHEDIR/$UNCHECKED-clean ]
then
- echo -n "`date -r $TOCHECK`"
+ echo -n "`date -r $CACHEDIR/$UNCHECKED-clean`"
else
echo -n "never"
fi
echo ")"
- echo " 2. Process changes for one facet"
- echo " 3. Process one change"
- echo " 4. Submit changes"
+ echo " 2. Start editing changes for one facet"
+ echo " 3. Start editing one change"
+ EDITCOUNT=`ls editing-* 2>/dev/null|wc -l`
+ case $EDITCOUNT in
+ 0) echo " 4. No editing sessions to resume (disabled)"
+ ;;
+ 1) echo " 4. Resume last editing session (`echo editing-*`)"
+ ;;
+ *) echo " 4. Resume one of the $EDITCOUNT editing sessions"
+ ;;
+ esac
echo " 5. Statistics"
echo ""
echo " q. Exit"
@@ -366,10 +373,11 @@
2) do_onefacet
ANS=""
;;
- 3) do_onechange
+ 3) do_extract_onechange
+ do_review_edit $EDITPATCH
ANS=""
;;
- 4) do_submit
+ 4) test $EDITCOUNT != 0 && do_review_edits
ANS=""
;;
5) do_stats
More information about the Debtags-commits
mailing list