1 |
Author: zmedico |
2 |
Date: 2009-06-23 20:44:49 +0000 (Tue, 23 Jun 2009) |
3 |
New Revision: 13677 |
4 |
|
5 |
Added: |
6 |
main/trunk/pym/_emerge/changelog.py |
7 |
Modified: |
8 |
main/trunk/pym/_emerge/depgraph.py |
9 |
Log: |
10 |
Bug #275217 - Part 2 - Move changelog stuff stuff out of depgraph. |
11 |
Thanks to Sebastian Mingramm (few) <s.mingramm@×××.de> for this patch. |
12 |
|
13 |
|
14 |
Added: main/trunk/pym/_emerge/changelog.py |
15 |
=================================================================== |
16 |
--- main/trunk/pym/_emerge/changelog.py (rev 0) |
17 |
+++ main/trunk/pym/_emerge/changelog.py 2009-06-23 20:44:49 UTC (rev 13677) |
18 |
@@ -0,0 +1,62 @@ |
19 |
+import os |
20 |
+import re |
21 |
+ |
22 |
+try: |
23 |
+ import portage |
24 |
+except ImportError: |
25 |
+ from os import path as osp |
26 |
+ import sys |
27 |
+ sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) |
28 |
+ import portage |
29 |
+ |
30 |
+def calc_changelog(ebuildpath,current,next): |
31 |
+ if ebuildpath == None or not os.path.exists(ebuildpath): |
32 |
+ return [] |
33 |
+ current = '-'.join(portage.catpkgsplit(current)[1:]) |
34 |
+ if current.endswith('-r0'): |
35 |
+ current = current[:-3] |
36 |
+ next = '-'.join(portage.catpkgsplit(next)[1:]) |
37 |
+ if next.endswith('-r0'): |
38 |
+ next = next[:-3] |
39 |
+ changelogpath = os.path.join(os.path.split(ebuildpath)[0],'ChangeLog') |
40 |
+ try: |
41 |
+ changelog = open(changelogpath).read() |
42 |
+ except SystemExit, e: |
43 |
+ raise # Needed else can't exit |
44 |
+ except: |
45 |
+ return [] |
46 |
+ divisions = _find_changelog_tags(changelog) |
47 |
+ #print 'XX from',current,'to',next |
48 |
+ #for div,text in divisions: print 'XX',div |
49 |
+ # skip entries for all revisions above the one we are about to emerge |
50 |
+ for i in range(len(divisions)): |
51 |
+ if divisions[i][0]==next: |
52 |
+ divisions = divisions[i:] |
53 |
+ break |
54 |
+ # find out how many entries we are going to display |
55 |
+ for i in range(len(divisions)): |
56 |
+ if divisions[i][0]==current: |
57 |
+ divisions = divisions[:i] |
58 |
+ break |
59 |
+ else: |
60 |
+ # couldnt find the current revision in the list. display nothing |
61 |
+ return [] |
62 |
+ return divisions |
63 |
+ |
64 |
+def _find_changelog_tags(changelog): |
65 |
+ divs = [] |
66 |
+ release = None |
67 |
+ while 1: |
68 |
+ match = re.search(r'^\*\ ?([-a-zA-Z0-9_.+]*)(?:\ .*)?\n',changelog,re.M) |
69 |
+ if match is None: |
70 |
+ if release is not None: |
71 |
+ divs.append((release,changelog)) |
72 |
+ return divs |
73 |
+ if release is not None: |
74 |
+ divs.append((release,changelog[:match.start()])) |
75 |
+ changelog = changelog[match.end():] |
76 |
+ release = match.group(1) |
77 |
+ if release.endswith('.ebuild'): |
78 |
+ release = release[:-7] |
79 |
+ if release.endswith('-r0'): |
80 |
+ release = release[:-3] |
81 |
|
82 |
|
83 |
Property changes on: main/trunk/pym/_emerge/changelog.py |
84 |
___________________________________________________________________ |
85 |
Name: svn:keywords |
86 |
+ Id |
87 |
|
88 |
Modified: main/trunk/pym/_emerge/depgraph.py |
89 |
=================================================================== |
90 |
--- main/trunk/pym/_emerge/depgraph.py 2009-06-23 20:38:40 UTC (rev 13676) |
91 |
+++ main/trunk/pym/_emerge/depgraph.py 2009-06-23 20:44:49 UTC (rev 13677) |
92 |
@@ -24,6 +24,7 @@ |
93 |
from _emerge.Blocker import Blocker |
94 |
from _emerge.BlockerCache import BlockerCache |
95 |
from _emerge.BlockerDepPriority import BlockerDepPriority |
96 |
+from _emerge.changelog import calc_changelog |
97 |
from _emerge.countdown import countdown |
98 |
from _emerge.create_world_atom import create_world_atom |
99 |
from _emerge.Dependency import Dependency |
100 |
@@ -3767,7 +3768,7 @@ |
101 |
if "--changelog" in self.myopts: |
102 |
inst_matches = vardb.match(pkg.slot_atom) |
103 |
if inst_matches: |
104 |
- changelogs.extend(self._calc_changelog( |
105 |
+ changelogs.extend(calc_changelog( |
106 |
portdb.findname(pkg_key), |
107 |
inst_matches[0], pkg_key)) |
108 |
else: |
109 |
@@ -4262,58 +4263,6 @@ |
110 |
show_mask_docs() |
111 |
print |
112 |
|
113 |
- def _calc_changelog(self,ebuildpath,current,next): |
114 |
- if ebuildpath == None or not os.path.exists(ebuildpath): |
115 |
- return [] |
116 |
- current = '-'.join(portage.catpkgsplit(current)[1:]) |
117 |
- if current.endswith('-r0'): |
118 |
- current = current[:-3] |
119 |
- next = '-'.join(portage.catpkgsplit(next)[1:]) |
120 |
- if next.endswith('-r0'): |
121 |
- next = next[:-3] |
122 |
- changelogpath = os.path.join(os.path.split(ebuildpath)[0],'ChangeLog') |
123 |
- try: |
124 |
- changelog = open(changelogpath).read() |
125 |
- except SystemExit, e: |
126 |
- raise # Needed else can't exit |
127 |
- except: |
128 |
- return [] |
129 |
- divisions = self.find_changelog_tags(changelog) |
130 |
- #print 'XX from',current,'to',next |
131 |
- #for div,text in divisions: print 'XX',div |
132 |
- # skip entries for all revisions above the one we are about to emerge |
133 |
- for i in range(len(divisions)): |
134 |
- if divisions[i][0]==next: |
135 |
- divisions = divisions[i:] |
136 |
- break |
137 |
- # find out how many entries we are going to display |
138 |
- for i in range(len(divisions)): |
139 |
- if divisions[i][0]==current: |
140 |
- divisions = divisions[:i] |
141 |
- break |
142 |
- else: |
143 |
- # couldnt find the current revision in the list. display nothing |
144 |
- return [] |
145 |
- return divisions |
146 |
- |
147 |
- def _find_changelog_tags(self,changelog): |
148 |
- divs = [] |
149 |
- release = None |
150 |
- while 1: |
151 |
- match = re.search(r'^\*\ ?([-a-zA-Z0-9_.+]*)(?:\ .*)?\n',changelog,re.M) |
152 |
- if match is None: |
153 |
- if release is not None: |
154 |
- divs.append((release,changelog)) |
155 |
- return divs |
156 |
- if release is not None: |
157 |
- divs.append((release,changelog[:match.start()])) |
158 |
- changelog = changelog[match.end():] |
159 |
- release = match.group(1) |
160 |
- if release.endswith('.ebuild'): |
161 |
- release = release[:-7] |
162 |
- if release.endswith('-r0'): |
163 |
- release = release[:-3] |
164 |
- |
165 |
def saveNomergeFavorites(self): |
166 |
"""Find atoms in favorites that are not in the mergelist and add them |
167 |
to the world file if necessary.""" |