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/git/
Date: Fri, 02 May 2014 23:13:40
Message-Id: 1399072090.533f07434f5cb2671e01f6c4225494e910f2154f.dol-sen@gentoo
1 commit: 533f07434f5cb2671e01f6c4225494e910f2154f
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Fri Mar 14 15:55:07 2014 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Fri May 2 23:08:10 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=533f0743
7
8 portage/sync/modules/git: Use SyncBase class.
9
10 Use self.bin_command for the binary call.
11
12 ---
13 pym/portage/sync/modules/git/git.py | 56 ++++++-------------------------------
14 1 file changed, 8 insertions(+), 48 deletions(-)
15
16 diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
17 index 6806ef3..5e0e5df 100644
18 --- a/pym/portage/sync/modules/git/git.py
19 +++ b/pym/portage/sync/modules/git/git.py
20 @@ -11,9 +11,10 @@ good = create_color_func("GOOD")
21 bad = create_color_func("BAD")
22 warn = create_color_func("WARN")
23 from .timestamps import git_sync_timestamps
24 +from portage.sync.syncbase import SyncBase
25
26
27 -class GitSync(object):
28 +class GitSync(SyncBase):
29 '''Git sync class'''
30
31 short_desc = "Perform sync operations on git based repositories"
32 @@ -23,34 +24,8 @@ class GitSync(object):
33 return "GitSync"
34
35
36 - def can_progressbar(self, func):
37 - return False
38 -
39 -
40 def __init__(self):
41 - self.options = None
42 - self.settings = None
43 - self.logger = None
44 - self.repo = None
45 - self.xterm_titles = None
46 -
47 - self.has_git = True
48 - if portage.process.find_binary("git") is None:
49 - msg = ["Command not found: git",
50 - "Type \"emerge %s\" to enable git support." % portage.const.GIT_PACKAGE_ATOM]
51 - for l in msg:
52 - writemsg_level("!!! %s\n" % l,
53 - level=logging.ERROR, noiselevel=-1)
54 - self.has_git = False
55 -
56 -
57 - def _kwargs(self, kwargs):
58 - '''Sets internal variables from kwargs'''
59 - self.options = kwargs.get('options', {})
60 - self.settings = self.options.get('settings', None)
61 - self.logger = self.options.get('logger', None)
62 - self.repo = self.options.get('repo', None)
63 - self.xterm_titles = self.options.get('xterm_titles', False)
64 + SyncBase.__init__(self, "git", portage.const.GIT_PACKAGE_ATOM)
65
66
67 def exists(self, **kwargs):
68 @@ -59,37 +34,22 @@ class GitSync(object):
69 self._kwargs(kwargs)
70 elif not self.repo:
71 return False
72 - spawn_kwargs = self.options.get('spawn_kwargs', None)
73
74 if not os.path.exists(self.repo.location):
75 return False
76 exitcode = portage.process.spawn_bash("cd %s ; git rev-parse" %\
77 (portage._shell_quote(self.repo.location),),
78 - **portage._native_kwargs(spawn_kwargs))
79 + **portage._native_kwargs(self.spawn_kwargs))
80 if exitcode == 128:
81 return False
82 return True
83
84
85 - def sync(self, **kwargs):
86 - '''Sync/Clone the repository'''
87 - if kwargs:
88 - self._kwargs(kwargs)
89 -
90 - if not self.has_git:
91 - return (1, False)
92 -
93 - if not self.exists():
94 - return self.new()
95 - return self._sync()
96 -
97 -
98 def new(self, **kwargs):
99 '''Do the initial clone of the repository'''
100 if kwargs:
101 self._kwargs(kwargs)
102 emerge_config = self.options.get('emerge_config', None)
103 - spawn_kwargs = self.options.get('spawn_kwargs', None)
104 portdb = self.options.get('portdb', None)
105 try:
106 if not os.path.exists(self.repo.location):
107 @@ -101,10 +61,11 @@ class GitSync(object):
108 msg = ">>> Cloning git repository from upstream into %s..." % self.repo.location
109 self.logger(self.xterm_titles, msg)
110 writemsg_level(msg + "\n")
111 - exitcode = portage.process.spawn_bash("cd %s ; git clone %s ." % \
112 + exitcode = portage.process.spawn_bash("cd %s ; %s clone %s ." % \
113 (portage._shell_quote(self.repo.location),
114 + self.bin_command,
115 portage._shell_quote(self.repo.sync_uri)),
116 - **portage._native_kwargs(spawn_kwargs))
117 + **portage._native_kwargs(self.spawn_kwargs))
118 if exitcode != os.EX_OK:
119 msg = "!!! git clone error in %s" % self.repo.location
120 self.logger(self.xterm_titles, msg)
121 @@ -125,7 +86,6 @@ class GitSync(object):
122 # No kwargs call here; this is internal, so it should have been
123 # called by something which set the internal variables
124 emerge_config = self.options.get('emerge_config', None)
125 - spawn_kwargs = self.options.get('spawn_kwargs', None)
126 portdb = self.options.get('portdb', None)
127
128 msg = ">>> Starting git pull in %s..." % self.repo.location
129 @@ -133,7 +93,7 @@ class GitSync(object):
130 writemsg_level(msg + "\n")
131 exitcode = portage.process.spawn_bash("cd %s ; git pull" % \
132 (portage._shell_quote(self.repo.location),),
133 - **portage._native_kwargs(spawn_kwargs))
134 + **portage._native_kwargs(self.spawn_kwargs))
135 if exitcode != os.EX_OK:
136 msg = "!!! git pull error in %s" % self.repo.location
137 self.logger(self.xterm_titles, msg)