Gentoo Archives: gentoo-portage-dev

From: Alec Warner <antarus@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] Config Cleanup Last Call
Date: Sat, 25 Feb 2006 15:36:23
Message-Id: 44007958.6010107@gentoo.org
In Reply to: Re: [gentoo-portage-dev] Config Cleanup Last Call by Jason Stubbs
1 Jason Stubbs wrote:
2 > On Saturday 25 February 2006 10:40, Alec Warner wrote:
3 >
4 >>Please review for badness, otherwise I'll commit this soon ;)
5 >
6 >
7 > - self.backupenv = os.environ.copy()
8 > - self.configlist.append(self.backupenv) # XXX Why though?
9 > - self.configdict["backupenv"]=self.configlist[-1]
10 > + self.configdict["backupenv"]=os.environ.copy() # XXX Why though? ( ferringb? )
11 >
12 > Kill this comment altogether. Reading it, my first thought is "why what?"
13 > It doesn't make the code clearer and so shouldn't be there.
14 killed
15 >
16 > - self.configlist.append(os.environ.copy())
17 > - self.configdict["env"]=self.configlist[-1]
18 > + ### backupenv maybe required to be a clone, and not just a reference
19 > + ### the old code did value copy we do a reference here
20 > + self.configdict["env"]=self.configdict["backupenv"]
21 Fixed to use a deepcopy instead of shallow
22 >
23 > Again, this comment doesn't make the code clearer and so shouldn't be there.
24 > Changing functionality in a "cleanup" patch is also bad form. As for the
25 > change itself, it's broken. Look at __setitem__() and reset() and then look
26 > at the usage of those two throughout the code.
27 >
28 > - mydbs=self.configlist[:-1]
29 > + #Abuse the order of lookuplist to emulate old behavior
30 > + mydbs=self.lookuplist[:-1]
31 + #abuse the order of lookuplist in order to have lookups done in the
32 correct order, "env" first.
33 >
34 > Same deal with this comment. A person seeing the code for the first time has
35 > no idea what the old behaviour was. In the old code, configlist starts with
36 > "globals" and ends with "env". In the new (and old) code, lookuplist is the
37 > reverse of that. I don't see any further changes to account for this.
38 >
39 In the old code configlist starts with env and ends with globals, but
40 the lookuplist is configlist.reverse()
41
42 <oldcode>
43 self.configdict = { "globals": self.configlist[0],
44 "defaults": self.configlist[1],
45 "conf": self.configlist[2],
46 "pkg": self.configlist[3],
47 "auto": self.configlist[4],
48 "backupenv": self.configlist[5],
49 "env": self.configlist[6] }
50
51 # make lookuplist for loading package.*
52 self.lookuplist=self.configlist[:]
53 self.lookuplist.reverse()
54 </oldcode>
55
56 > --
57 > Jason Stubbs
58 >

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
[gentoo-portage-dev] Questions regarding the new portage API (savior branch) Michael Schilling <gentoo@×××××××.de>