Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/repoman/
Date: Mon, 21 Sep 2015 23:51:46
Message-Id: 1442878966.458d0ca69f6e1d9fb0b673e48d86211a591581ee.dolsen@gentoo
1 commit: 458d0ca69f6e1d9fb0b673e48d86211a591581ee
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 19 03:25:28 2015 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Mon Sep 21 23:42:46 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=458d0ca6
7
8 repoman/actions.py: Split out the changelog code to it's own function
9
10 pym/repoman/actions.py | 191 +++++++++++++++++++++++++------------------------
11 1 file changed, 99 insertions(+), 92 deletions(-)
12
13 diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py
14 index e9bf147..d70dd82 100644
15 --- a/pym/repoman/actions.py
16 +++ b/pym/repoman/actions.py
17 @@ -132,102 +132,14 @@ class Actions(object):
18 print("* no commit message? aborting commit.")
19 sys.exit(1)
20 commitmessage = commitmessage.rstrip()
21 - changelog_msg = commitmessage
22 +
23 + myupdates, broken_changelog_manifests = self.changelogs(
24 + myupdates, mymanifests, myremoved, mychanged, myautoadd,
25 + mynew, commitmessage)
26
27 commit_footer = self.get_commit_footer()
28 commitmessage += commit_footer
29
30 - broken_changelog_manifests = []
31 - if self.options.echangelog in ('y', 'force'):
32 - logging.info("checking for unmodified ChangeLog files")
33 - committer_name = utilities.get_committer_name(env=self.repoman_settings)
34 - for x in sorted(vcs_files_to_cps(
35 - chain(myupdates, mymanifests, myremoved),
36 - self.scanner.repolevel, self.scanner.reposplit, self.scanner.categories)):
37 - catdir, pkgdir = x.split("/")
38 - checkdir = self.repo_settings.repodir + "/" + x
39 - checkdir_relative = ""
40 - if self.scanner.repolevel < 3:
41 - checkdir_relative = os.path.join(pkgdir, checkdir_relative)
42 - if self.scanner.repolevel < 2:
43 - checkdir_relative = os.path.join(catdir, checkdir_relative)
44 - checkdir_relative = os.path.join(".", checkdir_relative)
45 -
46 - changelog_path = os.path.join(checkdir_relative, "ChangeLog")
47 - changelog_modified = changelog_path in self.scanner.changed.changelogs
48 - if changelog_modified and self.options.echangelog != 'force':
49 - continue
50 -
51 - # get changes for this package
52 - cdrlen = len(checkdir_relative)
53 - check_relative = lambda e: e.startswith(checkdir_relative)
54 - split_relative = lambda e: e[cdrlen:]
55 - clnew = list(map(split_relative, filter(check_relative, mynew)))
56 - clremoved = list(map(split_relative, filter(check_relative, myremoved)))
57 - clchanged = list(map(split_relative, filter(check_relative, mychanged)))
58 -
59 - # Skip ChangeLog generation if only the Manifest was modified,
60 - # as discussed in bug #398009.
61 - nontrivial_cl_files = set()
62 - nontrivial_cl_files.update(clnew, clremoved, clchanged)
63 - nontrivial_cl_files.difference_update(['Manifest'])
64 - if not nontrivial_cl_files and self.options.echangelog != 'force':
65 - continue
66 -
67 - new_changelog = utilities.UpdateChangeLog(
68 - checkdir_relative, committer_name, changelog_msg,
69 - os.path.join(self.repo_settings.repodir, 'skel.ChangeLog'),
70 - catdir, pkgdir,
71 - new=clnew, removed=clremoved, changed=clchanged,
72 - pretend=self.options.pretend)
73 - if new_changelog is None:
74 - writemsg_level(
75 - "!!! Updating the ChangeLog failed\n",
76 - level=logging.ERROR, noiselevel=-1)
77 - sys.exit(1)
78 -
79 - # if the ChangeLog was just created, add it to vcs
80 - if new_changelog:
81 - myautoadd.append(changelog_path)
82 - # myautoadd is appended to myupdates below
83 - else:
84 - myupdates.append(changelog_path)
85 -
86 - if self.options.ask and not self.options.pretend:
87 - # regenerate Manifest for modified ChangeLog (bug #420735)
88 - self.repoman_settings["O"] = checkdir
89 - digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb)
90 - else:
91 - broken_changelog_manifests.append(x)
92 -
93 - if myautoadd:
94 - print(">>> Auto-Adding missing Manifest/ChangeLog file(s)...")
95 - add_cmd = [self.vcs_settings.vcs, "add"]
96 - add_cmd += myautoadd
97 - if self.options.pretend:
98 - portage.writemsg_stdout(
99 - "(%s)\n" % " ".join(add_cmd),
100 - noiselevel=-1)
101 - else:
102 -
103 - if sys.hexversion < 0x3020000 and sys.hexversion >= 0x3000000 and \
104 - not os.path.isabs(add_cmd[0]):
105 - # Python 3.1 _execvp throws TypeError for non-absolute executable
106 - # path passed as bytes (see http://bugs.python.org/issue8513).
107 - fullname = find_binary(add_cmd[0])
108 - if fullname is None:
109 - raise portage.exception.CommandNotFound(add_cmd[0])
110 - add_cmd[0] = fullname
111 -
112 - add_cmd = [_unicode_encode(arg) for arg in add_cmd]
113 - retcode = subprocess.call(add_cmd)
114 - if retcode != os.EX_OK:
115 - logging.error(
116 - "Exiting on %s error code: %s\n" % (self.vcs_settings.vcs, retcode))
117 - sys.exit(retcode)
118 -
119 - myupdates += myautoadd
120 -
121 print("* %s files being committed..." % green(str(len(myupdates))), end=' ')
122
123 if self.vcs_settings.vcs not in ('cvs', 'svn'):
124 @@ -800,3 +712,98 @@ class Actions(object):
125 commit_footer += ", unsigned Manifest commit"
126 commit_footer += ")"
127 return commit_footer
128 +
129 +
130 + def changelogs(self, myupdates, mymanifests, myremoved, mychanged, myautoadd,
131 + mynew, changelog_msg):
132 + broken_changelog_manifests = []
133 + if self.options.echangelog in ('y', 'force'):
134 + logging.info("checking for unmodified ChangeLog files")
135 + committer_name = utilities.get_committer_name(env=self.repoman_settings)
136 + for x in sorted(vcs_files_to_cps(
137 + chain(myupdates, mymanifests, myremoved),
138 + self.scanner.repolevel, self.scanner.reposplit, self.scanner.categories)):
139 + catdir, pkgdir = x.split("/")
140 + checkdir = self.repo_settings.repodir + "/" + x
141 + checkdir_relative = ""
142 + if self.scanner.repolevel < 3:
143 + checkdir_relative = os.path.join(pkgdir, checkdir_relative)
144 + if self.scanner.repolevel < 2:
145 + checkdir_relative = os.path.join(catdir, checkdir_relative)
146 + checkdir_relative = os.path.join(".", checkdir_relative)
147 +
148 + changelog_path = os.path.join(checkdir_relative, "ChangeLog")
149 + changelog_modified = changelog_path in self.scanner.changed.changelogs
150 + if changelog_modified and self.options.echangelog != 'force':
151 + continue
152 +
153 + # get changes for this package
154 + cdrlen = len(checkdir_relative)
155 + check_relative = lambda e: e.startswith(checkdir_relative)
156 + split_relative = lambda e: e[cdrlen:]
157 + clnew = list(map(split_relative, filter(check_relative, mynew)))
158 + clremoved = list(map(split_relative, filter(check_relative, myremoved)))
159 + clchanged = list(map(split_relative, filter(check_relative, mychanged)))
160 +
161 + # Skip ChangeLog generation if only the Manifest was modified,
162 + # as discussed in bug #398009.
163 + nontrivial_cl_files = set()
164 + nontrivial_cl_files.update(clnew, clremoved, clchanged)
165 + nontrivial_cl_files.difference_update(['Manifest'])
166 + if not nontrivial_cl_files and self.options.echangelog != 'force':
167 + continue
168 +
169 + new_changelog = utilities.UpdateChangeLog(
170 + checkdir_relative, committer_name, changelog_msg,
171 + os.path.join(self.repo_settings.repodir, 'skel.ChangeLog'),
172 + catdir, pkgdir,
173 + new=clnew, removed=clremoved, changed=clchanged,
174 + pretend=self.options.pretend)
175 + if new_changelog is None:
176 + writemsg_level(
177 + "!!! Updating the ChangeLog failed\n",
178 + level=logging.ERROR, noiselevel=-1)
179 + sys.exit(1)
180 +
181 + # if the ChangeLog was just created, add it to vcs
182 + if new_changelog:
183 + myautoadd.append(changelog_path)
184 + # myautoadd is appended to myupdates below
185 + else:
186 + myupdates.append(changelog_path)
187 +
188 + if self.options.ask and not self.options.pretend:
189 + # regenerate Manifest for modified ChangeLog (bug #420735)
190 + self.repoman_settings["O"] = checkdir
191 + digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb)
192 + else:
193 + broken_changelog_manifests.append(x)
194 +
195 + if myautoadd:
196 + print(">>> Auto-Adding missing Manifest/ChangeLog file(s)...")
197 + add_cmd = [self.vcs_settings.vcs, "add"]
198 + add_cmd += myautoadd
199 + if self.options.pretend:
200 + portage.writemsg_stdout(
201 + "(%s)\n" % " ".join(add_cmd),
202 + noiselevel=-1)
203 + else:
204 +
205 + if sys.hexversion < 0x3020000 and sys.hexversion >= 0x3000000 and \
206 + not os.path.isabs(add_cmd[0]):
207 + # Python 3.1 _execvp throws TypeError for non-absolute executable
208 + # path passed as bytes (see http://bugs.python.org/issue8513).
209 + fullname = find_binary(add_cmd[0])
210 + if fullname is None:
211 + raise portage.exception.CommandNotFound(add_cmd[0])
212 + add_cmd[0] = fullname
213 +
214 + add_cmd = [_unicode_encode(arg) for arg in add_cmd]
215 + retcode = subprocess.call(add_cmd)
216 + if retcode != os.EX_OK:
217 + logging.error(
218 + "Exiting on %s error code: %s\n" % (self.vcs_settings.vcs, retcode))
219 + sys.exit(retcode)
220 +
221 + myupdates += myautoadd
222 + return myupdates, broken_changelog_manifests