1 |
commit: f9895ac7a04ee31af370151f238409cae4ac1a01 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Mar 1 20:07:53 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Mar 1 20:54:01 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f9895ac7 |
7 |
|
8 |
unmerge: implicitly unmerge parent directories |
9 |
|
10 |
We can't necessarily assume that they are explicitly listed in |
11 |
CONTENTS. |
12 |
|
13 |
--- |
14 |
pym/portage/dbapi/vartree.py | 19 ++++++++++++++++--- |
15 |
1 files changed, 16 insertions(+), 3 deletions(-) |
16 |
|
17 |
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py |
18 |
index b8881c8..a7a7d40 100644 |
19 |
--- a/pym/portage/dbapi/vartree.py |
20 |
+++ b/pym/portage/dbapi/vartree.py |
21 |
@@ -1784,7 +1784,7 @@ class dblink(object): |
22 |
mykeys.reverse() |
23 |
|
24 |
#process symlinks second-to-last, directories last. |
25 |
- mydirs = [] |
26 |
+ mydirs = set() |
27 |
ignored_unlink_errnos = ( |
28 |
errno.EBUSY, errno.ENOENT, |
29 |
errno.ENOTDIR, errno.EISDIR) |
30 |
@@ -1846,6 +1846,7 @@ class dblink(object): |
31 |
|
32 |
real_root = self.settings['ROOT'] |
33 |
real_root_len = len(real_root) - 1 |
34 |
+ eroot_split_len = len(self.settings["EROOT"].split(os.sep)) - 1 |
35 |
|
36 |
for i, objkey in enumerate(mykeys): |
37 |
|
38 |
@@ -1871,6 +1872,18 @@ class dblink(object): |
39 |
os = portage.os |
40 |
perf_md5 = portage.checksum.perform_md5 |
41 |
|
42 |
+ # Try to unmerge parent directories of everything |
43 |
+ # listed in CONTENTS, since we can't necessarily |
44 |
+ # assume that directories are listed in CONTENTS. |
45 |
+ obj_split = obj.split(os.sep) |
46 |
+ obj_split.pop() |
47 |
+ while len(obj_split) > eroot_split_len: |
48 |
+ parent = os.sep.join(obj_split) |
49 |
+ if parent in mydirs: |
50 |
+ break |
51 |
+ mydirs.add(parent) |
52 |
+ obj_split.pop() |
53 |
+ |
54 |
file_data = pkgfiles[objkey] |
55 |
file_type = file_data[0] |
56 |
statobj = None |
57 |
@@ -1939,7 +1952,7 @@ class dblink(object): |
58 |
if lstatobj is None or not stat.S_ISDIR(lstatobj.st_mode): |
59 |
show_unmerge("---", unmerge_desc["!dir"], file_type, obj) |
60 |
continue |
61 |
- mydirs.append(obj) |
62 |
+ mydirs.add(obj) |
63 |
elif pkgfiles[objkey][0] == "sym": |
64 |
if not islink: |
65 |
show_unmerge("---", unmerge_desc["!sym"], file_type, obj) |
66 |
@@ -1991,7 +2004,7 @@ class dblink(object): |
67 |
elif pkgfiles[objkey][0] == "dev": |
68 |
show_unmerge("---", "", file_type, obj) |
69 |
|
70 |
- mydirs.sort() |
71 |
+ mydirs = sorted(mydirs) |
72 |
mydirs.reverse() |
73 |
|
74 |
for obj in mydirs: |