correctly ignore already (un)hold packages
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 11 Feb 2012 17:54:48 +0000 (18:54 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 11 Feb 2012 17:54:48 +0000 (18:54 +0100)
apt-pkg/cacheset.h
cmdline/apt-mark.cc
debian/changelog

index 91d7eec..6f0a0e3 100644 (file)
@@ -191,6 +191,8 @@ public:                                                                     /*{{{*/
                inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
                inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
                inline bool operator==(iterator const &i) const { return _iter == i._iter; };
+               inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; };
+               inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; };
                friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
        };
                                                                        /*}}}*/
@@ -201,7 +203,9 @@ public:                                                                     /*{{{*/
 
        bool empty() const { return _cont.empty(); };
        void clear() { return _cont.clear(); };
+       //FIXME: on ABI break, replace the first with the second without bool
        void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
+       iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); };
        size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); };
        void erase(iterator first, iterator last) { _cont.erase(first, last); };
        size_t size() const { return _cont.size(); };
@@ -507,6 +511,8 @@ public:                                                                     /*{{{*/
                inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
                inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
                inline bool operator==(iterator const &i) const { return _iter == i._iter; };
+               inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; };
+               inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; };
                friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
        };
                                                                        /*}}}*/
@@ -516,7 +522,9 @@ public:                                                                     /*{{{*/
        void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
        bool empty() const { return _cont.empty(); };
        void clear() { return _cont.clear(); };
+       //FIXME: on ABI break, replace the first with the second without bool
        void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
+       iterator& erase(iterator &position, bool) { return 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); };
        size_t size() const { return _cont.size(); };
index b067413..fa4134a 100644 (file)
@@ -220,7 +220,7 @@ bool DoHold(CommandLine &CmdL)
 
    bool const MarkHold = strcasecmp(CmdL.FileList[0],"hold") == 0;
 
-   for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+   for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end();)
    {
       if ((Pkg->SelectedState == pkgCache::State::Hold) == MarkHold)
       {
@@ -228,9 +228,10 @@ bool DoHold(CommandLine &CmdL)
            ioprintf(c1out,_("%s was already set on hold.\n"), Pkg.FullName(true).c_str());
         else
            ioprintf(c1out,_("%s was already not hold.\n"), Pkg.FullName(true).c_str());
-        pkgset.erase(Pkg);
-        continue;
+        Pkg = pkgset.erase(Pkg, true);
       }
+      else
+        ++Pkg;
    }
 
    bool dpkgMultiArch = false;
index fa8f396..d1a3354 100644 (file)
@@ -19,6 +19,7 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
     - ensure that architectures are not added multiple times
   * cmdline/apt-mark.cc:
     - detect if dpkg has multiarch support before calling --set-selections
+    - correctly ignore already (un)hold packages
 
   [ Steve Langasek ]
   * cmdline/apt-get.cc:
@@ -41,7 +42,7 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
   * apt-pkg/contrib/fileutl.h:
     - fix compat with FileFd::OpenDescriptor() in ReadOnlyGzip mode
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 10 Feb 2012 19:33:38 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 11 Feb 2012 18:54:11 +0100
 
 apt (0.8.16~exp12) experimental; urgency=low