=== modified file 'cmdline/apt-cache.cc'
--- cmdline/apt-cache.cc	2011-02-04 21:56:51 +0000
+++ cmdline/apt-cache.cc	2011-02-18 06:08:25 +0000
@@ -605,6 +605,7 @@
    bool const ShowEnhances = _config->FindB("APT::Cache::ShowEnhances", Important == false);
    bool const ShowOnlyFirstOr = _config->FindB("APT::Cache::ShowOnlyFirstOr", false);
 
+   std::set<std::string> output;
    while (verset.empty() != true)
    {
       pkgCache::VerIterator Ver = *verset.begin();
@@ -612,75 +613,106 @@
       pkgCache::PkgIterator Pkg = Ver.ParentPkg();
       Shown[Pkg->ID] = true;
 
-	 cout << Pkg.FullName(true) << endl;
-
-	 if (RevDepends == true)
-	    cout << "Reverse Depends:" << endl;
-	 for (pkgCache::DepIterator D = RevDepends ? Pkg.RevDependsList() : Ver.DependsList();
-	      D.end() == false; D++)
-	 {
-	    switch (D->Type) {
-	    case pkgCache::Dep::PreDepends: if (!ShowPreDepends) continue; break;
-	    case pkgCache::Dep::Depends: if (!ShowDepends) continue; break;
-	    case pkgCache::Dep::Recommends: if (!ShowRecommends) continue; break;
-	    case pkgCache::Dep::Suggests: if (!ShowSuggests) continue; break;
-	    case pkgCache::Dep::Replaces: if (!ShowReplaces) continue; break;
-	    case pkgCache::Dep::Conflicts: if (!ShowConflicts) continue; break;
-	    case pkgCache::Dep::DpkgBreaks: if (!ShowBreaks) continue; break;
-	    case pkgCache::Dep::Enhances: if (!ShowEnhances) continue; break;
-	    }
-
-	    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));
-		}
-
-	      }
-	    
-	    // 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);
-	       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));
-		}
-	    }
-
-	    if (ShowOnlyFirstOr == true)
-	       while ((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or) ++D;
-	 }
+     cout << Pkg.FullName(true) << endl;
+
+     if (RevDepends == true)
+        cout << "Reverse Depends:" << endl;
+     bool nextAlso = false;
+     output.clear();
+     for (pkgCache::DepIterator D = RevDepends ? Pkg.RevDependsList() : Ver.DependsList();
+          D.end() == false; D++)
+     {
+        string depType = " ";
+        string prefix = "";
+        string pkgName = "";
+        
+        switch (D->Type) {
+        case pkgCache::Dep::PreDepends: if (!ShowPreDepends) continue; break;
+        case pkgCache::Dep::Depends: if (!ShowDepends) continue; break;
+        case pkgCache::Dep::Recommends: if (!ShowRecommends) continue; break;
+        case pkgCache::Dep::Suggests: if (!ShowSuggests) continue; break;
+        case pkgCache::Dep::Replaces: if (!ShowReplaces) continue; break;
+        case pkgCache::Dep::Conflicts: if (!ShowConflicts) continue; break;
+        case pkgCache::Dep::DpkgBreaks: if (!ShowBreaks) continue; break;
+        case pkgCache::Dep::Enhances: if (!ShowEnhances) continue; break;
+        }
+
+        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)
+          {
+             if (nextAlso == true)
+             	 prefix = "|";
+             else
+                nextAlso = true;
+          }
+          else
+          {
+             if (nextAlso == true)
+             {
+                prefix = "|";
+                nextAlso = false;
+             }
+          }
+          
+          // Show the package
+          if (ShowDepType == true)
+             depType = depType + D.DepType() + ": ";
+          if (Trg->VersionList == 0)
+             pkgName = "<" + Trg.FullName(true) + ">";
+          else
+             pkgName = Trg.FullName(true);
+
+          if (Recurse == true && Shown[Trg->ID] == false)
+          {
+             Shown[Trg->ID] = true;
+             verset.insert(APT::VersionSet::FromPackage(CacheFile, Trg, APT::VersionSet::CANDIDATE, helper));
+          }
+        }
+
+        // Display all solutions
+        SPtrArray<pkgCache::Version *> List = D.AllTargets();
+        pkgPrioSortList(*Cache,List);
+        string provides = "";
+        for (pkgCache::Version **I = List; *I != 0; I++)
+        {
+           pkgCache::VerIterator V(*Cache,*I);
+           if (V != Cache->VerP + V.ParentPkg()->VersionList ||
+               V->ParentPkg == D->Package)
+              continue;
+           provides = provides + " " + V.ParentPkg().FullName(true);
+
+           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));
+           }
+        }
+
+        if (ShowOnlyFirstOr == true)
+           while ((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or) ++D;
+
+        if ((output.insert(depType + pkgName)).second == true)
+        {
+           std::string start = " ";
+           if (prefix == "")
+              start += depType;
+           else
+           {
+              start += "   ";
+              prefix += depType;        	     	  
+           }
+           cout << start << prefix << pkgName << provides << endl;
+        }
+        else
+           nextAlso = false;
+     }
    }
 
    for (APT::PackageSet::const_iterator Pkg = helper.virtualPkgs.begin();
-	Pkg != helper.virtualPkgs.end(); ++Pkg)
+    Pkg != helper.virtualPkgs.end(); ++Pkg)
       cout << '<' << Pkg.FullName(true) << '>' << endl;
 
    return true;

