Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
Date: Fri, 02 May 2014 23:13:41
Message-Id: 1399072156.4135c7482c4ab327291de32120b40295088ba9cf.dol-sen@gentoo
1 commit: 4135c7482c4ab327291de32120b40295088ba9cf
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Fri Mar 14 15:56:00 2014 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Fri May 2 23:09:16 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4135c748
7
8 portage/sync/modules/cvs: Use SyncBase class.
9
10 ---
11 pym/portage/sync/modules/cvs/cvs.py | 58 +++++--------------------------------
12 1 file changed, 7 insertions(+), 51 deletions(-)
13
14 diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py
15 index dadbf7b..52d5d9a 100644
16 --- a/pym/portage/sync/modules/cvs/cvs.py
17 +++ b/pym/portage/sync/modules/cvs/cvs.py
18 @@ -1,16 +1,16 @@
19 # Copyright 1999-2014 Gentoo Foundation
20 # Distributed under the terms of the GNU General Public License v2
21
22 -import sys
23 import logging
24 import errno
25
26 import portage
27 from portage import os
28 from portage.util import writemsg_level
29 +from portage.sync.syncbase import SyncBase
30
31
32 -class CVSSync(object):
33 +class CVSSync(SyncBase):
34 '''CVS sync module'''
35
36 short_desc = "Perform sync operations on CVS repositories"
37 @@ -20,53 +20,8 @@ class CVSSync(object):
38 return "CVSSync"
39
40
41 - def can_progressbar(self, func):
42 - return False
43 -
44 -
45 def __init__(self):
46 - self.settings = None
47 - self.options = None
48 - self.logger = None
49 - self.xterm_titles = None
50 - self.has_cvs = True
51 - if portage.process.find_binary("cvs") is None:
52 - msg = "Command not found: cvs"
53 - "Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM
54 - for l in msg:
55 - writemsg_level("!!! %s\n" % l,
56 - level=logging.ERROR, noiselevel=-1)
57 - self.has_cvs = False
58 -
59 - def _kwargs(self, **kwargs):
60 - self.options = kwargs.get('options', {})
61 - self.repo = self.options.get('repo', None)
62 - self.logger = self.options.get('logger', None)
63 - self.xterm_titles = self.options.get('xterm_titles', None)
64 -
65 -
66 - def exists(self, **kwargs):
67 - if kwargs:
68 - self._kwargs(kwargs)
69 - elif not self.repo:
70 - return False
71 - spawn_kwargs = self.options.get('spawn_kwargs', None)
72 -
73 - if not os.path.exists(os.path.join(repo.location, "CVS")):
74 - return False
75 - return True
76 -
77 -
78 - def sync(self, **kwargs):
79 - if kwargs:
80 - self._kwargs(kwargs)
81 -
82 - if not self.has_cvs:
83 - return (1, False)
84 -
85 - if not self.exists():
86 - return self.new()
87 - return self.sync()
88 + SyncBase.__init__(self, "cvs", portage.const.CVS_PACKAGE_ATOM)
89
90
91 def new(self, **kwargs):
92 @@ -85,18 +40,20 @@ class CVSSync(object):
93 writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
94 return (1, False)
95 del e
96 + cvs_root = self.repo.sync_uri
97 if portage.process.spawn_bash(
98 "cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
99 (portage._shell_quote(os.path.dirname(self.repo.location)), portage._shell_quote(cvs_root),
100 portage._shell_quote(os.path.basename(self.repo.location)),
101 portage._shell_quote(self.repo.sync_cvs_repo)),
102 - **portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
103 + **portage._native_kwargs(self.spawn_kwargs)) != os.EX_OK:
104 msg = "!!! cvs checkout error; exiting."
105 self.logger(self.xterm_titles, msg)
106 writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
107 return (1, False)
108 return (0, False)
109
110 +
111 def _sync(self):
112 """
113 Internal function to sync an existing CVS repository
114 @@ -106,7 +63,6 @@ class CVSSync(object):
115 @rtype: (int, bool)
116 """
117
118 - spawn_kwargs = options.get('spawn_kwargs', None)
119 cvs_root = self.repo.sync_uri
120
121 if cvs_root.startswith("cvs://"):
122 @@ -118,7 +74,7 @@ class CVSSync(object):
123 exitcode = portage.process.spawn_bash(
124 "cd %s; exec cvs -z0 -q update -dP" % \
125 (portage._shell_quote(self.repo.location),),
126 - **portage._native_kwargs(spawn_kwargs))
127 + **portage._native_kwargs(self.spawn_kwargs))
128 if exitcode != os.EX_OK:
129 msg = "!!! cvs update error; exiting."
130 self.logger(self.xterm_titles, msg)