* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/modules/vcs/bzr/, pym/repoman/modules/vcs/None/, ...
@ 2016-04-25 15:32 Brian Dolbec
0 siblings, 0 replies; only message in thread
From: Brian Dolbec @ 2016-04-25 15:32 UTC (permalink / raw
To: gentoo-commits
commit: 82c1160302e4d66e2ea6cf0afbacc2585e5ad965
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 16 20:06:30 2016 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Apr 25 15:28:53 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=82c11603
repoman: Migrate the commit code to the vcs modules
pym/repoman/actions.py | 84 +++++++++------------------------
pym/repoman/modules/vcs/None/changes.py | 13 +++++
pym/repoman/modules/vcs/bzr/changes.py | 1 -
pym/repoman/modules/vcs/changes.py | 20 ++++++++
pym/repoman/modules/vcs/cvs/changes.py | 1 -
pym/repoman/modules/vcs/git/changes.py | 10 ++++
pym/repoman/modules/vcs/hg/changes.py | 17 +++++++
7 files changed, 83 insertions(+), 63 deletions(-)
diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py
index 4032e04..c0cd5cc 100644
--- a/pym/repoman/actions.py
+++ b/pym/repoman/actions.py
@@ -7,21 +7,19 @@ import io
import logging
import platform
import signal
-import subprocess
import sys
import tempfile
from itertools import chain
from _emerge.UserQuery import UserQuery
-import portage
+from repoman._portage import portage
from portage import os
from portage import _encodings
from portage import _unicode_encode
from portage.output import (
bold, create_color_func, green, red)
from portage.package.ebuild.digestgen import digestgen
-from portage.process import find_binary, spawn
from portage.util import writemsg_level
from repoman.gpg import gpgsign, need_signature
@@ -443,43 +441,18 @@ class Actions(object):
mymsg.write(_unicode_encode(commitmessage))
mymsg.close()
- commit_cmd = []
- if self.options.pretend and self.vcs_settings.vcs is None:
- # substitute a bogus value for pretend output
- commit_cmd.append("cvs")
- else:
- commit_cmd.append(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)
- if self.vcs_settings.vcs == "hg":
- commit_cmd.extend(["--logfile", commitmessagefile])
- commit_cmd.extend(myfiles)
- else:
- commit_cmd.extend(["-F", commitmessagefile])
- commit_cmd.extend(f.lstrip("./") for f in myfiles)
-
+ retval = self.vcs_settings.changes.commit(myfiles, commitmessagefile)
+ # cleanup the commit message before possibly exiting
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:
- if self.repo_settings.repo_config.sign_commit and not self.vcs_settings.status.supports_gpg_sign():
- # Inform user that newer git is needed (bug #403323).
- logging.error(
- "Git >=1.7.9 is required for signed commits!")
-
- 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
+ os.unlink(commitmessagefile)
+ except OSError:
+ pass
+ 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)
def priming_commit(self, myupdates, myremoved, commitmessage):
@@ -503,29 +476,18 @@ class Actions(object):
# 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)
-
+ retval = self.vcs_settings.changes.commit(myfiles, commitmessagefile)
+ # cleanup the commit message before possibly exiting
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
+ os.unlink(commitmessagefile)
+ except OSError:
+ pass
+ 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)
def sign_manifest(self, myupdates, myremoved, mymanifests):
diff --git a/pym/repoman/modules/vcs/None/changes.py b/pym/repoman/modules/vcs/None/changes.py
index 98beedb..7f46177 100644
--- a/pym/repoman/modules/vcs/None/changes.py
+++ b/pym/repoman/modules/vcs/None/changes.py
@@ -26,3 +26,16 @@ class Changes(ChangesBase):
def add_items(self, myautoadd):
'''Nothing to add them to'''
pass
+
+ def commit(self, myfiles, commitmessagefile):
+ commit_cmd = []
+ # substitute a bogus vcs value for pretend output
+ commit_cmd.append("pretend")
+ 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(f.lstrip("./") for f in myfiles)
+
+ print("(%s)" % (" ".join(commit_cmd),))
+ return 0
diff --git a/pym/repoman/modules/vcs/bzr/changes.py b/pym/repoman/modules/vcs/bzr/changes.py
index 81e7cf5..e5e61ff 100644
--- a/pym/repoman/modules/vcs/bzr/changes.py
+++ b/pym/repoman/modules/vcs/bzr/changes.py
@@ -57,4 +57,3 @@ class Changes(ChangesBase):
for x in broken_changelog_manifests:
self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x)
digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb)
-
diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py
index ee94217..f322cb1 100644
--- a/pym/repoman/modules/vcs/changes.py
+++ b/pym/repoman/modules/vcs/changes.py
@@ -10,6 +10,8 @@ from itertools import chain
from repoman._portage import portage
from portage import _unicode_encode
+from portage.process import spawn
+
class ChangesBase(object):
'''Base Class object to scan and hold the resultant data
@@ -22,6 +24,7 @@ class ChangesBase(object):
self.options = options
self.repo_settings = repo_settings
self.repoman_settings = repo_settings.repoman_settings
+ self.vcs_settings = repo_settings.vcs_settings
self._reset()
def _reset(self):
@@ -109,3 +112,20 @@ class ChangesBase(object):
logging.error(
"Exiting on %s error code: %s\n" % (self.vcs_settings.vcs, retcode))
sys.exit(retcode)
+
+
+ def commit(self, myfiles, commitmessagefile):
+ '''Common generic commit function'''
+ commit_cmd = []
+ commit_cmd.append(self.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(f.lstrip("./") for f in myfiles)
+
+ if self.options.pretend:
+ print("(%s)" % (" ".join(commit_cmd),))
+ else:
+ retval = spawn(commit_cmd, env=self.repo_settings.commit_env)
+ return retval
diff --git a/pym/repoman/modules/vcs/cvs/changes.py b/pym/repoman/modules/vcs/cvs/changes.py
index 794e850..f5c622b 100644
--- a/pym/repoman/modules/vcs/cvs/changes.py
+++ b/pym/repoman/modules/vcs/cvs/changes.py
@@ -89,4 +89,3 @@ class Changes(ChangesBase):
scanner.repolevel, scanner.reposplit, scanner.categories)):
self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x)
digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb)
-
diff --git a/pym/repoman/modules/vcs/git/changes.py b/pym/repoman/modules/vcs/git/changes.py
index 018458c..a0b836e 100644
--- a/pym/repoman/modules/vcs/git/changes.py
+++ b/pym/repoman/modules/vcs/git/changes.py
@@ -90,3 +90,13 @@ class Changes(ChangesBase):
"error code: %s\n" % (self.vcs_settings.vcs, retval),
level=logging.ERROR, noiselevel=-1)
sys.exit(retval)
+
+ def commit(self, myfiles, commitmessagefile):
+ '''Git commit the changes'''
+ retval = super(Changes, self).commit(myfiles, commitmessagefile)
+ if retval != os.EX_OK:
+ if self.repo_settings.repo_config.sign_commit and not self.vcs_settings.status.supports_gpg_sign():
+ # Inform user that newer git is needed (bug #403323).
+ logging.error(
+ "Git >=1.7.9 is required for signed commits!")
+ return retval
diff --git a/pym/repoman/modules/vcs/hg/changes.py b/pym/repoman/modules/vcs/hg/changes.py
index 2667829..c8b0c5f 100644
--- a/pym/repoman/modules/vcs/hg/changes.py
+++ b/pym/repoman/modules/vcs/hg/changes.py
@@ -7,6 +7,7 @@ from repoman._subprocess import repoman_popen
from repoman._portage import portage
from portage import os
from portage.package.ebuild.digestgen import digestgen
+from portage.process import spawn
class Changes(ChangesBase):
@@ -71,3 +72,19 @@ class Changes(ChangesBase):
for x in broken_changelog_manifests:
self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x)
digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb)
+
+ def commit(self, myfiles, commitmessagefile):
+ '''Hg commit the changes'''
+ commit_cmd = []
+ commit_cmd.append(self.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(["--logfile", commitmessagefile])
+ commit_cmd.extend(myfiles)
+
+ if self.options.pretend:
+ print("(%s)" % (" ".join(commit_cmd),))
+ else:
+ retval = spawn(commit_cmd, env=self.repo_settings.commit_env)
+ return retval
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-25 15:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-25 15:32 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/modules/vcs/bzr/, pym/repoman/modules/vcs/None/, Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox