[Debtags-commits] [svn] r2005 - in daemon: . src
Enrico Zini
enrico at costa.debian.org
Thu Oct 5 13:22:00 UTC 2006
Author: enrico
Date: Thu Oct 5 13:22:00 2006
New Revision: 2005
Modified:
daemon/ (props changed)
daemon/src/debtagsd.cpp
Log:
r3513 at viaza: enrico | 2006-10-05 15:21:54 +0200
Allow to return the entire set of packages
Added first bit of handling of patch submission
Modified: daemon/src/debtagsd.cpp
==============================================================================
--- daemon/src/debtagsd.cpp (original)
+++ daemon/src/debtagsd.cpp Thu Oct 5 13:22:00 2006
@@ -11,9 +11,11 @@
#include <wibble/sys/process.h>
#include <wibble/operators.h>
+#include <tagcoll/patch.h>
#include <tagcoll/coll/fast.h>
#include <tagcoll/input/stdio.h>
#include <tagcoll/input/zlib.h>
+#include <tagcoll/input/string.h>
#include <tagcoll/TextFormat.h>
#include <iostream>
@@ -136,6 +138,7 @@
// Read a line
std::string readline()
{
+ // TODO: use a timeout
std::string line;
char c;
while (true)
@@ -231,6 +234,14 @@
else
return i->second;
}
+
+ std::set<std::string> allNames() const
+ {
+ std::set<std::string> res;
+ for (const_iterator i = begin(); i != end(); ++i)
+ res.insert(i->first);
+ return res;
+ }
};
/// The debtagsd daemon process
@@ -295,8 +306,14 @@
if (cmd == "PKGS")
{
+ set<string> pkgs;
set<string> tags = parseTagset(line);
- set<string> pkgs = coll.getItemsHavingTags(tags);
+ if (line.empty())
+ {
+ pkgs = desc.allNames();
+ } else {
+ pkgs = coll.getItemsHavingTags(tags);
+ }
for (set<string>::const_iterator i = pkgs.begin();
i != pkgs.end(); ++i)
outputPackage(*i, conn);
@@ -405,6 +422,32 @@
conn.write("\n");
}
}
+ else if (cmd == "PATCH")
+ {
+ // Read the patch in `buf`
+ string buf;
+ while (true)
+ {
+ string line = conn.readline();
+
+ // End with an empty line
+ if (line.empty()) break;
+
+ buf += line;
+ buf += "\n";
+ }
+
+ // Parse the patch
+ tagcoll::input::String in(buf);
+ tagcoll::PatchList<std::string, std::string> patches =
+ tagcoll::textformat::parsePatch(in);
+
+ // TODO: validate the patch, removing all non existing tags
+
+ coll.applyChange(patches);
+
+ // TODO: save the patch on a file
+ }
else
conn.write("Command not recognized: " + cmd + "\n");
} catch (std::exception& e) {
@@ -417,6 +460,7 @@
{
tagcoll::input::Stdio input(cfg.tagdb);
tagcoll::textformat::parse(input, tagcoll::coll::inserter(coll));
+ // TODO: read in all the saved patches, sorted by filename
}
/// Main loop: wait for connections and dispatch them
More information about the Debtags-commits
mailing list