[Debtags-commits] [svn] r1492 - central-database/branches/alioth/webfrontend

Enrico Zini enrico at costa.debian.org
Mon Nov 14 20:13:44 UTC 2005


Author: enrico
Date: Mon Nov 14 20:13:43 2005
New Revision: 1492

Modified:
   central-database/branches/alioth/webfrontend/Engine.pm
   central-database/branches/alioth/webfrontend/maint
Log:
Added 'resync' option to maint

Modified: central-database/branches/alioth/webfrontend/Engine.pm
==============================================================================
--- central-database/branches/alioth/webfrontend/Engine.pm	(original)
+++ central-database/branches/alioth/webfrontend/Engine.pm	Mon Nov 14 20:13:43 2005
@@ -986,8 +986,38 @@
 	tie %facets, 'GDBM_File', $FACETS, &GDBM_WRITER, 0664;
 	tie %tags, 'GDBM_File', $TAGS, &GDBM_WRITER, 0664;
 
+	lockdb();
+	$db = retrieve($DEBTAGS);
+
 	resyncPackages($pkgs);
 	resyncVocabulary($vocab);
+
+	# Generate missing special::not-yet-tagged tags
+	for my $pkg (keys %packages)
+	{
+		mkdbpkg($pkg) if (not exists $db->{pkgs}{$pkg});
+		if (not @{$db->{pkgs}{$pkg}{tags}})
+		{
+			my $nyt = 'special::not-yet-tagged';
+			my $nytx = $nyt.'::'.substr($pkg, 0, 1);
+
+			$db->{pkgs}{$pkg}{tags} =
+				[ sort { $a->{name} cmp $b->{name} }
+					(@{$db->{pkgs}{$pkg}{tags}}, mkdbtag($nyt)) ];
+			$db->{tags}{$nyt}{pkgs} =
+				[ sort { $a->{name} cmp $b->{name} }
+					(@{$db->{tags}{$nyt}{pkgs}}, mkdbpkg($pkg)) ];
+
+			$db->{pkgs}{$pkg}{tags} =
+				[ sort { $a->{name} cmp $b->{name} }
+					(@{$db->{pkgs}{$pkg}{tags}}, mkdbtag($nytx)) ];
+			$db->{tags}{$nytx}{pkgs} =
+				[ sort { $a->{name} cmp $b->{name} }
+					(@{$db->{tags}{$nytx}{pkgs}}, mkdbpkg($pkg)) ];
+		}
+	}
+	store $db, $DEBTAGS;
+	unlockdb();
 	
 	untie %packages ;
 	untie %facets ;

Modified: central-database/branches/alioth/webfrontend/maint
==============================================================================
--- central-database/branches/alioth/webfrontend/maint	(original)
+++ central-database/branches/alioth/webfrontend/maint	Mon Nov 14 20:13:43 2005
@@ -7,7 +7,7 @@
 
 sub usage ()
 {
-	print STDERR qq{Usage: $0 init|check|dump|tagcat|patch-from|applypatch
+	print STDERR qq{Usage: $0 init|resync|check|dump|tagcat|patch-from|applypatch
 };
 	exit 1;
 }
@@ -16,11 +16,16 @@
 
 if ($cmd eq 'init')
 {
-	my $pkgs = 'packages';
-	my $vocab = 'vocabulary';
-	my $tags = 'tags';
+	my $pkgs = (shift @ARGV or 'packages');
+	my $vocab = (shift @ARGV or 'vocabulary');
+	my $tags = (shift @ARGV or 'tags');
 
 	Engine::init($pkgs, $vocab, $tags);
+} elsif ($cmd eq 'resync') {
+	my $pkgs = (shift @ARGV or 'packages');
+	my $vocab = (shift @ARGV or 'vocabulary');
+
+	Engine::resync($pkgs, $vocab);
 } elsif ($cmd eq 'check') {
 	Engine::openDB();
 
@@ -79,7 +84,7 @@
 } elsif ($cmd eq 'dump') {
 	Engine::openDB();
 
-	for my $p (Engine::packages())
+	for my $p (sort { $a->name() cmp $b->name() } Engine::packages())
 	{
 		my $ldesc = substr(join(' ', split("\n", ($p->ldesc() or ''))), 0, 60);
 		printf "PKG name %s\n", $p->name();
@@ -87,7 +92,7 @@
 		printf "pkg ldesc %s\n", $ldesc;
 		printf "pkg tags %s\n", join(', ', map { $_->{name} } $p->tags());
 	}
-	for my $f (Engine::facets())
+	for my $f (sort { $a->name() cmp $b->name() } Engine::facets())
 	{
 		my $ldesc = substr(join(' ', split("\n", ($f->ldesc() or ''))), 0, 60);
 		printf "FAC name %s\n", $f->name();
@@ -95,7 +100,7 @@
 		printf "fac ldesc %s\n", $ldesc;
 		printf "fac tags %s\n", join(', ', map { $_->{name} } $f->tags());
 	}
-	for my $t (Engine::tags())
+	for my $t (sort { $a->name() cmp $b->name() } Engine::tags())
 	{
 		my $ldesc = substr(join(' ', split("\n", ($t->ldesc() or ''))), 0, 60);
 		printf "TAG name %s\n", $t->name();



More information about the Debtags-commits mailing list