Просмотр исходного кода

- provide a {Package,Version}List similar to {Package,Version}Set
* cmdline/apt-{get,cache,mark}.cc:
- use Lists instead of Sets if input order should be preserved for
commands accepting lists of packages, e.g. policy (Closes: #625960)

David Kalnischkies лет назад: 14
Родитель
Сommit
c4cca79156
6 измененных файлов с 146 добавлено и 54 удалено
  1. 99 11
      apt-pkg/cacheset.h
  2. 14 14
      cmdline/apt-cache.cc
  3. 7 7
      cmdline/apt-get.cc
  4. 8 8
      cmdline/apt-mark.cc
  5. 5 1
      debian/changelog
  6. 13 13
      test/integration/Packages-pdiff-usage-new

+ 99 - 11
apt-pkg/cacheset.h

@@ -14,6 +14,7 @@
 #include <list>
 #include <list>
 #include <map>
 #include <map>
 #include <set>
 #include <set>
+#include <list>
 #include <string>
 #include <string>
 #include <iterator>
 #include <iterator>
 
 
@@ -159,8 +160,8 @@ template<class Container> class PackageContainer : public PackageContainerInterf
 	Container _cont;
 	Container _cont;
 public:									/*{{{*/
 public:									/*{{{*/
 	/** \brief smell like a pkgCache::PkgIterator */
 	/** \brief smell like a pkgCache::PkgIterator */
-	class const_iterator : public PackageContainerInterface::const_iterator,
-			       public std::iterator<std::forward_iterator_tag, typename Container::const_iterator> {/*{{{*/
+	class const_iterator : public PackageContainerInterface::const_iterator,/*{{{*/
+			       public std::iterator<std::forward_iterator_tag, typename Container::const_iterator> {
 		typename Container::const_iterator _iter;
 		typename Container::const_iterator _iter;
 	public:
 	public:
 		const_iterator(typename Container::const_iterator i) : _iter(i) {}
 		const_iterator(typename Container::const_iterator i) : _iter(i) {}
@@ -172,22 +173,37 @@ public:									/*{{{*/
 		inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
 		inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
 		friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
 		friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
 	};
 	};
-	// we are not going to allow modify our pkgiterators (it doesn't make sense)…
-	typedef APT::PackageContainer<Container>::const_iterator iterator;
+	class iterator : public PackageContainerInterface::const_iterator,
+			 public std::iterator<std::forward_iterator_tag, typename Container::iterator> {
+		typename Container::iterator _iter;
+	public:
+		iterator(typename Container::iterator i) : _iter(i) {}
+		pkgCache::PkgIterator getPkg(void) const { return *_iter; }
+		inline pkgCache::PkgIterator operator*(void) const { return *_iter; };
+		operator typename Container::iterator(void) const { return _iter; }
+		operator typename PackageContainer<Container>::const_iterator() { return PackageContainer<Container>::const_iterator(_iter); }
+		inline void operator++(void) { ++_iter; };
+		inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
+		inline bool operator==(iterator const &i) const { return _iter == i._iter; };
+		friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
+	};
 									/*}}}*/
 									/*}}}*/
 
 
 	bool insert(pkgCache::PkgIterator const &P) { if (P.end() == true) return false; _cont.insert(P); return true; };
 	bool insert(pkgCache::PkgIterator const &P) { if (P.end() == true) return false; _cont.insert(P); return true; };
 	template<class Cont> void insert(PackageContainer<Cont> const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); };
 	template<class Cont> void insert(PackageContainer<Cont> const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); };
 	void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
 	void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
+
 	bool empty() const { return _cont.empty(); };
 	bool empty() const { return _cont.empty(); };
 	void clear() { return _cont.clear(); };
 	void clear() { return _cont.clear(); };
-	void erase(iterator position) { _cont.erase((typename Container::const_iterator)position); };
+	void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
 	size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); };
 	size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); };
 	void erase(iterator first, iterator last) { _cont.erase(first, last); };
 	void erase(iterator first, iterator last) { _cont.erase(first, last); };
 	size_t size() const { return _cont.size(); };
 	size_t size() const { return _cont.size(); };
 
 
 	const_iterator begin() const { return const_iterator(_cont.begin()); };
 	const_iterator begin() const { return const_iterator(_cont.begin()); };
 	const_iterator end() const { return const_iterator(_cont.end()); };
 	const_iterator end() const { return const_iterator(_cont.end()); };
+	iterator begin() { return iterator(_cont.begin()); };
+	iterator end() { return iterator(_cont.end()); };
 	const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); };
 	const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); };
 
 
 	void setConstructor(Constructor const &by) { ConstructedBy = by; };
 	void setConstructor(Constructor const &by) { ConstructedBy = by; };
@@ -318,7 +334,25 @@ private:								/*{{{*/
 	Constructor ConstructedBy;
 	Constructor ConstructedBy;
 									/*}}}*/
 									/*}}}*/
 };									/*}}}*/
 };									/*}}}*/
+
+template<> template<class Cont> void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(PackageContainer<Cont> const &pkgcont) {
+	for (typename PackageContainer<Cont>::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p)
+		_cont.push_back(*p);
+};
+// these two are 'inline' as otherwise the linker has problems with seeing these untemplated
+// specializations again and again - but we need to see them, so that library users can use them
+template<> inline bool PackageContainer<std::list<pkgCache::PkgIterator> >::insert(pkgCache::PkgIterator const &P) {
+	if (P.end() == true)
+		return false;
+	_cont.push_back(P);
+	return true;
+};
+template<> inline void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(const_iterator begin, const_iterator end) {
+	for (const_iterator p = begin; p != end; ++p)
+		_cont.push_back(*p);
+};
 typedef PackageContainer<std::set<pkgCache::PkgIterator> > PackageSet;
 typedef PackageContainer<std::set<pkgCache::PkgIterator> > PackageSet;
+typedef PackageContainer<std::list<pkgCache::PkgIterator> > PackageList;
 
 
 class VersionContainerInterface {					/*{{{*/
 class VersionContainerInterface {					/*{{{*/
 /** \class APT::VersionContainerInterface
 /** \class APT::VersionContainerInterface
@@ -406,6 +440,13 @@ public:
 					    std::list<Modifier> const &mods,
 					    std::list<Modifier> const &mods,
 					    CacheSetHelper &helper);
 					    CacheSetHelper &helper);
 
 
+
+	static bool FromDependency(VersionContainerInterface * const vci,
+				   pkgCacheFile &Cache,
+				   pkgCache::DepIterator const &D,
+				   Version const &selector,
+				   CacheSetHelper &helper);
+
 protected:								/*{{{*/
 protected:								/*{{{*/
 
 
 	/** \brief returns the candidate version of the package
 	/** \brief returns the candidate version of the package
@@ -425,7 +466,7 @@ protected:								/*{{{*/
 };
 };
 									/*}}}*/
 									/*}}}*/
 template<class Container> class VersionContainer : public VersionContainerInterface {/*{{{*/
 template<class Container> class VersionContainer : public VersionContainerInterface {/*{{{*/
-/** \class APT::PackageContainer
+/** \class APT::VersionContainer
 
 
     Simple wrapper around a container class like std::set to provide a similar
     Simple wrapper around a container class like std::set to provide a similar
     interface to a set of versions as to the complete set of all versions in the
     interface to a set of versions as to the complete set of all versions in the
@@ -446,8 +487,20 @@ public:									/*{{{*/
 		inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
 		inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
 		friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
 		friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
 	};
 	};
-	// we are not going to allow modify our veriterators (it doesn't make sense)…
-	typedef APT::VersionContainer<Container>::const_iterator iterator;
+	class iterator : public VersionContainerInterface::const_iterator,
+			 public std::iterator<std::forward_iterator_tag, typename Container::iterator> {
+		typename Container::iterator _iter;
+	public:
+		iterator(typename Container::iterator i) : _iter(i) {}
+		pkgCache::VerIterator getVer(void) const { return *_iter; }
+		inline pkgCache::VerIterator operator*(void) const { return *_iter; };
+		operator typename Container::iterator(void) const { return _iter; }
+		operator typename VersionContainer<Container>::const_iterator() { return VersionContainer<Container>::const_iterator(_iter); }
+		inline void operator++(void) { ++_iter; };
+		inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
+		inline bool operator==(iterator const &i) const { return _iter == i._iter; };
+		friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
+	};
 									/*}}}*/
 									/*}}}*/
 
 
 	bool insert(pkgCache::VerIterator const &V) { if (V.end() == true) return false; _cont.insert(V); return true; };
 	bool insert(pkgCache::VerIterator const &V) { if (V.end() == true) return false; _cont.insert(V); return true; };
@@ -455,13 +508,15 @@ public:									/*{{{*/
 	void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
 	void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
 	bool empty() const { return _cont.empty(); };
 	bool empty() const { return _cont.empty(); };
 	void clear() { return _cont.clear(); };
 	void clear() { return _cont.clear(); };
-	void erase(iterator position) { _cont.erase((typename Container::const_iterator)position); };
-	size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); };
+	void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
+	size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); };
 	void erase(iterator first, iterator last) { _cont.erase(first, last); };
 	void erase(iterator first, iterator last) { _cont.erase(first, last); };
 	size_t size() const { return _cont.size(); };
 	size_t size() const { return _cont.size(); };
 
 
 	const_iterator begin() const { return const_iterator(_cont.begin()); };
 	const_iterator begin() const { return const_iterator(_cont.begin()); };
 	const_iterator end() const { return const_iterator(_cont.end()); };
 	const_iterator end() const { return const_iterator(_cont.end()); };
+	iterator begin() { return iterator(_cont.begin()); };
+	iterator end() { return iterator(_cont.end()); };
 	const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); };
 	const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); };
 
 
 	/** \brief returns all versions specified on the commandline
 	/** \brief returns all versions specified on the commandline
@@ -520,7 +575,7 @@ public:									/*{{{*/
 		return FromPackage(Cache, P, fallback, helper);
 		return FromPackage(Cache, P, fallback, helper);
 	}
 	}
 	static VersionContainer FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P) {
 	static VersionContainer FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P) {
-		return FromPackage(Cache, P, CANDINST);
+		return FromPackage(Cache, P, CANDIDATE);
 	}
 	}
 
 
 	static std::map<unsigned short, VersionContainer> GroupedFromCommandLine(
 	static std::map<unsigned short, VersionContainer> GroupedFromCommandLine(
@@ -547,8 +602,41 @@ public:									/*{{{*/
 		return GroupedFromCommandLine(Cache, cmdline,
 		return GroupedFromCommandLine(Cache, cmdline,
 				mods, fallback, helper);
 				mods, fallback, helper);
 	}
 	}
+
+	static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D,
+					       Version const &selector, CacheSetHelper &helper) {
+		VersionContainer vercon;
+		VersionContainerInterface::FromDependency(&vercon, Cache, D, selector, helper);
+		return vercon;
+	}
+	static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D,
+					       Version const &selector) {
+		CacheSetHelper helper;
+		return FromPackage(Cache, D, selector, helper);
+	}
+	static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D) {
+		return FromPackage(Cache, D, CANDIDATE);
+	}
 									/*}}}*/
 									/*}}}*/
 };									/*}}}*/
 };									/*}}}*/
+
+template<> template<class Cont> void VersionContainer<std::list<pkgCache::VerIterator> >::insert(VersionContainer<Cont> const &vercont) {
+	for (typename VersionContainer<Cont>::const_iterator v = vercont.begin(); v != vercont.end(); ++v)
+		_cont.push_back(*v);
+};
+// these two are 'inline' as otherwise the linker has problems with seeing these untemplated
+// specializations again and again - but we need to see them, so that library users can use them
+template<> inline bool VersionContainer<std::list<pkgCache::VerIterator> >::insert(pkgCache::VerIterator const &V) {
+	if (V.end() == true)
+		return false;
+	_cont.push_back(V);
+	return true;
+};
+template<> inline void VersionContainer<std::list<pkgCache::VerIterator> >::insert(const_iterator begin, const_iterator end) {
+	for (const_iterator v = begin; v != end; ++v)
+		_cont.push_back(*v);
+};
 typedef VersionContainer<std::set<pkgCache::VerIterator> > VersionSet;
 typedef VersionContainer<std::set<pkgCache::VerIterator> > VersionSet;
+typedef VersionContainer<std::list<pkgCache::VerIterator> > VersionList;
 }
 }
 #endif
 #endif

+ 14 - 14
cmdline/apt-cache.cc

@@ -199,9 +199,9 @@ bool UnMet(CommandLine &CmdL)
    else
    else
    {
    {
       CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
       CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
-      APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1,
-				APT::VersionSet::CANDIDATE, helper);
-      for (APT::VersionSet::iterator V = verset.begin(); V != verset.end(); ++V)
+      APT::VersionList verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1,
+				APT::VersionList::CANDIDATE, helper);
+      for (APT::VersionList::iterator V = verset.begin(); V != verset.end(); ++V)
 	 if (ShowUnMet(V, Important) == false)
 	 if (ShowUnMet(V, Important) == false)
 	    return false;
 	    return false;
    }
    }
@@ -215,9 +215,9 @@ bool DumpPackage(CommandLine &CmdL)
 {
 {
    pkgCacheFile CacheFile;
    pkgCacheFile CacheFile;
    APT::CacheSetHelper helper(true, GlobalError::NOTICE);
    APT::CacheSetHelper helper(true, GlobalError::NOTICE);
-   APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
+   APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
 
 
-   for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+   for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
    {
    {
       cout << "Package: " << Pkg.FullName(true) << endl;
       cout << "Package: " << Pkg.FullName(true) << endl;
       cout << "Versions: " << endl;
       cout << "Versions: " << endl;
@@ -588,7 +588,7 @@ bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
       return false;
       return false;
 
 
    CacheSetHelperVirtuals helper(false);
    CacheSetHelperVirtuals helper(false);
-   APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
+   APT::VersionList verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionList::CANDIDATE, helper);
    if (verset.empty() == true && helper.virtualPkgs.empty() == true)
    if (verset.empty() == true && helper.virtualPkgs.empty() == true)
       return _error->Error(_("No packages found"));
       return _error->Error(_("No packages found"));
    std::vector<bool> Shown(Cache->Head().PackageCount);
    std::vector<bool> Shown(Cache->Head().PackageCount);
@@ -1365,10 +1365,10 @@ bool ShowPackage(CommandLine &CmdL)
 {
 {
    pkgCacheFile CacheFile;
    pkgCacheFile CacheFile;
    CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
    CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
-   APT::VersionSet::Version const select = _config->FindB("APT::Cache::AllVersions", true) ?
-			APT::VersionSet::ALL : APT::VersionSet::CANDIDATE;
-   APT::VersionSet const verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
-   for (APT::VersionSet::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
+   APT::VersionList::Version const select = _config->FindB("APT::Cache::AllVersions", true) ?
+			APT::VersionList::ALL : APT::VersionList::CANDIDATE;
+   APT::VersionList const verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
+   for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
       if (DisplayRecord(CacheFile, Ver) == false)
       if (DisplayRecord(CacheFile, Ver) == false)
 	 return false;
 	 return false;
 
 
@@ -1531,8 +1531,8 @@ bool Policy(CommandLine &CmdL)
 
 
    // Print out detailed information for each package
    // Print out detailed information for each package
    APT::CacheSetHelper helper(true, GlobalError::NOTICE);
    APT::CacheSetHelper helper(true, GlobalError::NOTICE);
-   APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
-   for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+   APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
+   for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
    {
    {
       cout << Pkg.FullName(true) << ":" << endl;
       cout << Pkg.FullName(true) << ":" << endl;
 
 
@@ -1608,8 +1608,8 @@ bool Madison(CommandLine &CmdL)
    for (const char **I = CmdL.FileList + 1; *I != 0; I++)
    for (const char **I = CmdL.FileList + 1; *I != 0; I++)
    {
    {
       _error->PushToStack();
       _error->PushToStack();
-      APT::PackageSet pkgset = APT::PackageSet::FromString(CacheFile, *I, helper);
-      for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+      APT::PackageList pkgset = APT::PackageList::FromString(CacheFile, *I, helper);
+      for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
       {
       {
          for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; ++V)
          for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; ++V)
          {
          {

+ 7 - 7
cmdline/apt-get.cc

@@ -2293,8 +2293,8 @@ bool DoDownload(CommandLine &CmdL)
       return false;
       return false;
    
    
    APT::CacheSetHelper helper(c0out);
    APT::CacheSetHelper helper(c0out);
-   APT::VersionSet verset = APT::VersionSet::FromCommandLine(Cache,
-		CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
+   APT::VersionList verset = APT::VersionList::FromCommandLine(Cache,
+		CmdL.FileList + 1, APT::VersionList::CANDIDATE, helper);
 
 
    if (verset.empty() == true)
    if (verset.empty() == true)
       return false;
       return false;
@@ -2306,7 +2306,7 @@ bool DoDownload(CommandLine &CmdL)
 
 
    pkgRecords Recs(Cache);
    pkgRecords Recs(Cache);
    pkgSourceList *SrcList = Cache.GetSourceList();
    pkgSourceList *SrcList = Cache.GetSourceList();
-   for (APT::VersionSet::const_iterator Ver = verset.begin(); 
+   for (APT::VersionList::const_iterator Ver = verset.begin(); 
         Ver != verset.end(); 
         Ver != verset.end(); 
         ++Ver) 
         ++Ver) 
    {
    {
@@ -3165,14 +3165,14 @@ bool DoChangelog(CommandLine &CmdL)
       return false;
       return false;
    
    
    APT::CacheSetHelper helper(c0out);
    APT::CacheSetHelper helper(c0out);
-   APT::VersionSet verset = APT::VersionSet::FromCommandLine(Cache,
-		CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
+   APT::VersionList verset = APT::VersionList::FromCommandLine(Cache,
+		CmdL.FileList + 1, APT::VersionList::CANDIDATE, helper);
    if (verset.empty() == true)
    if (verset.empty() == true)
       return false;
       return false;
    pkgAcquire Fetcher;
    pkgAcquire Fetcher;
 
 
    if (_config->FindB("APT::Get::Print-URIs", false) == true)
    if (_config->FindB("APT::Get::Print-URIs", false) == true)
-      for (APT::VersionSet::const_iterator Ver = verset.begin();
+      for (APT::VersionList::const_iterator Ver = verset.begin();
 	   Ver != verset.end(); ++Ver)
 	   Ver != verset.end(); ++Ver)
 	 return DownloadChangelog(Cache, Fetcher, Ver, "");
 	 return DownloadChangelog(Cache, Fetcher, Ver, "");
 
 
@@ -3195,7 +3195,7 @@ bool DoChangelog(CommandLine &CmdL)
 	 return _error->Errno("mkdtemp", "mkdtemp failed");
 	 return _error->Errno("mkdtemp", "mkdtemp failed");
    }
    }
 
 
-   for (APT::VersionSet::const_iterator Ver = verset.begin(); 
+   for (APT::VersionList::const_iterator Ver = verset.begin(); 
         Ver != verset.end(); 
         Ver != verset.end(); 
         ++Ver) 
         ++Ver) 
    {
    {

+ 8 - 8
cmdline/apt-mark.cc

@@ -34,14 +34,14 @@ bool DoAuto(CommandLine &CmdL)
    if (unlikely(Cache == NULL || DepCache == NULL))
    if (unlikely(Cache == NULL || DepCache == NULL))
       return false;
       return false;
 
 
-   APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
+   APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1);
    if (pkgset.empty() == true)
    if (pkgset.empty() == true)
       return _error->Error(_("No packages found"));
       return _error->Error(_("No packages found"));
 
 
    bool MarkAuto = strcasecmp(CmdL.FileList[0],"auto") == 0;
    bool MarkAuto = strcasecmp(CmdL.FileList[0],"auto") == 0;
    int AutoMarkChanged = 0;
    int AutoMarkChanged = 0;
 
 
-   for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+   for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
    {
    {
       if (Pkg->CurrentVer == 0)
       if (Pkg->CurrentVer == 0)
       {
       {
@@ -81,7 +81,7 @@ bool DoMarkAuto(CommandLine &CmdL)
    if (unlikely(Cache == NULL || DepCache == NULL))
    if (unlikely(Cache == NULL || DepCache == NULL))
       return false;
       return false;
 
 
-   APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
+   APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1);
    if (pkgset.empty() == true)
    if (pkgset.empty() == true)
       return _error->Error(_("No packages found"));
       return _error->Error(_("No packages found"));
 
 
@@ -89,7 +89,7 @@ bool DoMarkAuto(CommandLine &CmdL)
    bool const Verbose = _config->FindB("APT::MarkAuto::Verbose", false);
    bool const Verbose = _config->FindB("APT::MarkAuto::Verbose", false);
    int AutoMarkChanged = 0;
    int AutoMarkChanged = 0;
 
 
-   for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+   for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
    {
    {
       if (Pkg->CurrentVer == 0 ||
       if (Pkg->CurrentVer == 0 ||
 	  (((*DepCache)[Pkg].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto) == MarkAuto)
 	  (((*DepCache)[Pkg].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto) == MarkAuto)
@@ -157,13 +157,13 @@ bool DoHold(CommandLine &CmdL)
    if (unlikely(Cache == NULL))
    if (unlikely(Cache == NULL))
       return false;
       return false;
 
 
-   APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
+   APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1);
    if (pkgset.empty() == true)
    if (pkgset.empty() == true)
       return _error->Error(_("No packages found"));
       return _error->Error(_("No packages found"));
 
 
    bool const MarkHold = strcasecmp(CmdL.FileList[0],"hold") == 0;
    bool const MarkHold = strcasecmp(CmdL.FileList[0],"hold") == 0;
 
 
-   for (APT::PackageSet::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+   for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
    {
    {
       if ((Pkg->SelectedState == pkgCache::State::Hold) == MarkHold)
       if ((Pkg->SelectedState == pkgCache::State::Hold) == MarkHold)
       {
       {
@@ -181,7 +181,7 @@ bool DoHold(CommandLine &CmdL)
 
 
    if (_config->FindB("APT::Mark::Simulate", false) == true)
    if (_config->FindB("APT::Mark::Simulate", false) == true)
    {
    {
-      for (APT::PackageSet::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+      for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
       {
       {
 	 if (MarkHold == false)
 	 if (MarkHold == false)
 	    ioprintf(c1out,_("%s set on hold.\n"), Pkg.FullName(true).c_str());
 	    ioprintf(c1out,_("%s set on hold.\n"), Pkg.FullName(true).c_str());
@@ -201,7 +201,7 @@ bool DoHold(CommandLine &CmdL)
    if (dpkg == NULL)
    if (dpkg == NULL)
       return _error->Errno("DoHold", "fdopen on dpkg stdin failed");
       return _error->Errno("DoHold", "fdopen on dpkg stdin failed");
 
 
-   for (APT::PackageSet::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+   for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
    {
    {
       if (MarkHold == true)
       if (MarkHold == true)
       {
       {

+ 5 - 1
debian/changelog

@@ -12,8 +12,12 @@ apt (0.8.16~exp8) experimental; urgency=low
   * apt-pkg/cacheset.cc:
   * apt-pkg/cacheset.cc:
     - make the cachesets real containers which can embedding any container
     - make the cachesets real containers which can embedding any container
       to be able to use the same interface regardless of set or list usage
       to be able to use the same interface regardless of set or list usage
+    - provide a {Package,Version}List similar to {Package,Version}Set
+  * cmdline/apt-{get,cache,mark}.cc:
+    - use Lists instead of Sets if input order should be preserved for
+      commands accepting lists of packages, e.g. policy (Closes: #625960)
 
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 09 Nov 2011 17:21:02 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 11 Nov 2011 15:55:13 +0100
 
 
 apt (0.8.16~exp7) experimental; urgency=low
 apt (0.8.16~exp7) experimental; urgency=low
 
 

+ 13 - 13
test/integration/Packages-pdiff-usage-new

@@ -1,16 +1,3 @@
-Package: newstuff
-Version: 1.0
-Architecture: i386
-Maintainer: Joe Sixpack <joe@example.org>
-Installed-Size: 101
-Filename: pool/newstuff_1.0_i386.deb
-Size: 101100
-MD5sum: 311aeeadf78324aaff1ceaf3e1f76671
-SHA1: 3c695e028f7a1ae324deeddaaa1242desa81088c
-SHA256: b46fd154615edefab321cc56a5cc0e7deaef23e2da3e4f129727fd660f28f050
-Description: some cool and shiny new stuff
- This package will appear in the next mirror update
-
 Package: apt
 Package: apt
 Priority: important
 Priority: important
 Section: admin
 Section: admin
@@ -35,3 +22,16 @@ Description: Advanced front-end for dpkg
  .
  .
  APT features complete installation ordering, multiple source capability
  APT features complete installation ordering, multiple source capability
  and several other unique features, see the Users Guide in apt-doc.
  and several other unique features, see the Users Guide in apt-doc.
+
+Package: newstuff
+Version: 1.0
+Architecture: i386
+Maintainer: Joe Sixpack <joe@example.org>
+Installed-Size: 101
+Filename: pool/newstuff_1.0_i386.deb
+Size: 101100
+MD5sum: 311aeeadf78324aaff1ceaf3e1f76671
+SHA1: 3c695e028f7a1ae324deeddaaa1242desa81088c
+SHA256: b46fd154615edefab321cc56a5cc0e7deaef23e2da3e4f129727fd660f28f050
+Description: some cool and shiny new stuff
+ This package will appear in the next mirror update