Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH 1/2] Add FEATURES=binpkg-multi-instance (bug 150031)
Date: Tue, 17 Feb 2015 19:26:32
Message-Id: 54E395E3.6060500@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH 1/2] Add FEATURES=binpkg-multi-instance (bug 150031) by Brian Dolbec
1 On 02/17/2015 10:42 AM, Brian Dolbec wrote:
2 >
3 > overall, there is no way I know the code well enough to know if you
4 > screwed up. But the code looks decent, so...
5 >
6 > My only questions are:
7 >
8 > pym/portage/dbapi/bintree.py:
9 >
10 > You removed several functions from the binarytree class and essentially
11 > reduced prevent_collision to a warning message. Can you briefly say
12 > why they are not needed please.
13
14 Okay, I'll include this info in an updated patch:
15
16 _pkgindex_cpv_map_latest_build:
17
18 This is what binhost clients running older versions of portage will use
19 to select to select the latest builds when their binhost server switches
20 to FEATURES=binpkg-multi-instance. New portage won't need this anymore
21 because it is capable of examining multiple builds and it uses sorting
22 to ensure that the latest builds are preferred when appropriate.
23
24 _remove_symlink, _create_symlink, prevent_collision, _move_to_all, and
25 _move_from_all:
26
27 These are all related to the oldest PKGDIR layout, which put all of the
28 tbz2 files in $PKGDIR/All, and created symlinks to them in the category
29 directories. The $PKGDIR/All layout should be practically extinct by
30 now. New portage recognizes all existing layouts, or mixtures of them,
31 and uses the old packages in place. It never puts new packages in
32 $PKGDIR/All, so there's no need to move packages around to prevent file
33 name collisions between packages from different categories. It also only
34 uses regular files (any symlinks are ignored).
35
36 > _populate() ==> it is some 500+ LOC nasty. From what I can see I
37 > think you added slightly more loc than you deleted/changed. While I
38 > don't expect a breakup of this function to be directly a part of
39 > this commit.
40 >
41 > IT IS BADLY NEEDED.
42 >
43 > I'd like to see this function properly split into pieces and act as
44 > a driver for the smaller tasks. Currently it is a mess of nested
45 > if/else, for,... that is extremely difficult to keep straight and
46 > make logic changes to. It's almost as bad as repomans 1000+ LOC
47 > main loop. Why "if TRUE:" <== just fix the indent... At the same
48 > time, I noticed _ensure_dirs, _file_permissions functions defined in
49 > that class. Shouldn't these just be util functions available
50 > everywhere.
51
52 Yeah, I will work on cleaning that up, and submit it as a separate patch.
53
54 >
55 >
56 > pym/portage/versions.py
57 >
58 > class _pkg_str(_unicode)
59 >
60 > in __init__()
61 >
62 > if build_time is not None:
63 > try:
64 > build_time = long(build_time)
65 > except ValueError:
66 > if build_time:
67 > build_time = -1
68 > else:
69 > build_time = 0
70 > if build_id is not None:
71 > try:
72 > build_id = long(build_id)
73 > except ValueError:
74 > if build_id:
75 > build_id = -1
76 > else:
77 > build_id = None
78 > if file_size is not None:
79 > try:
80 > file_size = long(file_size)
81 > except ValueError:
82 > if file_size:
83 > file_size = -1
84 > else:
85 > file_size = None
86 > if mtime is not None:
87 > try:
88 > mtime = long(mtime)
89 > except ValueError:
90 > if mtime:
91 > mtime = -1
92 > else:
93 > mtime = None
94 >
95 >
96 > I hate repeating code. This can be done using one universal small
97 > function and will clean up the __init__()
98 >
99 > @static_method
100 > def _long(var, default):
101 > if var is not None:
102 > try:
103 > var = long(var)
104 > except ValueError:
105 > if var:
106 > var = -1
107 > else:
108 > var = default
109 > return var
110
111 Okay, I'll do that and post the updated patch.
112 --
113 Thanks,
114 Zac

Replies