[Debtags-commits] [svn] r1620 - tagdb

Enrico Zini enrico at costa.debian.org
Thu Mar 2 12:46:29 UTC 2006


Author: enrico
Date: Thu Mar  2 12:46:29 2006
New Revision: 1620

Modified:
   tagdb/process
   tagdb/stattags
Log:
Fixed ranking changes for extract_changes
Fixed generation of filenames for archiving corrections and approvals
Finally implemented do_extract_onefacet


Modified: tagdb/process
==============================================================================
--- tagdb/process	(original)
+++ tagdb/process	Thu Mar  2 12:46:29 2006
@@ -128,14 +128,62 @@
 }
 
 # Extract one kind of change from the main patch and verify it by hand
+do_extract_onefacet() {
+	#  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 --facet $BIGPATCH | sort -nr > $STATS
+
+	EDITPATCH=""
+	ANS=""
+	COUNT_SHOW=20
+	while [ -z "$ANS" ]
+	do
+		echo ""
+		echo "Top $COUNT_SHOW facets (`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-byfacet-$ANS"
+	tagcoll --remove-tags="! (+$ANS::* || -$ANS::*)" copy $BIGPATCH | grep -v ': $' > $EDITPATCH
+	cp $EDITPATCH orig-$EDITPATCH
+	rm $BIGPATCH
+	rm $STATS
+
+	#  2) invoke editor (repeat as long as needed)
+	#do_edit $EDITPATCH
+}
+
+# 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
+	./stattags $BIGPATCH | sort -nr > $STATS
 
+	EDITPATCH=""
 	ANS=""
 	COUNT_SHOW=20
 	while [ -z "$ANS" ]
@@ -220,15 +268,14 @@
 	then
 		debtags submit corrections-$FILE
 
-		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 corrections-$FILE corrections/`date +%Y%m%d-%H%M%S`-$FILE
 	fi
 
         #  7) file the approved and corrected patches into the edits archive
-	cp approved-$FILE approved/`date +%Y%m%s-%H%M%S`-$FILE
+	cp approved-$FILE approved/`date +%Y%m%d-%H%M%S`-$FILE
+
+	do_cleandata
 
 	#  8) remove editing copy
 	do_delete $FILE	
@@ -243,24 +290,27 @@
 		#     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
+		if [ $FILE -nt corrections-$FILE ] || [ $FILE -nt approved-$FILE ]
+		then
+			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
+		fi
 		
 		# 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 " 1) Edit"
 		echo " 2) Submit patch"
 		echo " 3) Give up edits and delete the file"
 		echo ""
@@ -375,11 +425,12 @@
 			1) do_getnew
 			   ANS=""
 			   ;;
-			2) do_onefacet
+			2) do_extract_onefacet
+			   test ! -z "$EDITPATCH" && do_review_edit $EDITPATCH
 			   ANS=""
 			   ;;
 			3) do_extract_onechange
-			   do_review_edit $EDITPATCH
+			   test ! -z "$EDITPATCH" && do_review_edit $EDITPATCH
 			   ANS=""
 			   ;;
 			4) test $EDITCOUNT != 0 && do_review_edits

Modified: tagdb/stattags
==============================================================================
--- tagdb/stattags	(original)
+++ tagdb/stattags	Thu Mar  2 12:46:29 2006
@@ -3,17 +3,41 @@
 use strict;
 use warnings;
 
-my $patchfile = (shift @ARGV or 'patch');
+if (@ARGV && $ARGV[0] eq '--facet')
+{
+	shift @ARGV;
+	my $patchfile = (shift @ARGV or 'patch');
 
-open IN, "tagcoll reverse $patchfile | tagcoll copy -x |" or die "Can't get the reverse collection from the patch";
+	open IN, "tagcoll reverse $patchfile | tagcoll copy -x |" or die "Can't get the reverse collection from the patch";
 
-while (<IN>)
-{
-	my ($tag, $pkgs) = split(': ', $_);
-	my @pkgs = split(', ', $pkgs);
-	printf "%d %s\n", scalar(@pkgs), $tag;
-}
+	my %facets;
+	while (<IN>)
+	{
+		my ($tag, $pkgs) = split(': ', $_);
+		my @pkgs = split(', ', $pkgs);
+		$tag =~ s/^[+-](.+?)::.+$/$1/;
+		$facets{$tag} = 0 if not exists $facets{$tag};
+		$facets{$tag} += scalar(@pkgs);
+	}
+	for my $tag (sort { $facets{$b} <=> $facets{$a} } keys %facets)
+	{
+		printf "%d %s\n", $facets{$tag}, $tag;
+	}
+
+	close IN;
+} else {
+	my $patchfile = (shift @ARGV or 'patch');
 
-close IN;
+	open IN, "tagcoll reverse $patchfile | tagcoll copy -x |" or die "Can't get the reverse collection from the patch";
+
+	while (<IN>)
+	{
+		my ($tag, $pkgs) = split(': ', $_);
+		my @pkgs = split(', ', $pkgs);
+		printf "%d %s\n", scalar(@pkgs), $tag;
+	}
+
+	close IN;
+}
 
 exit 0;



More information about the Debtags-commits mailing list