commit:     5970bd1432c54e5ab1138f2378eb30c86b182354
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 14 15:56:00 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jun 16 22:43:10 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5970bd14

portage/sync/modules/cvs: Use SyncBase class.

---
 pym/portage/sync/modules/cvs/cvs.py | 58 +++++--------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/cvs.py 
b/pym/portage/sync/modules/cvs/cvs.py
index dadbf7b..52d5d9a 100644
--- a/pym/portage/sync/modules/cvs/cvs.py
+++ b/pym/portage/sync/modules/cvs/cvs.py
@@ -1,16 +1,16 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import sys
 import logging
 import errno
 
 import portage
 from portage import os
 from portage.util import writemsg_level
+from portage.sync.syncbase import SyncBase
 
 
-class CVSSync(object):
+class CVSSync(SyncBase):
        '''CVS sync module'''
 
        short_desc = "Perform sync operations on CVS repositories"
@@ -20,53 +20,8 @@ class CVSSync(object):
                return "CVSSync"
 
 
-       def can_progressbar(self, func):
-               return False
-
-
        def __init__(self):
-               self.settings = None
-               self.options = None
-               self.logger = None
-               self.xterm_titles = None
-               self.has_cvs = True
-               if portage.process.find_binary("cvs") is None:
-                       msg = "Command not found: cvs"
-                       "Type \"emerge %s\" to enable CVS support." % 
portage.const.CVS_PACKAGE_ATOM
-                       for l in msg:
-                               writemsg_level("!!! %s\n" % l,
-                                       level=logging.ERROR, noiselevel=-1)
-                       self.has_cvs = False
-
-       def _kwargs(self, **kwargs):
-               self.options = kwargs.get('options', {})
-               self.repo = self.options.get('repo', None)
-               self.logger = self.options.get('logger', None)
-               self.xterm_titles = self.options.get('xterm_titles', None)
-
-
-       def exists(self, **kwargs):
-               if kwargs:
-                       self._kwargs(kwargs)
-               elif not self.repo:
-                       return False
-               spawn_kwargs = self.options.get('spawn_kwargs', None)
-
-               if not os.path.exists(os.path.join(repo.location, "CVS")):
-                       return False
-               return True
-
-
-       def sync(self, **kwargs):
-               if kwargs:
-                       self._kwargs(kwargs)
-
-               if not self.has_cvs:
-                       return (1, False)
-
-               if not self.exists():
-                       return self.new()
-               return self.sync()
+               SyncBase.__init__(self, "cvs", portage.const.CVS_PACKAGE_ATOM)
 
 
        def new(self, **kwargs):
@@ -85,18 +40,20 @@ class CVSSync(object):
                                writemsg_level(msg + "\n", noiselevel=-1, 
level=logging.ERROR)
                                return (1, False)
                        del e
+               cvs_root = self.repo.sync_uri
                if portage.process.spawn_bash(
                        "cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
                        
(portage._shell_quote(os.path.dirname(self.repo.location)), 
portage._shell_quote(cvs_root),
                                
portage._shell_quote(os.path.basename(self.repo.location)),
                                portage._shell_quote(self.repo.sync_cvs_repo)),
-                               **portage._native_kwargs(spawn_kwargs)) != 
os.EX_OK:
+                               **portage._native_kwargs(self.spawn_kwargs)) != 
os.EX_OK:
                        msg = "!!! cvs checkout error; exiting."
                        self.logger(self.xterm_titles, msg)
                        writemsg_level(msg + "\n", noiselevel=-1, 
level=logging.ERROR)
                        return (1, False)
                return (0, False)
 
+
        def _sync(self):
                """
                Internal function to sync an existing CVS repository
@@ -106,7 +63,6 @@ class CVSSync(object):
                @rtype: (int, bool)
                """
 
-               spawn_kwargs = options.get('spawn_kwargs', None)
                cvs_root = self.repo.sync_uri
 
                if cvs_root.startswith("cvs://"):
@@ -118,7 +74,7 @@ class CVSSync(object):
                        exitcode = portage.process.spawn_bash(
                                "cd %s; exec cvs -z0 -q update -dP" % \
                                (portage._shell_quote(self.repo.location),),
-                               **portage._native_kwargs(spawn_kwargs))
+                               **portage._native_kwargs(self.spawn_kwargs))
                        if exitcode != os.EX_OK:
                                msg = "!!! cvs update error; exiting."
                                self.logger(self.xterm_titles, msg)

Reply via email to