1 |
commit: 5acf1392fdcac2470e504b211d40ee7606d2090a |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Oct 30 23:11:35 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Oct 30 23:11:35 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5acf1392 |
7 |
|
8 |
dblink.mergeme(): use stack instead of recursion |
9 |
|
10 |
Maybe this helps reduce memory consumption when merging packages with |
11 |
lots of subdirectories like gentoo-sources (bug #320859). |
12 |
|
13 |
--- |
14 |
pym/portage/dbapi/vartree.py | 22 +++++++++++----------- |
15 |
1 files changed, 11 insertions(+), 11 deletions(-) |
16 |
|
17 |
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py |
18 |
index aae23e6..8d908fc 100644 |
19 |
--- a/pym/portage/dbapi/vartree.py |
20 |
+++ b/pym/portage/dbapi/vartree.py |
21 |
@@ -4356,18 +4356,18 @@ class dblink(object): |
22 |
# this is supposed to merge a list of files. There will be 2 forms of argument passing. |
23 |
if isinstance(stufftomerge, basestring): |
24 |
#A directory is specified. Figure out protection paths, listdir() it and process it. |
25 |
- mergelist = os.listdir(join(srcroot, stufftomerge)) |
26 |
- offset = stufftomerge |
27 |
+ mergelist = [join(stufftomerge, child) for child in \ |
28 |
+ os.listdir(join(srcroot, stufftomerge))] |
29 |
else: |
30 |
- mergelist = stufftomerge |
31 |
- offset = "" |
32 |
+ mergelist = stufftomerge[:] |
33 |
|
34 |
- for i, x in enumerate(mergelist): |
35 |
+ while mergelist: |
36 |
|
37 |
- mysrc = join(srcroot, offset, x) |
38 |
- mydest = join(destroot, offset, x) |
39 |
+ relative_path = mergelist.pop() |
40 |
+ mysrc = join(srcroot, relative_path) |
41 |
+ mydest = join(destroot, relative_path) |
42 |
# myrealdest is mydest without the $ROOT prefix (makes a difference if ROOT!="/") |
43 |
- myrealdest = join(sep, offset, x) |
44 |
+ myrealdest = join(sep, relative_path) |
45 |
# stat file once, test using S_* macros many times (faster that way) |
46 |
mystat = os.lstat(mysrc) |
47 |
mymode = mystat[stat.ST_MODE] |
48 |
@@ -4575,9 +4575,9 @@ class dblink(object): |
49 |
|
50 |
outfile.write("dir "+myrealdest+"\n") |
51 |
# recurse and merge this directory |
52 |
- if self.mergeme(srcroot, destroot, outfile, secondhand, |
53 |
- join(offset, x), cfgfiledict, thismtime): |
54 |
- return 1 |
55 |
+ mergelist.extend(join(relative_path, child) for child in |
56 |
+ os.listdir(join(srcroot, relative_path))) |
57 |
+ |
58 |
elif stat.S_ISREG(mymode): |
59 |
# we are merging a regular file |
60 |
mymd5 = perform_md5(mysrc, calc_prelink=calc_prelink) |