1 |
commit: 6a7e4358e3fbf359d77623b007c1a68c901a1790 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Sep 19 04:10:03 2015 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 21 23:42:47 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6a7e4358 |
7 |
|
8 |
repoman/actions.py: Split out priming_commit() |
9 |
|
10 |
pym/repoman/actions.py | 91 ++++++++++++++++++++++++++------------------------ |
11 |
1 file changed, 48 insertions(+), 43 deletions(-) |
12 |
|
13 |
diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py |
14 |
index 2318ce2..af50c1b 100644 |
15 |
--- a/pym/repoman/actions.py |
16 |
+++ b/pym/repoman/actions.py |
17 |
@@ -208,49 +208,7 @@ class Actions(object): |
18 |
# will change and need a priming commit before the Manifest |
19 |
# can be committed. |
20 |
if (myupdates or myremoved) and myheaders: |
21 |
- myfiles = myupdates + myremoved |
22 |
- fd, commitmessagefile = tempfile.mkstemp(".repoman.msg") |
23 |
- mymsg = os.fdopen(fd, "wb") |
24 |
- mymsg.write(_unicode_encode(commitmessage)) |
25 |
- mymsg.close() |
26 |
- |
27 |
- separator = '-' * 78 |
28 |
- |
29 |
- print() |
30 |
- print(green("Using commit message:")) |
31 |
- print(green(separator)) |
32 |
- print(commitmessage) |
33 |
- print(green(separator)) |
34 |
- print() |
35 |
- |
36 |
- # Having a leading ./ prefix on file paths can trigger a bug in |
37 |
- # the cvs server when committing files to multiple directories, |
38 |
- # so strip the prefix. |
39 |
- myfiles = [f.lstrip("./") for f in myfiles] |
40 |
- |
41 |
- commit_cmd = [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 |
- commit_cmd.extend(["-F", commitmessagefile]) |
46 |
- commit_cmd.extend(myfiles) |
47 |
- |
48 |
- try: |
49 |
- if self.options.pretend: |
50 |
- print("(%s)" % (" ".join(commit_cmd),)) |
51 |
- else: |
52 |
- retval = spawn(commit_cmd, env=self.repo_settings.commit_env) |
53 |
- if retval != os.EX_OK: |
54 |
- writemsg_level( |
55 |
- "!!! Exiting on %s (shell) " |
56 |
- "error code: %s\n" % (self.vcs_settings.vcs, retval), |
57 |
- level=logging.ERROR, noiselevel=-1) |
58 |
- sys.exit(retval) |
59 |
- finally: |
60 |
- try: |
61 |
- os.unlink(commitmessagefile) |
62 |
- except OSError: |
63 |
- pass |
64 |
+ self.priming_commit(myupdates, myremoved, commitmessage) |
65 |
|
66 |
# When files are removed and re-added, the cvs server will put /Attic/ |
67 |
# inside the $Header path. This code detects the problem and corrects it |
68 |
@@ -809,3 +767,50 @@ class Actions(object): |
69 |
os.unlink(commitmessagefile) |
70 |
except OSError: |
71 |
pass |
72 |
+ |
73 |
+ |
74 |
+ def priming_commit(self, myupdates, myremoved, commitmessage): |
75 |
+ myfiles = myupdates + myremoved |
76 |
+ fd, commitmessagefile = tempfile.mkstemp(".repoman.msg") |
77 |
+ mymsg = os.fdopen(fd, "wb") |
78 |
+ mymsg.write(_unicode_encode(commitmessage)) |
79 |
+ mymsg.close() |
80 |
+ |
81 |
+ separator = '-' * 78 |
82 |
+ |
83 |
+ print() |
84 |
+ print(green("Using commit message:")) |
85 |
+ print(green(separator)) |
86 |
+ print(commitmessage) |
87 |
+ print(green(separator)) |
88 |
+ print() |
89 |
+ |
90 |
+ # Having a leading ./ prefix on file paths can trigger a bug in |
91 |
+ # the cvs server when committing files to multiple directories, |
92 |
+ # so strip the prefix. |
93 |
+ myfiles = [f.lstrip("./") for f in myfiles] |
94 |
+ |
95 |
+ commit_cmd = [self.vcs_settings.vcs] |
96 |
+ commit_cmd.extend(self.vcs_settings.vcs_global_opts) |
97 |
+ commit_cmd.append("commit") |
98 |
+ commit_cmd.extend(self.vcs_settings.vcs_local_opts) |
99 |
+ commit_cmd.extend(["-F", commitmessagefile]) |
100 |
+ commit_cmd.extend(myfiles) |
101 |
+ |
102 |
+ try: |
103 |
+ if self.options.pretend: |
104 |
+ print("(%s)" % (" ".join(commit_cmd),)) |
105 |
+ else: |
106 |
+ retval = spawn(commit_cmd, env=self.repo_settings.commit_env) |
107 |
+ if retval != os.EX_OK: |
108 |
+ writemsg_level( |
109 |
+ "!!! Exiting on %s (shell) " |
110 |
+ "error code: %s\n" % (self.vcs_settings.vcs, retval), |
111 |
+ level=logging.ERROR, noiselevel=-1) |
112 |
+ sys.exit(retval) |
113 |
+ finally: |
114 |
+ try: |
115 |
+ os.unlink(commitmessagefile) |
116 |
+ except OSError: |
117 |
+ pass |
118 |
+ |