Re: [gentoo-portage-dev] [PATCH] Colorize packages in user sets (bug 577720)

2016-04-18 Thread Zac Medico
On 04/18/2016 01:14 PM, Adam Mills wrote:
> Thanks for all the feedback so far. I probably should have just filed
> the bug
> and left it at that, but I'm committed now.
> 
> I've done my best to incorporate all of the suggestions here, and
> submitted a
> new patch rev 3. I have a few questions about details I'm pretty sure still
> need improvement:
> 
> 1) In order to build the InternalPackageSet only once, I used the
>   _DisplayConfig target_root, instead of using pkg.root in the check_sets
>   method. I'm not sure of the pkg.root purpose, but if there can be
> different
>   roots, the InternalPackageSet would have to be created for each package.
>   If that's the case, it could be moved to the check_sets method, and
> created
>   for each package.

You should create the InternalPackageSet for each root, since each root
has its own package sets.

> 2) I added the new InternalPackageSet as a new member of the _DisplayConfig
>   class. Let me know if there's somewhere more appropriate, especially
> after
>   the feedback from #1.

I guess that's fine, since we're not using it anywhere else.

> 3) Is there a better method available for merging PackageSets?

Yes, you should add all of the atoms to it at once, because each update
calls _updateAtomMap which is expensive. For example, use something like
this:

user_sets =
InternalPackageSet(initial_atoms=itertools.chain.from_iterable(pkgset.getAtoms()
for pkgset in pkgsets if pkgset.user_set))
-- 
Thanks,
Zac



Re: [gentoo-portage-dev] [PATCH] Colorize packages in user sets (bug 577720)

2016-04-18 Thread Adam Mills
Thanks for all the feedback so far. I probably should have just filed 
the bug

and left it at that, but I'm committed now.

I've done my best to incorporate all of the suggestions here, and 
submitted a
new patch rev 3. I have a few questions about details I'm pretty sure 
still

need improvement:

1) In order to build the InternalPackageSet only once, I used the
  _DisplayConfig target_root, instead of using pkg.root in the 
check_sets
  method. I'm not sure of the pkg.root purpose, but if there can be 
different
  roots, the InternalPackageSet would have to be created for each 
package.
  If that's the case, it could be moved to the check_sets method, and 
created

  for each package.

2) I added the new InternalPackageSet as a new member of the 
_DisplayConfig
  class. Let me know if there's somewhere more appropriate, especially 
after

  the feedback from #1.

3) Is there a better method available for merging PackageSets?

Thanks,
Adam




Re: [gentoo-portage-dev] [PATCH] Colorize packages in user sets (bug 577720)

2016-04-18 Thread Alexander Berntsen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On 20/03/16 15:33, Adam Mills wrote:
> + def isUserSet(self): +  return False +
Furthermore, this makes no sense and needs to go.

- -- 
Alexander
berna...@gentoo.org
https://secure.plaimi.net/~alexander
-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iQIcBAEBCgAGBQJXFH22AAoJENQqWdRUGk8Bjx0P/22kcx+y/MulWUDHl31kIKoG
T1WqdW4dqDv/1xGCFvpAQWX8w04cHRs2AxzKWdWNWqDi53LAAHaRMX/8VhxoV/3Y
zQtZfeT7CFfX5Mtn5NLVG5C6/Xvemo2NjKSQqF76TH+CUUVDCr1lP73kned/vwV4
Hj4JNgrQamsMpzdsmU/UvyHClh9rvLwulc3+7vIaaY9UB5wUDsVJfs7MwtO0xEau
7YnAv6gvm501JDxrFyzes8524ghPBsQmoVLaDTpEl+ilF+k3qEdJ8vZJ7bth+FUC
qvjpjI4hZf09SBI6z5MfnXTepyjL8iqV4+l28jjm3JWDMYVrKCbjGAnMllUH3bZD
gYQBCKzqCsdwgA3THHESMJnHGxcmMymaBbqUzqYobvPjNSgsdPOmG9bNoZxlbVJu
TMtNuHQQKxkn7/UeEHvCE6XGPcLLzGD7fxYlj18LyXfbI8LnZAK9bcX45jK3dWGp
LCp/S0M9fgox1wkUWy8TU7DFwM5MQ9q9ZmmfhaAuPS37Zt08TiUf6HEz8R21y24/
eanNTHPrL18CqFkBRrXqBFLIFuYF+fUH+wEZ6gWVBUxTj/IH/U4PnlKRFlwbFP9o
Txs9VETI10Z2vilAUwyhP3uQa4pfsGH6RDkUFKFJt3TPPneOPKlNh7VFeQP23EMk
TtowE5+ZvgYh5e/juBxU
=eHbc
-END PGP SIGNATURE-



Re: [gentoo-portage-dev] [PATCH] Colorize packages in user sets (bug 577720)

2016-04-16 Thread Zac Medico
On 04/16/2016 09:51 AM, Zac Medico wrote:
> On 03/29/2016 01:35 AM, Alexander Berntsen wrote:
>> On 20/03/16 15:33, Adam Mills wrote:
>>> +   for set_name in root_config.sets:
>>> +   if set_name == "system":
>>> +   system = 
>>> root_config.sets[set_name].findAtomForPackage(
>>> +   pkg, 
>>> modified_use=self.conf.pkg_use_enabled(pkg))
>>> +   elif set_name == "selected":
>>> +   world = 
>>> root_config.sets[set_name].findAtomForPackage(
>>> +   pkg, 
>>> modified_use=self.conf.pkg_use_enabled(pkg))
>>> +   elif user_set is None and 
>>> root_config.sets[set_name].isUserSet():
>>> +   user_set = 
>>> root_config.sets[set_name].findAtomForPackage(
>>> +   pkg, 
>>> modified_use=self.conf.pkg_use_enabled(pkg))
>> This is really silly. At the very least try to not repeat yourself so
>> much.
> 
> In order to avoid the loop, all of the user sets could be combined into
> a single InternalPackageSet instance, for indexing purposes.

To clarify, a combined user sets InternalPackageSet instance will
convert this from a O(N) sequential search loop to a O(1) hash table lookup.
-- 
Thanks,
Zac



Re: [gentoo-portage-dev] [PATCH] Colorize packages in user sets (bug 577720)

2016-04-16 Thread Zac Medico
On 03/29/2016 01:35 AM, Alexander Berntsen wrote:
> On 20/03/16 15:33, Adam Mills wrote:
>> +for set_name in root_config.sets:
>> +if set_name == "system":
>> +system = 
>> root_config.sets[set_name].findAtomForPackage(
>> +pkg, 
>> modified_use=self.conf.pkg_use_enabled(pkg))
>> +elif set_name == "selected":
>> +world = 
>> root_config.sets[set_name].findAtomForPackage(
>> +pkg, 
>> modified_use=self.conf.pkg_use_enabled(pkg))
>> +elif user_set is None and 
>> root_config.sets[set_name].isUserSet():
>> +user_set = 
>> root_config.sets[set_name].findAtomForPackage(
>> +pkg, 
>> modified_use=self.conf.pkg_use_enabled(pkg))
> This is really silly. At the very least try to not repeat yourself so
> much.

In order to avoid the loop, all of the user sets could be combined into
a single InternalPackageSet instance, for indexing purposes.

As is, the logic is wrong because the user_set should be an accumulator,
assigned with an operator like |= since you don't what this variable to
toggle back and forth in the loop.

> The patch otherwise looks OK, and the idea is OK by me. Unless someone
> has any big objections, I can probably merge a cleaned up patch.

As discussed in the meeting today, the above loop needs to be fixed
before we can merge this.
-- 
Thanks,
Zac



Re: [gentoo-portage-dev] [PATCH] Colorize packages in user sets (bug 577720)

2016-03-29 Thread Alexander Berntsen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On 20/03/16 15:33, Adam Mills wrote:
> + for set_name in root_config.sets:
> + if set_name == "system":
> + system = 
> root_config.sets[set_name].findAtomForPackage(
> + pkg, 
> modified_use=self.conf.pkg_use_enabled(pkg))
> + elif set_name == "selected":
> + world = 
> root_config.sets[set_name].findAtomForPackage(
> + pkg, 
> modified_use=self.conf.pkg_use_enabled(pkg))
> + elif user_set is None and 
> root_config.sets[set_name].isUserSet():
> + user_set = 
> root_config.sets[set_name].findAtomForPackage(
> + pkg, 
> modified_use=self.conf.pkg_use_enabled(pkg))
This is really silly. At the very least try to not repeat yourself so
much.

The patch otherwise looks OK, and the idea is OK by me. Unless someone
has any big objections, I can probably merge a cleaned up patch.
- -- 
Alexander
berna...@gentoo.org
https://secure.plaimi.net/~alexander
-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iQIcBAEBCgAGBQJW+j5tAAoJENQqWdRUGk8BKpYP/iG5tLtEv7Zf7AbPOj4Dkt1V
t25DMqUU0+uq3Wu0AsUsGYxg8K4dFMZ3+t54w4aykF5/lGNz/cz+O1NFy7WgQ/Y4
9pxkPIQ8py9FX8uh4Hm5/fplBJ5RP1CvvftLeImpKx/B2GTqtLDx0EYehfqRqWNa
2Hx6TE1GH3bbvQgJpl65L4c30JfIBP4pcW95EzUc4XFE87KV0abFFsPLc8sEewp8
NXDDvLZnC+8+BKlLuhyZArxfDp02kQWLd7ho3Uq1rB1LVTUCbxLkV8F9UHtCX9/w
XyyGkg/Xe4Ev1oLcMuEGWGcoQDdLA03CrTzZ59TYIrP2+/0EBCXfNPSy9SLehIew
N+RpgRqc6ecRVq4Nm5NbHfcYmieSKIJD9KPlLqFOShdLEn92gZp2syKkKd+R5JwE
voKVGMgAiJinZkNtwp/j4wgCoLf++I4FJ4BOWAkc7gkKOaDT7UnK2q3M9n6DTNtP
kbyB0cRMSbyMN75vLi2LdB37xC7a2aWCNUi0ssL183bocxhtcRUCxpUsA+dRnGWP
dKCoMzoYVcEARxbzukoJ1vuF+GN+tMoIHfAaXiAhTkwENn+s64b3pYy7tDRBjLxt
Wi3Fvh9h2ipU42wc0p8puZmT9v+60rcUKbNCjLQD9lEX9nh6bR91gB7FlPzU/ss8
Kqz55vBVouA/Fwkn+qZi
=TBB6
-END PGP SIGNATURE-



[gentoo-portage-dev] [PATCH] Colorize packages in user sets (bug 577720)

2016-03-20 Thread Adam Mills
Three new settings were added to /etc/portage/color.map:
PKG_MERGE_USER_SET, PKG_BINARY_MERGE_USER_SET, and
PKG_NOMERGE_USER_SET. These colors are applied when the package is
selected from a set in /etc/portage/sets/

X-Gentoo-bug: 577720
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=577720
---
 man/color.map.5| 11 ++
 pym/_emerge/resolver/output.py | 39 ++
 pym/_emerge/resolver/output_helpers.py |  8 ---
 pym/portage/_sets/base.py  |  3 +++
 pym/portage/_sets/files.py |  3 +++
 pym/portage/output.py  | 39 ++
 6 files changed, 68 insertions(+), 35 deletions(-)

diff --git a/man/color.map.5 b/man/color.map.5
index 5543628..39f23f7 100644
--- a/man/color.map.5
+++ b/man/color.map.5
@@ -46,6 +46,9 @@ Defines color used for satisfied blockers.
 \fBPKG_MERGE\fR = \fI"darkgreen"\fR
 Defines color used for packages planned to be merged.
 .TP
+\fBPKG_MERGE_USER_SET\fR = \fI"darkgreen"\fR
+Defines color used for packages planned to be merged from a user defined set.
+.TP
 \fBPKG_MERGE_SYSTEM\fR = \fI"darkgreen"\fR
 Defines color used for system packages planned to be merged.
 .TP
@@ -55,6 +58,10 @@ Defines color used for world packages planned to be merged.
 \fBPKG_BINARY_MERGE\fR = \fI"purple"\fR
 Defines color used for packages planned to be merged using a binary package.
 .TP
+\fBPKG_BINARY_MERGE_USER_SET\fR = \fI"purple"\fR
+Defines color used for packages planned to be merged using a binary package
+from a user defined set.
+.TP
 \fBPKG_BINARY_MERGE_SYSTEM\fR = \fI"purple"\fR
 Defines color used for system packages planned to be merged using a binary
 package.
@@ -66,6 +73,10 @@ package.
 \fBPKG_NOMERGE\fR = \fI"darkblue"\fR
 Defines color used for packages not planned to be merged.
 .TP
+\fBPKG_NOMERGE_USER_SET\fR = \fI"darkblue"\fR
+Defines color used for packages not planned to be merged from a user defined
+set.
+.TP
 \fBPKG_NOMERGE_SYSTEM\fR = \fI"darkblue"\fR
 Defines color used for system packages not planned to be merged.
 .TP
diff --git a/pym/_emerge/resolver/output.py b/pym/_emerge/resolver/output.py
index 400617d..4cb8393 100644
--- a/pym/_emerge/resolver/output.py
+++ b/pym/_emerge/resolver/output.py
@@ -271,6 +271,8 @@ class Display(object):
return 
colorize("PKG_BINARY_MERGE_SYSTEM", pkg_str)
elif pkg_info.world:
return 
colorize("PKG_BINARY_MERGE_WORLD", pkg_str)
+   elif pkg_info.user_set:
+   return 
colorize("PKG_BINARY_MERGE_USER_SET", pkg_str)
else:
return colorize("PKG_BINARY_MERGE", 
pkg_str)
else:
@@ -278,6 +280,8 @@ class Display(object):
return colorize("PKG_MERGE_SYSTEM", 
pkg_str)
elif pkg_info.world:
return colorize("PKG_MERGE_WORLD", 
pkg_str)
+   elif pkg_info.user_set:
+   return colorize("PKG_MERGE_USER_SET", 
pkg_str)
else:
return colorize("PKG_MERGE", pkg_str)
elif pkg_info.operation == "uninstall":
@@ -287,6 +291,8 @@ class Display(object):
return colorize("PKG_NOMERGE_SYSTEM", pkg_str)
elif pkg_info.world:
return colorize("PKG_NOMERGE_WORLD", pkg_str)
+   elif pkg_info.user_set:
+   return colorize("PKG_NOMERGE_USER_SET", pkg_str)
else:
return colorize("PKG_NOMERGE", pkg_str)
 
@@ -699,22 +705,27 @@ class Display(object):
return
 
 
-   def check_system_world(self, pkg):
-   """Checks for any occurances of the package in the system or 
world sets
+   def check_sets(self, pkg):
+   """Checks for any occurances of the package in the portage sets
 
@param pkg: _emerge.Package.Package instance
-   @rtype system and world booleans
+   @rtype user_set, system, and world booleans
"""
root_config = self.conf.roots[pkg.root]
-   system_set = root_config.sets["system"]
-   world_set  = root_config.sets["selected"]
-   system = False
-   world = False
+   user_set = None
+   system = None
+   world = None
try:
-   system = system_set.findAtomForPackage(
-   pkg, 
modified_use=self.conf.pkg_use_enabled(pkg))
-   world =