Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] repos.conf: rename sync-depth option to clone-depth
Date: Wed, 22 Feb 2017 03:38:38
Message-Id: 20170221193829.0b0f7d69.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] repos.conf: rename sync-depth option to clone-depth by Zac Medico
1 On Fri, 17 Feb 2017 18:53:09 -0800
2 Zac Medico <zmedico@g.o> wrote:
3
4 > Since sync-depth actually controls clone depth, rename it
5 > to clone-depth, and show a warning message when the sync-depth
6 > option has been specified:
7 >
8 > UserWarning: repos.conf: sync-depth is deprecated, use clone-depth
9 > instead
10 >
11 > This makes it feasible to change the meaning of sync-depth in
12 > the future (it could be used to control git pull depth).
13 >
14 > X-Gentoo-Bug: 552814
15 > X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=552814
16 > ---
17 > man/portage.5 | 7 +++++--
18 > pym/portage/repository/config.py | 16 ++++++++++++----
19 > pym/portage/sync/modules/git/__init__.py | 14 +++++++++-----
20 > pym/portage/sync/modules/git/git.py | 4 +++-
21 > 4 files changed, 29 insertions(+), 12 deletions(-)
22 >
23 > diff --git a/man/portage.5 b/man/portage.5
24 > index 415817a..82e979e 100644
25 > --- a/man/portage.5
26 > +++ b/man/portage.5
27 > @@ -925,6 +925,10 @@ Valid values: yes, no, true, false.
28 > If unset, the repo will be treated as set
29 > yes, true.
30 > .TP
31 > +.B clone\-depth
32 > +Specifies clone depth to use for DVCS repositories. Defaults to 1
33 > (only +the newest commit). If set to 0, the depth is unlimited.
34 > +.TP
35 > .B eclass\-overrides
36 > Makes given repository inherit eclasses from specified repositories.
37 > .br
38 > @@ -972,8 +976,7 @@ Valid values: true, false.
39 > Specifies CVS repository.
40 > .TP
41 > .B sync\-depth
42 > -Specifies clone depth to use for DVCS repositories. Defaults to 1
43 > (only -the newest commit). If set to 0, the depth is unlimited.
44 > +This is a deprecated alias for the \fBclone\-depth\fR option.
45 > .TP
46 > .B sync\-git\-clone\-extra\-opts
47 > Extra options to give to git when cloning repository (git clone).
48 > diff --git a/pym/portage/repository/config.py
49 > b/pym/portage/repository/config.py index 67c717d..b65ed97 100644
50 > --- a/pym/portage/repository/config.py
51 > +++ b/pym/portage/repository/config.py
52 > @@ -75,7 +75,8 @@ class RepoConfig(object):
53 > """Stores config of one repository"""
54 >
55 > __slots__ = ('aliases', 'allow_missing_manifest',
56 > 'allow_provide_virtual',
57 > - 'auto_sync', 'cache_formats', 'create_manifest',
58 > 'disable_manifest',
59 > + 'auto_sync', 'cache_formats', 'clone_depth',
60 > + 'create_manifest', 'disable_manifest',
61 > 'eapi', 'eclass_db', 'eclass_locations',
62 > 'eclass_overrides', 'find_invalid_path_char', 'force', 'format',
63 > 'local_config', 'location', 'main_repo', 'manifest_hashes',
64 > 'masters', 'missing_repo_name', @@ -168,7 +169,13 @@ class
65 > RepoConfig(object): auto_sync = auto_sync.strip().lower()
66 > self.auto_sync = auto_sync
67 >
68 > + self.clone_depth = repo_opts.get('clone-depth')
69 > self.sync_depth = repo_opts.get('sync-depth')
70 > +
71 > + if self.sync_depth is not None:
72 > + warnings.warn(_("repos.conf: sync-depth is
73 > deprecated,"
74 > + " use clone-depth instead"))
75 > +
76 > self.sync_hooks_only_on_change = repo_opts.get(
77 > 'sync-hooks-only-on-change',
78 > 'false').lower() == 'true'
79 > @@ -505,7 +512,8 @@ class RepoConfigLoader(object):
80 > if repos_conf_opts is not
81 > None: # Selectively copy only the attributes which
82 > # repos.conf is
83 > allowed to override.
84 > - for k in ('aliases',
85 > 'auto_sync', 'eclass_overrides',
86 > + for k in ('aliases',
87 > 'auto_sync',
88 > + 'clone_depth',
89 > 'eclass_overrides', 'force', 'masters', 'priority',
90 > 'strict_misc_digests', 'sync_depth', 'sync_hooks_only_on_change',
91 > 'sync_type',
92 > 'sync_umask', 'sync_uri', 'sync_user', @@ -929,8 +937,8 @@ class
93 > RepoConfigLoader(object):
94 > def config_string(self):
95 > bool_keys = ("strict_misc_digests",)
96 > - str_or_int_keys = ("auto_sync", "format", "location",
97 > - "main_repo", "priority",
98 > + str_or_int_keys = ("auto_sync", "clone_depth",
99 > "format", "location",
100 > + "main_repo", "priority", "sync_depth",
101 > "sync_type", "sync_umask", "sync_uri",
102 > 'sync_user') str_tuple_keys = ("aliases", "eclass_overrides", "force")
103 > repo_config_tuple_keys = ("masters",)
104 > diff --git a/pym/portage/sync/modules/git/__init__.py
105 > b/pym/portage/sync/modules/git/__init__.py index d5eb5c6..2df60e3
106 > 100644 --- a/pym/portage/sync/modules/git/__init__.py
107 > +++ b/pym/portage/sync/modules/git/__init__.py
108 > @@ -16,22 +16,26 @@ class CheckGitConfig(CheckSyncConfig):
109 > self.checks.append('check_depth')
110 >
111 > def check_depth(self):
112 > - d = self.repo.sync_depth
113 > + for attr in ('clone_depth', 'sync_depth'):
114 > + self._check_depth(attr)
115 > +
116 > + def _check_depth(self, attr):
117 > + d = getattr(self.repo, attr)
118 > # default
119 > - self.repo.sync_depth = 1
120 > + setattr(self.repo, attr, 1)
121 >
122 > if d is not None:
123 > try:
124 > d = int(d)
125 > except ValueError:
126 > writemsg_level("!!! %s\n" %
127 > - _("sync-depth value is not a
128 > number: '%s'")
129 > - % (d),
130 > + _("%s value is not a number:
131 > '%s'")
132 > + % (attr.replace('_', '-'),
133 > d), level=self.logger.ERROR, noiselevel=-1)
134 > else:
135 > if d == 0:
136 > d = None
137 > - self.repo.sync_depth = d
138 > + setattr(self.repo, attr, d)
139 >
140 >
141 > module_spec = {
142 > diff --git a/pym/portage/sync/modules/git/git.py
143 > b/pym/portage/sync/modules/git/git.py index 02eeb16..d5400d5 100644
144 > --- a/pym/portage/sync/modules/git/git.py
145 > +++ b/pym/portage/sync/modules/git/git.py
146 > @@ -52,7 +52,9 @@ class GitSync(NewBase):
147 > git_cmd_opts = ""
148 > if self.settings.get("PORTAGE_QUIET") == "1":
149 > git_cmd_opts += " --quiet"
150 > - if self.repo.sync_depth is not None:
151 > + if self.repo.clone_depth is not None:
152 > + git_cmd_opts += " --depth %d" %
153 > self.repo.clone_depth
154 > + elif self.repo.sync_depth is not None:
155 > git_cmd_opts += " --depth %d" %
156 > self.repo.sync_depth if
157 > self.repo.module_specific_options.get('sync-git-clone-extra-opts'):
158 > git_cmd_opts += " %s" %
159 > self.repo.module_specific_options['sync-git-clone-extra-opts']
160
161 hmm, I might be out of sync, but if this isn't merged already, looks
162 fine.
163
164 --
165 Brian Dolbec <dolsen>

Replies