Bug#335925: apt-cache rdepends shows duplicated reverse dependencies/dependants
I have attached a modified patch
On 2/9/11, Ishan Jayawardena <udeshike@gmail.com> wrote:
> Hi David,
>
> Thank you for your reply. I will look into your suggestions and modify
> it appropriately.
>
> On 2/9/11, David Kalnischkies <kalnischkies+debian@gmail.com> wrote:
>> Hi Ishan,
>>
>> On Tue, Feb 8, 2011 at 16:46, Ishan Jayawardena <udeshike@gmail.com>
>> wrote:
>>> I tried to come up with a fix.
>>
>> First of all, the patch really fixes the issue for rdepends, so you are
>> on
>> the right track, but…
>>
>>> Please find the attached patch and give
>>> me your feedback.
>>
>> * the indent-style is wrong. I know that the indent-style is… lets say
>> strange, but thats how it is and changing it would just destroy the
>> history
>> in the vcs. The style is easiest described by indent with 3 spaces on
>> each
>> curly bracket - but replace 8 consecutive spaces with a tab. You have
>> just
>> used spaces and/or not the tabstop at 8 so your code is various indent-
>> levels higher than the rest which make it harder to read.
>> * The code is reused for the depends command which breaks with your
>> patch.
>> Attached is a testcase you can copy to test/integration in the source
>> tree
>> which will run the tools build in this tree, so you can test your patch
>> without installing anything, you just need to build the tree and run
>> the
>> testcase(s). This will show you the next two things:
>> * You are printing your s string to often (you don't need it, just print
>> it
>> as the code did it before and move the duplication check before it
>> instead)
>> * If the DependencyType is shown you should disable the duplication check
>> as
>> otherwise only one of possible many dependencies is shown.
>>
>> In general, it seems to be a burden at first, but writing a testcase for
>> the
>> issue at hand can save you from a lot of problems later on.
>>
>> Hope that helps.
>>
>>
>> Best regards
>>
>> David Kalnischkies
>>
>
>
> --
> Regards,
> Ishan Jayawardena.
>
--
Regards,
Ishan Jayawardena.
=== modified file 'cmdline/apt-cache.cc'
--- cmdline/apt-cache.cc 2011-02-04 21:56:51 +0000
+++ cmdline/apt-cache.cc 2011-02-09 12:51:15 +0000
@@ -633,45 +633,52 @@
pkgCache::PkgIterator Trg = RevDepends ? D.ParentPkg() : D.TargetPkg();
if((Installed && Trg->CurrentVer != 0) || !Installed)
- {
-
- if ((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or && ShowOnlyFirstOr == false)
- cout << " |";
- else
- cout << " ";
-
- // Show the package
- if (ShowDepType == true)
- cout << D.DepType() << ": ";
- if (Trg->VersionList == 0)
- cout << "<" << Trg.FullName(true) << ">" << endl;
- else
- cout << Trg.FullName(true) << endl;
-
- if (Recurse == true && Shown[Trg->ID] == false)
- {
- Shown[Trg->ID] = true;
- verset.insert(APT::VersionSet::FromPackage(CacheFile, Trg, APT::VersionSet::CANDIDATE, helper));
- }
-
- }
+ {
+ if (Shown[Trg->ID] == false)
+ {
+ if ((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or && ShowOnlyFirstOr == false)
+ cout << " |";
+ else
+ cout << " ";
+
+ // Show the package
+ if (ShowDepType == true)
+ {
+ cout << D.DepType() << ": ";
+ Shown[Trg->ID] = false;
+ }
+ else
+ Shown[Trg->ID] = true;
+ if (Trg->VersionList == 0)
+ cout << "<" << Trg.FullName(true) << ">" << endl;
+ else
+ cout << Trg.FullName(true) << endl;
+ if (Recurse == true)
+ {
+ verset.insert(APT::VersionSet::FromPackage(CacheFile, Trg, APT::VersionSet::CANDIDATE, helper));
+ }
+ }
+
+ }
// Display all solutions
SPtrArray<pkgCache::Version *> List = D.AllTargets();
pkgPrioSortList(*Cache,List);
for (pkgCache::Version **I = List; *I != 0; I++)
{
- pkgCache::VerIterator V(*Cache,*I);
+ pkgCache::VerIterator V(*Cache,*I);
if (V != Cache->VerP + V.ParentPkg()->VersionList ||
- V->ParentPkg == D->Package)
- continue;
- cout << " " << V.ParentPkg().FullName(true) << endl;
-
- if (Recurse == true && Shown[V.ParentPkg()->ID] == false)
- {
- Shown[V.ParentPkg()->ID] = true;
- verset.insert(APT::VersionSet::FromPackage(CacheFile, V.ParentPkg(), APT::VersionSet::CANDIDATE, helper));
- }
+ V->ParentPkg == D->Package)
+ continue;
+ if (Shown[V.ParentPkg()->ID] == false)
+ {
+ cout << " " << V.ParentPkg().FullName(true) << endl;
+ if (Recurse == true)
+ {
+ verset.insert(APT::VersionSet::FromPackage(CacheFile, V.ParentPkg(), APT::VersionSet::CANDIDATE, helper));
+ }
+ Shown[V.ParentPkg()->ID] = true;
+ }
}
if (ShowOnlyFirstOr == true)
Reply to: