Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH v2] sync: support sync-depth for DVCS-es (git --depth)
Date: Sun, 18 Jan 2015 16:33:38
Message-Id: 20150118083317.23ab8d0f.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH v2] sync: support sync-depth for DVCS-es (git --depth) by "Michał Górny"
1 On Sun, 18 Jan 2015 11:33:49 +0100
2 Michał Górny <mgorny@g.o> wrote:
3
4 > Support sync-depth with the default set to 1. This allows the user
5 > to reduce the number of historical commits fetched along with the
6 > repository (git --depth).
7 > ---
8 > man/portage.5 | 6 +++++-
9 > pym/portage/repository/config.py | 6 +++++-
10 > pym/portage/sync/modules/git/__init__.py | 28
11 > +++++++++++++++++++++++++++- pym/portage/sync/modules/git/git.py
12 > | 6 +++++- 4 files changed, 42 insertions(+), 4 deletions(-)
13 >
14 > diff --git a/man/portage.5 b/man/portage.5
15 > index f0b0e20..5d0e7c0 100644
16 > --- a/man/portage.5
17 > +++ b/man/portage.5
18 > @@ -1,4 +1,4 @@
19 > -.TH "PORTAGE" "5" "Jan 2015" "Portage VERSION" "Portage"
20 > +TH "PORTAGE" "5" "Jan 2015" "Portage VERSION" "Portage"
21 > .SH NAME
22 > portage \- the heart of Gentoo
23 > .SH "DESCRIPTION"
24 > @@ -906,6 +906,10 @@ Specifies priority of given repository.
25 > .B sync\-cvs\-repo
26 > Specifies CVS repository.
27 > .TP
28 > +.B sync\-depth
29 > +Specifies clone depth to use for DVCS repositories. Defaults to 1
30 > (only +the newest commit). If set to 0, the depth is unlimited.
31 > +.TP
32 > .B sync\-type
33 > Specifies type of synchronization performed by `emerge \-\-sync`.
34 > .br
35 > diff --git a/pym/portage/repository/config.py
36 > b/pym/portage/repository/config.py index 7e17e02..84fc2ff 100644
37 > --- a/pym/portage/repository/config.py
38 > +++ b/pym/portage/repository/config.py
39 > @@ -88,7 +88,8 @@ class RepoConfig(object):
40 > 'profile_formats', 'sign_commit', 'sign_manifest',
41 > 'sync_cvs_repo', 'sync_type', 'sync_umask', 'sync_uri', 'sync_user',
42 > 'thin_manifest', 'update_changelog', 'user_location', '_eapis_banned',
43 > - '_eapis_deprecated', '_masters_orig')
44 > + '_eapis_deprecated', '_masters_orig',
45 > + 'sync_depth')
46 >
47 > def __init__(self, name, repo_opts, local_config=True):
48 > """Build a RepoConfig with options in repo_opts
49 > @@ -176,6 +177,8 @@ class RepoConfig(object):
50 > auto_sync = auto_sync.strip().lower()
51 > self.auto_sync = auto_sync
52 >
53 > + self.sync_depth = repo_opts.get('sync-depth')
54 > +
55
56 Yeah, just move this to sorted order like Arfrever said. Otherwise it
57 looks good, ready to merge.
58
59
60
61 > # Not implemented.
62 > format = repo_opts.get('format')
63 > if format is not None:
64 > @@ -489,6 +492,7 @@ class RepoConfigLoader(object):
65 > for k in ('aliases',
66 > 'auto_sync', 'eclass_overrides', 'force', 'masters', 'priority',
67 > 'sync_cvs_repo', 'sync_type', 'sync_umask', 'sync_uri', 'sync_user',
68 > + 'sync_depth',
69 > ):
70 > v =
71 > getattr(repos_conf_opts, k, None) if v is not None:
72 > diff --git a/pym/portage/sync/modules/git/__init__.py
73 > b/pym/portage/sync/modules/git/__init__.py index 833b389..a372881
74 > 100644 --- a/pym/portage/sync/modules/git/__init__.py
75 > +++ b/pym/portage/sync/modules/git/__init__.py
76 > @@ -5,7 +5,33 @@ doc = """Git plug-in module for portage.
77 > Performs a git pull on repositories."""
78 > __doc__ = doc[:]
79 >
80 > +from portage.localization import _
81 > from portage.sync.config_checks import CheckSyncConfig
82 > +from portage.util import writemsg_level
83 > +
84 > +
85 > +class CheckGitConfig(CheckSyncConfig):
86 > + def __init__(self, repo, logger):
87 > + CheckSyncConfig.__init__(self, repo, logger)
88 > + self.checks.append('check_depth')
89 > +
90 > + def check_depth(self):
91 > + d = self.repo.sync_depth
92 > + # default
93 > + self.repo.sync_depth = 1
94 > +
95 > + if d is not None:
96 > + try:
97 > + d = int(d)
98 > + except ValueError:
99 > + writemsg_level("!!! %s\n" %
100 > + _("sync-depth value is not a
101 > number: '%s'")
102 > + % (d),
103 > + level=self.logger.ERROR,
104 > noiselevel=-1)
105 > + else:
106 > + if d == 0:
107 > + d = None
108 > + self.repo.sync_depth = d
109 >
110 >
111 > module_spec = {
112 > @@ -23,7 +49,7 @@ module_spec = {
113 > 'exists': 'Returns a boolean of
114 > whether the specified dir ' + 'exists and is a valid Git repository',
115 > },
116 > - 'validate_config': CheckSyncConfig,
117 > + 'validate_config': CheckGitConfig,
118 > }
119 > }
120 > }
121 > diff --git a/pym/portage/sync/modules/git/git.py
122 > b/pym/portage/sync/modules/git/git.py index 35943dd..d4f2cc1 100644
123 > --- a/pym/portage/sync/modules/git/git.py
124 > +++ b/pym/portage/sync/modules/git/git.py
125 > @@ -63,9 +63,13 @@ class GitSync(SyncBase):
126 > sync_uri = self.repo.sync_uri
127 > if sync_uri.startswith("file://"):
128 > sync_uri = sync_uri[6:]
129 > - exitcode = portage.process.spawn_bash("cd %s ; %s
130 > clone %s ." % \
131 > + depth_arg = ''
132 > + if self.repo.sync_depth is not None:
133 > + depth_arg = '--depth %d ' %
134 > self.repo.sync_depth
135 > + exitcode = portage.process.spawn_bash("cd %s ; %s
136 > clone %s%s ." % \ (portage._shell_quote(self.repo.location),
137 > self.bin_command,
138 > + depth_arg,
139 > portage._shell_quote(sync_uri)),
140 > **portage._native_kwargs(self.spawn_kwargs))
141 > if exitcode != os.EX_OK:
142
143
144
145 --
146 Brian Dolbec <dolsen>

Replies

Subject Author
[gentoo-portage-dev] Regarding ACKs to the effect of "looks OK except..." Alexander Berntsen <bernalex@g.o>