1 |
commit: f702bf4c75b03b19e214c6d9f5a376afa647dce5 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Sep 19 03:59:10 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=f702bf4c |
7 |
|
8 |
repoman/actions.py: split out a manifest function |
9 |
|
10 |
pym/repoman/actions.py | 110 +++++++++++++++++++++++++------------------------ |
11 |
1 file changed, 57 insertions(+), 53 deletions(-) |
12 |
|
13 |
diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py |
14 |
index d70dd82..405a8c7 100644 |
15 |
--- a/pym/repoman/actions.py |
16 |
+++ b/pym/repoman/actions.py |
17 |
@@ -330,59 +330,7 @@ class Actions(object): |
18 |
level=logging.ERROR, noiselevel=-1) |
19 |
sys.exit(retval) |
20 |
|
21 |
- if True: |
22 |
- myfiles = mymanifests[:] |
23 |
- # If there are no header (SVN/CVS keywords) changes in |
24 |
- # the files, this Manifest commit must include the |
25 |
- # other (yet uncommitted) files. |
26 |
- if not myheaders: |
27 |
- myfiles += myupdates |
28 |
- myfiles += myremoved |
29 |
- myfiles.sort() |
30 |
- |
31 |
- fd, commitmessagefile = tempfile.mkstemp(".repoman.msg") |
32 |
- mymsg = os.fdopen(fd, "wb") |
33 |
- mymsg.write(_unicode_encode(commitmessage)) |
34 |
- mymsg.close() |
35 |
- |
36 |
- commit_cmd = [] |
37 |
- if self.options.pretend and self.vcs_settings.vcs is None: |
38 |
- # substitute a bogus value for pretend output |
39 |
- commit_cmd.append("cvs") |
40 |
- else: |
41 |
- commit_cmd.append(self.vcs_settings.vcs) |
42 |
- commit_cmd.extend(self.vcs_settings.vcs_global_opts) |
43 |
- commit_cmd.append("commit") |
44 |
- commit_cmd.extend(self.vcs_settings.vcs_local_opts) |
45 |
- if self.vcs_settings.vcs == "hg": |
46 |
- commit_cmd.extend(["--logfile", commitmessagefile]) |
47 |
- commit_cmd.extend(myfiles) |
48 |
- else: |
49 |
- commit_cmd.extend(["-F", commitmessagefile]) |
50 |
- commit_cmd.extend(f.lstrip("./") for f in myfiles) |
51 |
- |
52 |
- try: |
53 |
- if self.options.pretend: |
54 |
- print("(%s)" % (" ".join(commit_cmd),)) |
55 |
- else: |
56 |
- retval = spawn(commit_cmd, env=self.repo_settings.commit_env) |
57 |
- if retval != os.EX_OK: |
58 |
- if self.repo_settings.repo_config.sign_commit and self.vcs_settings.vcs == 'git' and \ |
59 |
- not git_supports_gpg_sign(): |
60 |
- # Inform user that newer git is needed (bug #403323). |
61 |
- logging.error( |
62 |
- "Git >=1.7.9 is required for signed commits!") |
63 |
- |
64 |
- writemsg_level( |
65 |
- "!!! Exiting on %s (shell) " |
66 |
- "error code: %s\n" % (self.vcs_settings.vcs, retval), |
67 |
- level=logging.ERROR, noiselevel=-1) |
68 |
- sys.exit(retval) |
69 |
- finally: |
70 |
- try: |
71 |
- os.unlink(commitmessagefile) |
72 |
- except OSError: |
73 |
- pass |
74 |
+ self.add_manifest(mymanifests, myheaders, myupdates, myremoved, commitmessage) |
75 |
|
76 |
print() |
77 |
if self.vcs_settings.vcs: |
78 |
@@ -807,3 +755,59 @@ class Actions(object): |
79 |
|
80 |
myupdates += myautoadd |
81 |
return myupdates, broken_changelog_manifests |
82 |
+ |
83 |
+ |
84 |
+ def add_manifest(self, mymanifests, myheaders, myupdates, myremoved, |
85 |
+ commitmessage): |
86 |
+ myfiles = mymanifests[:] |
87 |
+ # If there are no header (SVN/CVS keywords) changes in |
88 |
+ # the files, this Manifest commit must include the |
89 |
+ # other (yet uncommitted) files. |
90 |
+ if not myheaders: |
91 |
+ myfiles += myupdates |
92 |
+ myfiles += myremoved |
93 |
+ myfiles.sort() |
94 |
+ |
95 |
+ fd, commitmessagefile = tempfile.mkstemp(".repoman.msg") |
96 |
+ mymsg = os.fdopen(fd, "wb") |
97 |
+ mymsg.write(_unicode_encode(commitmessage)) |
98 |
+ mymsg.close() |
99 |
+ |
100 |
+ commit_cmd = [] |
101 |
+ if self.options.pretend and self.vcs_settings.vcs is None: |
102 |
+ # substitute a bogus value for pretend output |
103 |
+ commit_cmd.append("cvs") |
104 |
+ else: |
105 |
+ commit_cmd.append(self.vcs_settings.vcs) |
106 |
+ commit_cmd.extend(self.vcs_settings.vcs_global_opts) |
107 |
+ commit_cmd.append("commit") |
108 |
+ commit_cmd.extend(self.vcs_settings.vcs_local_opts) |
109 |
+ if self.vcs_settings.vcs == "hg": |
110 |
+ commit_cmd.extend(["--logfile", commitmessagefile]) |
111 |
+ commit_cmd.extend(myfiles) |
112 |
+ else: |
113 |
+ commit_cmd.extend(["-F", commitmessagefile]) |
114 |
+ commit_cmd.extend(f.lstrip("./") for f in myfiles) |
115 |
+ |
116 |
+ try: |
117 |
+ if self.options.pretend: |
118 |
+ print("(%s)" % (" ".join(commit_cmd),)) |
119 |
+ else: |
120 |
+ retval = spawn(commit_cmd, env=self.repo_settings.commit_env) |
121 |
+ if retval != os.EX_OK: |
122 |
+ if self.repo_settings.repo_config.sign_commit and self.vcs_settings.vcs == 'git' and \ |
123 |
+ not git_supports_gpg_sign(): |
124 |
+ # Inform user that newer git is needed (bug #403323). |
125 |
+ logging.error( |
126 |
+ "Git >=1.7.9 is required for signed commits!") |
127 |
+ |
128 |
+ writemsg_level( |
129 |
+ "!!! Exiting on %s (shell) " |
130 |
+ "error code: %s\n" % (self.vcs_settings.vcs, retval), |
131 |
+ level=logging.ERROR, noiselevel=-1) |
132 |
+ sys.exit(retval) |
133 |
+ finally: |
134 |
+ try: |
135 |
+ os.unlink(commitmessagefile) |
136 |
+ except OSError: |
137 |
+ pass |