[Debtags-commits] [svn] r2075 - in tagcoll/2.0: . tagcoll

Enrico Zini enrico at alioth.debian.org
Fri Nov 17 16:08:11 CET 2006


Author: enrico
Date: Fri Nov 17 16:08:10 2006
New Revision: 2075

Modified:
   tagcoll/2.0/   (props changed)
   tagcoll/2.0/tagcoll/patch.tcc
Log:
 r3647 at viaza:  enrico | 2006-11-17 15:53:20 +0100
 When diffing collections, don't ignore the items added in the second collection


Modified: tagcoll/2.0/tagcoll/patch.tcc
==============================================================================
--- tagcoll/2.0/tagcoll/patch.tcc	(original)
+++ tagcoll/2.0/tagcoll/patch.tcc	Fri Nov 17 16:08:10 2006
@@ -93,15 +93,25 @@
 template <class ITEM, class TAG> template<typename COLL1, typename COLL2>
 void PatchList<ITEM, TAG>::addPatch(const COLL1& im1, const COLL2& im2)
 {
+	// FIXME: if I could implement the guarantee that the collection iterators
+	// iterate in sorted item order, then I wouldn't need to extract all the
+	// items of im2
+	std::set<ITEM> im2items = im2.getTaggedItems();
 	for (typename COLL1::const_iterator i1 = im1.begin();
 			i1 != im1.end(); ++i1)
 	{
+		im2items.erase(i1->first);
 		std::set<TAG> ts2 = im2.getTagsOfItem(i1->first);
 		std::set<TAG> added = ts2 - i1->second;
 		std::set<TAG> removed = i1->second - ts2;
 		if (!added.empty() || !removed.empty())
 			addPatch(Patch<ITEM, TAG>(i1->first, added, removed));
 	}
+	for (typename std::set<ITEM>::const_iterator i = im2items.begin();
+			i != im2items.end(); ++i)
+	{
+		addPatch(Patch<ITEM, TAG>(*i, im2.getTagsOfItem(*i), wibble::Empty<TAG>()));
+	}
 }
 
 template <class ITEM, class TAG>



More information about the Debtags-commits mailing list