commit:     f180baffdc7d1eb010a822e3d6585b4a1a635772
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 19 04:10:03 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Sep 19 04:10:03 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=f180baff

repoman/actions.py: Split out priming_commit()

 pym/repoman/actions.py | 91 ++++++++++++++++++++++++++------------------------
 1 file changed, 48 insertions(+), 43 deletions(-)

diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py
index 06f57a3..a538174 100644
--- a/pym/repoman/actions.py
+++ b/pym/repoman/actions.py
@@ -205,49 +205,7 @@ class Actions(object):
                # will change and need a priming commit before the Manifest
                # can be committed.
                if (myupdates or myremoved) and myheaders:
-                       myfiles = myupdates + myremoved
-                       fd, commitmessagefile = tempfile.mkstemp(".repoman.msg")
-                       mymsg = os.fdopen(fd, "wb")
-                       mymsg.write(_unicode_encode(commitmessage))
-                       mymsg.close()
-
-                       separator = '-' * 78
-
-                       print()
-                       print(green("Using commit message:"))
-                       print(green(separator))
-                       print(commitmessage)
-                       print(green(separator))
-                       print()
-
-                       # Having a leading ./ prefix on file paths can trigger 
a bug in
-                       # the cvs server when committing files to multiple 
directories,
-                       # so strip the prefix.
-                       myfiles = [f.lstrip("./") for f in myfiles]
-
-                       commit_cmd = [self.vcs_settings.vcs]
-                       commit_cmd.extend(self.vcs_settings.vcs_global_opts)
-                       commit_cmd.append("commit")
-                       commit_cmd.extend(self.vcs_settings.vcs_local_opts)
-                       commit_cmd.extend(["-F", commitmessagefile])
-                       commit_cmd.extend(myfiles)
-
-                       try:
-                               if self.options.pretend:
-                                       print("(%s)" % (" ".join(commit_cmd),))
-                               else:
-                                       retval = spawn(commit_cmd, 
env=self.repo_settings.commit_env)
-                                       if retval != os.EX_OK:
-                                               writemsg_level(
-                                                       "!!! Exiting on %s 
(shell) "
-                                                       "error code: %s\n" % 
(self.vcs_settings.vcs, retval),
-                                                       level=logging.ERROR, 
noiselevel=-1)
-                                               sys.exit(retval)
-                       finally:
-                               try:
-                                       os.unlink(commitmessagefile)
-                               except OSError:
-                                       pass
+                       self.priming_commit(myupdates, myremoved, commitmessage)
 
                # When files are removed and re-added, the cvs server will put 
/Attic/
                # inside the $Header path. This code detects the problem and 
corrects it
@@ -805,3 +763,50 @@ class Actions(object):
                                os.unlink(commitmessagefile)
                        except OSError:
                                pass
+
+
+       def priming_commit(self, myupdates, myremoved, commitmessage):
+               myfiles = myupdates + myremoved
+               fd, commitmessagefile = tempfile.mkstemp(".repoman.msg")
+               mymsg = os.fdopen(fd, "wb")
+               mymsg.write(_unicode_encode(commitmessage))
+               mymsg.close()
+
+               separator = '-' * 78
+
+               print()
+               print(green("Using commit message:"))
+               print(green(separator))
+               print(commitmessage)
+               print(green(separator))
+               print()
+
+               # Having a leading ./ prefix on file paths can trigger a bug in
+               # the cvs server when committing files to multiple directories,
+               # so strip the prefix.
+               myfiles = [f.lstrip("./") for f in myfiles]
+
+               commit_cmd = [self.vcs_settings.vcs]
+               commit_cmd.extend(self.vcs_settings.vcs_global_opts)
+               commit_cmd.append("commit")
+               commit_cmd.extend(self.vcs_settings.vcs_local_opts)
+               commit_cmd.extend(["-F", commitmessagefile])
+               commit_cmd.extend(myfiles)
+
+               try:
+                       if self.options.pretend:
+                               print("(%s)" % (" ".join(commit_cmd),))
+                       else:
+                               retval = spawn(commit_cmd, 
env=self.repo_settings.commit_env)
+                               if retval != os.EX_OK:
+                                       writemsg_level(
+                                               "!!! Exiting on %s (shell) "
+                                               "error code: %s\n" % 
(self.vcs_settings.vcs, retval),
+                                               level=logging.ERROR, 
noiselevel=-1)
+                                       sys.exit(retval)
+               finally:
+                       try:
+                               os.unlink(commitmessagefile)
+                       except OSError:
+                               pass
+

Reply via email to