Gentoo Archives: gentoo-portage-dev

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

Replies