[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/hg/, ...
commit: 685676cc8d53e710836697ba0c79d8a252b884a7 Author: Brian Dolbec gentoo org> AuthorDate: Sun Feb 7 18:53:58 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Mar 12 17:57:41 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=685676cc repoman: Migrate digest regeneration to the vcs modules pym/repoman/actions.py | 15 ++- pym/repoman/modules/vcs/bzr/changes.py | 14 -- pym/repoman/modules/vcs/changes.py | 5 + pym/repoman/modules/vcs/cvs/changes.py | 13 +++-- pym/repoman/modules/vcs/git/changes.py | 9 + pym/repoman/modules/vcs/hg/changes.py | 9 + pym/repoman/modules/vcs/settings.py| 6 -- pym/repoman/modules/vcs/svn/changes.py | 17 + 8 files changed, 69 insertions(+), 19 deletions(-) diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py index 8ff658c..4d06555 100644 --- a/pym/repoman/actions.py +++ b/pym/repoman/actions.py @@ -6,7 +6,6 @@ import errno import io import logging import platform -import re import signal import subprocess import sys @@ -25,7 +24,6 @@ from portage.package.ebuild.digestgen import digestgen from portage.process import find_binary, spawn from portage.util import writemsg_level -from repoman._subprocess import repoman_getstatusoutput from repoman.gpg import gpgsign, need_signature from repoman import utilities from repoman.modules.vcs.vcs import vcs_files_to_cps @@ -160,17 +158,8 @@ class Actions(object): "\"You're rather crazy... " "doing the entire repository.\"\n") - if self.vcs_settings.vcs in ('cvs', 'svn') and (myupdates or myremoved): - for x in sorted(vcs_files_to_cps( - chain(myupdates, myremoved, mymanifests), - self.scanner.repolevel, self.scanner.reposplit, self.scanner.categories)): - self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x) - digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb) - - elif broken_changelog_manifests: - 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) + self.vcs_settings.changes.digest_regen(myupdates, myremoved, mymanifests, + self.scanner, broken_changelog_manifests) if self.repo_settings.sign_manifests: self.sign_manifest(myupdates, myremoved, mymanifests) diff --git a/pym/repoman/modules/vcs/bzr/changes.py b/pym/repoman/modules/vcs/bzr/changes.py index 9bd0646..81e7cf5 100644 --- a/pym/repoman/modules/vcs/bzr/changes.py +++ b/pym/repoman/modules/vcs/bzr/changes.py @@ -4,7 +4,9 @@ Bazaar module Changes class submodule from repoman.modules.vcs.changes import ChangesBase from repoman._subprocess import repoman_popen - +from repoman._portage import portage +from portage import os +from portage.package.ebuild.digestgen import digestgen class Changes(ChangesBase): '''Class object to scan and hold the resultant data @@ -36,6 +38,7 @@ class Changes(ChangesBase): "./" + elem.split()[-3:-2][0].split('/')[-1:][0] for elem in bzrstatus if elem and (elem[1:2] == "K" or elem[0:1] == "R")] + self.bzrstatus = bzrstatus # Bazaar expands nothing. @property @@ -45,6 +48,13 @@ class Changes(ChangesBase): return self._unadded self._unadded = [ "./" + elem.rstrip().split()[1].split('/')[-1:][0] - for elem in bzrstatus + for elem in self.bzrstatus if elem.startswith("?") or elem[0:2] == " D"] return self._unadded + + def digest_regen(self, myupdates, myremoved, mymanifests, scanner, broken_changelog_manifests): + if broken_changelog_manifests: + 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 921e9b5..27b627f 100644 --- a/pym/repoman/modules/vcs/changes.py +++ b/pym/repoman/modules/vcs/changes.py @@ -76,6 +76,11 @@ class ChangesBase(object): '''Create a thick manifest''' pass + def digest_regen(self, myupdates, myremoved, mymanifests, scanner, +
[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/, pym/repoman/
commit: 34f2515b33ac1861da2f7e4f10ad0100ae2f155c Author: Brian Dolbec gentoo org> AuthorDate: Sun Feb 7 18:46:27 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Mar 12 17:57:40 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=34f2515b repoman: Move clear_attic() code to the modules pym/repoman/actions.py | 24 +--- pym/repoman/modules/vcs/changes.py | 4 pym/repoman/modules/vcs/cvs/changes.py | 21 + 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py index f477aec..8ff658c 100644 --- a/pym/repoman/actions.py +++ b/pym/repoman/actions.py @@ -153,7 +153,7 @@ class Actions(object): # inside the $Header path. This code detects the problem and corrects it # so that the Manifest will generate correctly. See bug #169500. # Use binary mode in order to avoid potential character encoding issues. - self.clear_attic(myheaders) + self.vcs_settings.changes.clear_attic(myheaders) if self.scanner.repolevel == 1: utilities.repoman_sez( @@ -582,28 +582,6 @@ class Actions(object): pass - - - def clear_attic(self, myheaders): - cvs_header_re = re.compile(br'^#\s*\$Header.*\$$') - attic_str = b'/Attic/' - attic_replace = b'/' - for x in myheaders: - f = open( - _unicode_encode(x, encoding=_encodings['fs'], errors='strict'), - mode='rb') - mylines = f.readlines() - f.close() - modified = False - for i, line in enumerate(mylines): - if cvs_header_re.match(line) is not None and \ - attic_str in line: - mylines[i] = line.replace(attic_str, attic_replace) - modified = True - if modified: - portage.util.write_atomic(x, b''.join(mylines), mode='wb') - - def sign_manifest(self, myupdates, myremoved, mymanifests): try: for x in sorted(vcs_files_to_cps( diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py index 77d7dc1..1745a65 100644 --- a/pym/repoman/modules/vcs/changes.py +++ b/pym/repoman/modules/vcs/changes.py @@ -74,3 +74,7 @@ class ChangesBase(object): '''Create a thick manifest''' pass + @staticmethod + def clear_attic(myheaders): + '''Old CVS leftover''' + pass diff --git a/pym/repoman/modules/vcs/cvs/changes.py b/pym/repoman/modules/vcs/cvs/changes.py index 6accd4a..061486f 100644 --- a/pym/repoman/modules/vcs/cvs/changes.py +++ b/pym/repoman/modules/vcs/cvs/changes.py @@ -41,6 +41,27 @@ class Changes(ChangesBase): return self._unadded self._unadded = portage.cvstree.findunadded(self._tree, recursive=1, basedir="./") return self._unadded + + @staticmethod + def clear_attic(myheaders): + cvs_header_re = re.compile(br'^#\s*\$Header.*\$$') + attic_str = b'/Attic/' + attic_replace = b'/' + for x in myheaders: + f = open( + _unicode_encode(x, encoding=_encodings['fs'], errors='strict'), + mode='rb') + mylines = f.readlines() + f.close() + modified = False + for i, line in enumerate(mylines): + if cvs_header_re.match(line) is not None and \ + attic_str in line: + mylines[i] = line.replace(attic_str, attic_replace) + modified = True + if modified: + portage.util.write_atomic(x, b''.join(mylines), mode='wb') + def thick_manifest(self, myupdates, myheaders, no_expansion, expansion): headerstring = "'\$(Header|Id).*\$'"
[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/git/, pym/repoman/, ...
commit: cada36afb2420cf4beb032c407bc337155ee9eee Author: Brian Dolbec gentoo org> AuthorDate: Sun Feb 7 18:50:21 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 10 23:47:35 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=cada36af repoman: Add repo_settings to VCSSettings class and the Changes classes Needed for more code migration from atcions.py to the vcs modules. pym/repoman/main.py | 4 pym/repoman/modules/vcs/None/changes.py | 4 ++-- pym/repoman/modules/vcs/bzr/changes.py | 4 ++-- pym/repoman/modules/vcs/changes.py | 4 +++- pym/repoman/modules/vcs/cvs/changes.py | 4 ++-- pym/repoman/modules/vcs/git/changes.py | 4 ++-- pym/repoman/modules/vcs/hg/changes.py | 4 ++-- pym/repoman/modules/vcs/svn/changes.py | 4 ++-- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/pym/repoman/main.py b/pym/repoman/main.py index 6921005..337e638 100755 --- a/pym/repoman/main.py +++ b/pym/repoman/main.py @@ -84,6 +84,7 @@ def repoman_main(argv): myreporoot = os.path.basename(portdir_overlay) myreporoot += mydir[len(portdir_overlay):] + # avoid a circular parameter repo_settings vcs_settings = VCSSettings(options, repoman_settings) repo_settings = RepoSettings( @@ -91,6 +92,9 @@ def repoman_main(argv): repoman_settings, vcs_settings, options, qawarnings) repoman_settings = repo_settings.repoman_settings + # Now set repo_settings + vcs_settings.repo_settings = repo_settings + if 'digest' in repoman_settings.features and options.digest != 'n': options.digest = 'y' diff --git a/pym/repoman/modules/vcs/None/changes.py b/pym/repoman/modules/vcs/None/changes.py index 759b554..37693ad 100644 --- a/pym/repoman/modules/vcs/None/changes.py +++ b/pym/repoman/modules/vcs/None/changes.py @@ -12,12 +12,12 @@ class Changes(ChangesBase): vcs = 'None' - def __init__(self, options): + def __init__(self, options, repo_settings): '''Class init @param options: commandline options ''' - super(Changes, self).__init__(options) + super(Changes, self).__init__(options, repo_settings) def scan(self): '''VCS type scan function, looks for all detectable changes''' diff --git a/pym/repoman/modules/vcs/bzr/changes.py b/pym/repoman/modules/vcs/bzr/changes.py index 519d311..9bd0646 100644 --- a/pym/repoman/modules/vcs/bzr/changes.py +++ b/pym/repoman/modules/vcs/bzr/changes.py @@ -13,12 +13,12 @@ class Changes(ChangesBase): vcs = 'bzr' - def __init__(self, options): + def __init__(self, options, repo_settings): '''Class init @param options: commandline options ''' - super(Changes, self).__init__(options) + super(Changes, self).__init__(options, repo_settings) def _scan(self): '''VCS type scan function, looks for all detectable changes''' diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py index 1745a65..921e9b5 100644 --- a/pym/repoman/modules/vcs/changes.py +++ b/pym/repoman/modules/vcs/changes.py @@ -13,8 +13,10 @@ class ChangesBase(object): vcs = 'None' - def __init__(self, options): + def __init__(self, options, repo_settings): self.options = options + self.repo_settings = repo_settings + self.repoman_settings = repo_settings.repoman_settings self._reset() def _reset(self): diff --git a/pym/repoman/modules/vcs/cvs/changes.py b/pym/repoman/modules/vcs/cvs/changes.py index 061486f..5fc9642 100644 --- a/pym/repoman/modules/vcs/cvs/changes.py +++ b/pym/repoman/modules/vcs/cvs/changes.py @@ -16,12 +16,12 @@ class Changes(ChangesBase): vcs = 'cvs' - def __init__(self, options): + def __init__(self, options, repo_settings): '''Class init @param options: commandline options ''' - super(Changes, self).__init__(options) + super(Changes, self).__init__(options, repo_settings) self._tree = None def _scan(self): diff --git a/pym/repoman/modules/vcs/git/changes.py b/pym/repoman/modules/vcs/git/changes.py index d0b6acd..f159298 100644 --- a/pym/repoman/modules/vcs/git/changes.py +++ b/pym/repoman/modules/vcs/git/changes.py @@ -13,12 +13,12 @@ class Changes(ChangesBase): vcs = 'git' - def __init__(self, options): + def __init__(self, options, repo_settings): '''Class init @param options: commandline options ''' - super(Changes, self).__init__(options) + super(Changes, self).__init__(options, repo_settings) def
[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/None/, ...
commit: 2dd56cc49565387512d5cf209c4c003f19741bf9 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jan 30 07:58:04 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 10 23:47:35 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=2dd56cc4 repoman: Create docstrings for all new vcs module files pym/repoman/modules/vcs/None/changes.py | 9 - pym/repoman/modules/vcs/None/status.py | 35 ++--- pym/repoman/modules/vcs/bzr/__init__.py | 2 +- pym/repoman/modules/vcs/bzr/changes.py | 9 - pym/repoman/modules/vcs/bzr/status.py | 30 pym/repoman/modules/vcs/changes.py | 3 +++ pym/repoman/modules/vcs/cvs/__init__.py | 2 +- pym/repoman/modules/vcs/cvs/changes.py | 8 +++- pym/repoman/modules/vcs/cvs/status.py | 18 + pym/repoman/modules/vcs/git/__init__.py | 2 +- pym/repoman/modules/vcs/git/changes.py | 9 - pym/repoman/modules/vcs/git/status.py | 33 +++ pym/repoman/modules/vcs/hg/__init__.py | 2 +- pym/repoman/modules/vcs/hg/changes.py | 9 - pym/repoman/modules/vcs/hg/status.py| 31 + pym/repoman/modules/vcs/settings.py | 2 +- pym/repoman/modules/vcs/svn/__init__.py | 2 +- pym/repoman/modules/vcs/svn/changes.py | 9 - pym/repoman/modules/vcs/svn/status.py | 27 ++--- 19 files changed, 220 insertions(+), 22 deletions(-) diff --git a/pym/repoman/modules/vcs/None/changes.py b/pym/repoman/modules/vcs/None/changes.py index f95af69..759b554 100644 --- a/pym/repoman/modules/vcs/None/changes.py +++ b/pym/repoman/modules/vcs/None/changes.py @@ -1,4 +1,6 @@ - +''' +None module Changes class submodule +''' from repoman.modules.vcs.changes import ChangesBase @@ -11,7 +13,12 @@ class Changes(ChangesBase): vcs = 'None' def __init__(self, options): + '''Class init + + @param options: commandline options + ''' super(Changes, self).__init__(options) def scan(self): + '''VCS type scan function, looks for all detectable changes''' pass diff --git a/pym/repoman/modules/vcs/None/status.py b/pym/repoman/modules/vcs/None/status.py index b23fa10..d6e5ca0 100644 --- a/pym/repoman/modules/vcs/None/status.py +++ b/pym/repoman/modules/vcs/None/status.py @@ -1,24 +1,53 @@ - +''' +None (non-VCS) module Status class submodule +''' class Status(object): + '''Performs status checks on the svn repository''' def __init__(self, qatracker, eadded): + '''Class init + + @param qatracker: QATracker class instance + @param eadded: list + ''' self.qatracker = qatracker self.eadded = eadded def check(self, checkdir, checkdir_relative, xpkg): + '''Perform the svn status check + + @param checkdir: string of the directory being checked + @param checkdir_relative: string of the relative directory being checked + @param xpkg: string of the package being checked + @returns: boolean + ''' return True @staticmethod - def supports_gpg_sign(): + def detect_conflicts(options): + '''Are there any merge conflicts present in the VCS tracking system + + @param options: command line options + @returns: Boolean + ''' return False @staticmethod - def detect_conflicts(options): + def supports_gpg_sign(): + '''Does this vcs system support gpg commit signatures + + @returns: Boolean + ''' return False @staticmethod def isVcsDir(dirname): + '''Is the directory belong to the vcs system + + @param dirname: string, directory name + @returns: Boolean + ''' return False diff --git a/pym/repoman/modules/vcs/bzr/__init__.py b/pym/repoman/modules/vcs/bzr/__init__.py index 1192782..4490ed8 100644 --- a/pym/repoman/modules/vcs/bzr/__init__.py +++ b/pym/repoman/modules/vcs/bzr/__init__.py @@ -1,7 +1,7 @@ # Copyright 2014-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -doc = """BZR plug-in module for portage. +doc = """Bazaar (bzr) plug-in module for portage. Performs variaous Bazaar actions and checks on repositories.""" __doc__ = doc[:] diff --git a/pym/repoman/modules/vcs/bzr/changes.py b/pym/repoman/modules/vcs/bzr/changes.py index 41ce347..519d311 100644 --- a/pym/repoman/modules/vcs/bzr/changes.py +++ b/pym/repoman/modules/vcs/bzr/changes.py @@ -1,4 +1,6 @@ - +''' +Bazaar module Changes class submodule +''' from
[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/, pym/repoman/
commit: e83b512387046deedca87a48b689ebe8e1a44b1e Author: Brian Dolbec gentoo org> AuthorDate: Sun Feb 7 18:46:27 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 10 23:47:35 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e83b5123 repoman: Move clear_attic() code to the modules pym/repoman/actions.py | 24 +--- pym/repoman/modules/vcs/changes.py | 4 pym/repoman/modules/vcs/cvs/changes.py | 21 + 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py index f477aec..8ff658c 100644 --- a/pym/repoman/actions.py +++ b/pym/repoman/actions.py @@ -153,7 +153,7 @@ class Actions(object): # inside the $Header path. This code detects the problem and corrects it # so that the Manifest will generate correctly. See bug #169500. # Use binary mode in order to avoid potential character encoding issues. - self.clear_attic(myheaders) + self.vcs_settings.changes.clear_attic(myheaders) if self.scanner.repolevel == 1: utilities.repoman_sez( @@ -582,28 +582,6 @@ class Actions(object): pass - - - def clear_attic(self, myheaders): - cvs_header_re = re.compile(br'^#\s*\$Header.*\$$') - attic_str = b'/Attic/' - attic_replace = b'/' - for x in myheaders: - f = open( - _unicode_encode(x, encoding=_encodings['fs'], errors='strict'), - mode='rb') - mylines = f.readlines() - f.close() - modified = False - for i, line in enumerate(mylines): - if cvs_header_re.match(line) is not None and \ - attic_str in line: - mylines[i] = line.replace(attic_str, attic_replace) - modified = True - if modified: - portage.util.write_atomic(x, b''.join(mylines), mode='wb') - - def sign_manifest(self, myupdates, myremoved, mymanifests): try: for x in sorted(vcs_files_to_cps( diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py index 77d7dc1..1745a65 100644 --- a/pym/repoman/modules/vcs/changes.py +++ b/pym/repoman/modules/vcs/changes.py @@ -74,3 +74,7 @@ class ChangesBase(object): '''Create a thick manifest''' pass + @staticmethod + def clear_attic(myheaders): + '''Old CVS leftover''' + pass diff --git a/pym/repoman/modules/vcs/cvs/changes.py b/pym/repoman/modules/vcs/cvs/changes.py index 6accd4a..061486f 100644 --- a/pym/repoman/modules/vcs/cvs/changes.py +++ b/pym/repoman/modules/vcs/cvs/changes.py @@ -41,6 +41,27 @@ class Changes(ChangesBase): return self._unadded self._unadded = portage.cvstree.findunadded(self._tree, recursive=1, basedir="./") return self._unadded + + @staticmethod + def clear_attic(myheaders): + cvs_header_re = re.compile(br'^#\s*\$Header.*\$$') + attic_str = b'/Attic/' + attic_replace = b'/' + for x in myheaders: + f = open( + _unicode_encode(x, encoding=_encodings['fs'], errors='strict'), + mode='rb') + mylines = f.readlines() + f.close() + modified = False + for i, line in enumerate(mylines): + if cvs_header_re.match(line) is not None and \ + attic_str in line: + mylines[i] = line.replace(attic_str, attic_replace) + modified = True + if modified: + portage.util.write_atomic(x, b''.join(mylines), mode='wb') + def thick_manifest(self, myupdates, myheaders, no_expansion, expansion): headerstring = "'\$(Header|Id).*\$'"
[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/None/, ...
commit: d6f695d66ac9160842256970a1aea63d4f47f6b0 Author: Brian Dolbec gentoo org> AuthorDate: Tue Feb 16 20:06:30 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Mar 8 03:13:28 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d6f695d6 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 | 16 +++ 7 files changed, 82 insertions(+), 63 deletions(-) diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py index d2e4fc1..4aec1e0 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 @@ -432,43 +430,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): @@ -492,29 +465,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)
[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/git/, ...
commit: de59c489c3ad388a062b8d60a6df376a5f1c6eb2 Author: Brian Dolbec gentoo org> AuthorDate: Wed Feb 10 18:10:04 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Feb 10 18:10:04 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=de59c489 repoman: Migrate teh 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 | 19 pym/repoman/modules/vcs/cvs/changes.py | 1 - pym/repoman/modules/vcs/git/changes.py | 10 pym/repoman/modules/vcs/hg/changes.py | 16 +++ 7 files changed, 81 insertions(+), 63 deletions(-) diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py index cdd..4393e52 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 @@ -432,43 +430,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): @@ -492,29 +465,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)
[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/, ...
commit: f8198d98b7d195b0b42fecf648022fd5bcd4e4a8 Author: Brian Dolbec gentoo org> AuthorDate: Sun Feb 7 18:32:59 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sun Feb 7 18:32:59 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=f8198d98 repoman: Migrate thick_manifest to the vcs Changes classes pym/repoman/actions.py | 53 ++ pym/repoman/modules/vcs/changes.py | 5 pym/repoman/modules/vcs/cvs/changes.py | 19 pym/repoman/modules/vcs/svn/changes.py | 42 +++ 4 files changed, 68 insertions(+), 51 deletions(-) diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py index 15a0d04..20116db 100644 --- a/pym/repoman/actions.py +++ b/pym/repoman/actions.py @@ -131,7 +131,8 @@ class Actions(object): print() elif not self.repo_settings.repo_config.thin_manifest: logging.debug("perform: Calling thick_manifest()") - self.thick_manifest(myupdates, myheaders, no_expansion, expansion) + self.vcs_settings.changes.thick_manifest(myupdates, myheaders, + no_expansion, expansion) logging.info("myupdates: %s", myupdates) logging.info("myheaders: %s", myheaders) @@ -570,56 +571,6 @@ class Actions(object): pass - def thick_manifest(self, myupdates, myheaders, no_expansion, expansion): - if self.vcs_settings.vcs == 'cvs': - headerstring = "'\$(Header|Id).*\$'" - elif self.vcs_settings.vcs == "svn": - svn_keywords = dict((k.lower(), k) for k in [ - "Rev", - "Revision", - "LastChangedRevision", - "Date", - "LastChangedDate", - "Author", - "LastChangedBy", - "URL", - "HeadURL", - "Id", - "Header", - ]) - - for myfile in myupdates: - - # for CVS, no_expansion contains files that are excluded from expansion - if self.vcs_settings.vcs == "cvs": - if myfile in no_expansion: - continue - - # for SVN, expansion contains files that are included in expansion - elif self.vcs_settings.vcs == "svn": - if myfile not in expansion: - continue - - # Subversion keywords are case-insensitive - # in svn:keywords properties, - # but case-sensitive in contents of files. - enabled_keywords = [] - for k in expansion[myfile]: - keyword = svn_keywords.get(k.lower()) - if keyword is not None: - enabled_keywords.append(keyword) - - headerstring = "'\$(%s).*\$'" % "|".join(enabled_keywords) - - myout = repoman_getstatusoutput( - "egrep -q %s %s" % (headerstring, portage._shell_quote(myfile))) - if myout[0] == 0: - myheaders.append(myfile) - - print("%s have headers that will change." % green(str(len(myheaders - print( - "* Files with headers will" - " cause the manifests to be changed and committed separately.") def clear_attic(self, myheaders): diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py index 76ad591..77d7dc1 100644 --- a/pym/repoman/modules/vcs/changes.py +++ b/pym/repoman/modules/vcs/changes.py @@ -69,3 +69,8 @@ class ChangesBase(object): def expansion(self): '''Override this function as needed''' return {} + + def thick_manifest(self, myupdates, myheaders, no_expansion, expansion): + '''Create a thick manifest''' + pass + diff --git a/pym/repoman/modules/vcs/cvs/changes.py b/pym/repoman/modules/vcs/cvs/changes.py index 3ef91cc..6accd4a 100644 --- a/pym/repoman/modules/vcs/cvs/changes.py +++ b/pym/repoman/modules/vcs/cvs/changes.py @@ -41,3 +41,22 @@ class Changes(ChangesBase): return self._unadded self._unadded = portage.cvstree.findunadded(self._tree, recursive=1, basedir="./")
[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/, pym/repoman/
commit: d521c64172b6da67aabb8752f2b0a8b2bea9e5d3 Author: Brian Dolbec gentoo org> AuthorDate: Sun Feb 7 18:46:27 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sun Feb 7 18:46:27 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d521c641 repoman: Move clear_attic() code to the modules pym/repoman/actions.py | 24 +--- pym/repoman/modules/vcs/changes.py | 4 pym/repoman/modules/vcs/cvs/changes.py | 21 + 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py index 20116db..e045295 100644 --- a/pym/repoman/actions.py +++ b/pym/repoman/actions.py @@ -152,7 +152,7 @@ class Actions(object): # inside the $Header path. This code detects the problem and corrects it # so that the Manifest will generate correctly. See bug #169500. # Use binary mode in order to avoid potential character encoding issues. - self.clear_attic(myheaders) + self.vcs_settings.changes.clear_attic(myheaders) if self.scanner.repolevel == 1: utilities.repoman_sez( @@ -571,28 +571,6 @@ class Actions(object): pass - - - def clear_attic(self, myheaders): - cvs_header_re = re.compile(br'^#\s*\$Header.*\$$') - attic_str = b'/Attic/' - attic_replace = b'/' - for x in myheaders: - f = open( - _unicode_encode(x, encoding=_encodings['fs'], errors='strict'), - mode='rb') - mylines = f.readlines() - f.close() - modified = False - for i, line in enumerate(mylines): - if cvs_header_re.match(line) is not None and \ - attic_str in line: - mylines[i] = line.replace(attic_str, attic_replace) - modified = True - if modified: - portage.util.write_atomic(x, b''.join(mylines), mode='wb') - - def sign_manifest(self, myupdates, myremoved, mymanifests): try: for x in sorted(vcs_files_to_cps( diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py index 77d7dc1..1745a65 100644 --- a/pym/repoman/modules/vcs/changes.py +++ b/pym/repoman/modules/vcs/changes.py @@ -74,3 +74,7 @@ class ChangesBase(object): '''Create a thick manifest''' pass + @staticmethod + def clear_attic(myheaders): + '''Old CVS leftover''' + pass diff --git a/pym/repoman/modules/vcs/cvs/changes.py b/pym/repoman/modules/vcs/cvs/changes.py index 6accd4a..061486f 100644 --- a/pym/repoman/modules/vcs/cvs/changes.py +++ b/pym/repoman/modules/vcs/cvs/changes.py @@ -41,6 +41,27 @@ class Changes(ChangesBase): return self._unadded self._unadded = portage.cvstree.findunadded(self._tree, recursive=1, basedir="./") return self._unadded + + @staticmethod + def clear_attic(myheaders): + cvs_header_re = re.compile(br'^#\s*\$Header.*\$$') + attic_str = b'/Attic/' + attic_replace = b'/' + for x in myheaders: + f = open( + _unicode_encode(x, encoding=_encodings['fs'], errors='strict'), + mode='rb') + mylines = f.readlines() + f.close() + modified = False + for i, line in enumerate(mylines): + if cvs_header_re.match(line) is not None and \ + attic_str in line: + mylines[i] = line.replace(attic_str, attic_replace) + modified = True + if modified: + portage.util.write_atomic(x, b''.join(mylines), mode='wb') + def thick_manifest(self, myupdates, myheaders, no_expansion, expansion): headerstring = "'\$(Header|Id).*\$'"
[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/bzr/, ...
commit: 7c06bfba625e89ccad8c8c565999893028e01119 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jan 30 01:58:36 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jan 30 07:50:22 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=7c06bfba repoman: Migrate actions.py vcs code to the vcs modules Add missing changes code to the existing Changes classes. This removes the duplicated code in the Actions class. It alsosspeeds up the run by not calling the vcs binary to scan for changes a second time. Optimize the code for the vcs modules. pym/repoman/actions.py | 208 --- pym/repoman/modules/vcs/None/__init__.py | 1 + pym/repoman/modules/vcs/bzr/__init__.py | 1 + pym/repoman/modules/vcs/bzr/changes.py | 15 ++- pym/repoman/modules/vcs/changes.py | 13 ++ pym/repoman/modules/vcs/cvs/__init__.py | 1 + pym/repoman/modules/vcs/cvs/changes.py | 13 +- pym/repoman/modules/vcs/git/__init__.py | 1 + pym/repoman/modules/vcs/git/changes.py | 20 +-- pym/repoman/modules/vcs/hg/__init__.py | 1 + pym/repoman/modules/vcs/hg/changes.py| 27 +++- pym/repoman/modules/vcs/settings.py | 5 +- pym/repoman/modules/vcs/svn/__init__.py | 1 + pym/repoman/modules/vcs/svn/changes.py | 24 +++- 14 files changed, 118 insertions(+), 213 deletions(-) diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py index 3fd940c..8cf4a97 100644 --- a/pym/repoman/actions.py +++ b/pym/repoman/actions.py @@ -16,7 +16,6 @@ from itertools import chain from _emerge.UserQuery import UserQuery import portage -from portage import cvstree from portage import os from portage import _encodings from portage import _unicode_encode @@ -26,8 +25,7 @@ from portage.package.ebuild.digestgen import digestgen from portage.process import find_binary, spawn from portage.util import writemsg_level -from repoman._subprocess import repoman_popen, repoman_getstatusoutput -from repoman.errors import err +from repoman._subprocess import repoman_getstatusoutput from repoman.gpg import gpgsign, need_signature from repoman import utilities from repoman.modules.vcs.vcs import vcs_files_to_cps @@ -71,13 +69,11 @@ class Actions(object): def perform(self, qa_output): - myunadded, mydeleted = self._vcs_unadded() + myautoadd = self._vcs_autoadd() - myautoadd = self._vcs_autoadd(myunadded) + self._vcs_deleted() - self._vcs_deleted(mydeleted) - - changes = self.get_vcs_changed(mydeleted) + changes = self.get_vcs_changed() mynew, mychanged, myremoved, no_expansion, expansion = changes @@ -127,8 +123,8 @@ class Actions(object): print("* %s files being committed..." % green(str(len(myupdates))), end=' ') - if self.vcs_settings.vcs not in ('cvs', 'svn'): - # With git, bzr and hg, there's never any keyword expansion, so + if self.vcs_settings.needs_keyword_expansion: + # With some VCS types there's never any keyword expansion, so # there's no need to regenerate manifests and all files will be # committed in one big commit at the end. print() @@ -261,62 +257,8 @@ class Actions(object): sys.exit(1) - def _vcs_unadded(self): - myunadded = [] - mydeleted = [] - if self.vcs_settings.vcs == "cvs": - try: - myvcstree = portage.cvstree.getentries("./", recursive=1) - myunadded = portage.cvstree.findunadded( - myvcstree, recursive=1, basedir="./") - except SystemExit: - raise # TODO propagate this - except: - err("Error retrieving CVS tree; exiting.") - if self.vcs_settings.vcs == "svn": - try: - with repoman_popen("svn status --no-ignore") as f: - svnstatus = f.readlines() - myunadded = [ - "./" + elem.rstrip().split()[1] - for elem in svnstatus - if elem.startswith("?") or elem.startswith("I")] - except SystemExit: - raise # TODO propagate this - except: - err("Error retrieving SVN info; exiting.") - if self.vcs_settings.vcs == "git": - # get list of files not under version control or missing - myf = repoman_popen("git ls-files
[gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/bzr/, ...
commit: 7ed3cb06a165bdd933a2faf43ff839920cf5d704 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jan 30 07:58:04 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jan 30 07:58:04 2016 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=7ed3cb06 repoman: Create docstrings for all new vcs module files pym/repoman/modules/vcs/None/changes.py | 9 - pym/repoman/modules/vcs/None/status.py | 35 ++--- pym/repoman/modules/vcs/bzr/__init__.py | 2 +- pym/repoman/modules/vcs/bzr/changes.py | 9 - pym/repoman/modules/vcs/bzr/status.py | 30 pym/repoman/modules/vcs/changes.py | 3 +++ pym/repoman/modules/vcs/cvs/__init__.py | 2 +- pym/repoman/modules/vcs/cvs/changes.py | 9 - pym/repoman/modules/vcs/cvs/status.py | 18 + pym/repoman/modules/vcs/git/__init__.py | 2 +- pym/repoman/modules/vcs/git/changes.py | 9 - pym/repoman/modules/vcs/git/status.py | 33 +++ pym/repoman/modules/vcs/hg/__init__.py | 2 +- pym/repoman/modules/vcs/hg/changes.py | 9 - pym/repoman/modules/vcs/hg/status.py| 31 + pym/repoman/modules/vcs/settings.py | 2 +- pym/repoman/modules/vcs/svn/__init__.py | 2 +- pym/repoman/modules/vcs/svn/changes.py | 9 - pym/repoman/modules/vcs/svn/status.py | 27 ++--- 19 files changed, 221 insertions(+), 22 deletions(-) diff --git a/pym/repoman/modules/vcs/None/changes.py b/pym/repoman/modules/vcs/None/changes.py index f95af69..759b554 100644 --- a/pym/repoman/modules/vcs/None/changes.py +++ b/pym/repoman/modules/vcs/None/changes.py @@ -1,4 +1,6 @@ - +''' +None module Changes class submodule +''' from repoman.modules.vcs.changes import ChangesBase @@ -11,7 +13,12 @@ class Changes(ChangesBase): vcs = 'None' def __init__(self, options): + '''Class init + + @param options: commandline options + ''' super(Changes, self).__init__(options) def scan(self): + '''VCS type scan function, looks for all detectable changes''' pass diff --git a/pym/repoman/modules/vcs/None/status.py b/pym/repoman/modules/vcs/None/status.py index b23fa10..d6e5ca0 100644 --- a/pym/repoman/modules/vcs/None/status.py +++ b/pym/repoman/modules/vcs/None/status.py @@ -1,24 +1,53 @@ - +''' +None (non-VCS) module Status class submodule +''' class Status(object): + '''Performs status checks on the svn repository''' def __init__(self, qatracker, eadded): + '''Class init + + @param qatracker: QATracker class instance + @param eadded: list + ''' self.qatracker = qatracker self.eadded = eadded def check(self, checkdir, checkdir_relative, xpkg): + '''Perform the svn status check + + @param checkdir: string of the directory being checked + @param checkdir_relative: string of the relative directory being checked + @param xpkg: string of the package being checked + @returns: boolean + ''' return True @staticmethod - def supports_gpg_sign(): + def detect_conflicts(options): + '''Are there any merge conflicts present in the VCS tracking system + + @param options: command line options + @returns: Boolean + ''' return False @staticmethod - def detect_conflicts(options): + def supports_gpg_sign(): + '''Does this vcs system support gpg commit signatures + + @returns: Boolean + ''' return False @staticmethod def isVcsDir(dirname): + '''Is the directory belong to the vcs system + + @param dirname: string, directory name + @returns: Boolean + ''' return False diff --git a/pym/repoman/modules/vcs/bzr/__init__.py b/pym/repoman/modules/vcs/bzr/__init__.py index 1192782..4490ed8 100644 --- a/pym/repoman/modules/vcs/bzr/__init__.py +++ b/pym/repoman/modules/vcs/bzr/__init__.py @@ -1,7 +1,7 @@ # Copyright 2014-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -doc = """BZR plug-in module for portage. +doc = """Bazaar (bzr) plug-in module for portage. Performs variaous Bazaar actions and checks on repositories.""" __doc__ = doc[:] diff --git a/pym/repoman/modules/vcs/bzr/changes.py b/pym/repoman/modules/vcs/bzr/changes.py index dab5d73..751d803 100644 --- a/pym/repoman/modules/vcs/bzr/changes.py +++ b/pym/repoman/modules/vcs/bzr/changes.py @@ -1,4 +1,6 @@ - +''' +Bazaar module Changes class submodule +''' from