1 |
On Sat, 17 Jan 2015 12:58:19 +0100 |
2 |
Michał Górny <mgorny@g.o> wrote: |
3 |
|
4 |
> Support sync-clone-depth with the default set to 1. This allows the |
5 |
> user to reduce the number of historical commits fetched along with the |
6 |
> repository (git --depth). |
7 |
> --- |
8 |
> man/portage.5 | 4 ++++ |
9 |
> pym/portage/repository/config.py | 19 ++++++++++++++++++- |
10 |
> pym/portage/sync/modules/git/git.py | 6 +++++- |
11 |
> 3 files changed, 27 insertions(+), 2 deletions(-) |
12 |
> |
13 |
> diff --git a/man/portage.5 b/man/portage.5 |
14 |
> index f0b0e20..3fb511c 100644 |
15 |
> --- a/man/portage.5 |
16 |
> +++ b/man/portage.5 |
17 |
> @@ -903,6 +903,10 @@ since operations performed by these tools are |
18 |
> inherently .B priority |
19 |
> Specifies priority of given repository. |
20 |
> .TP |
21 |
> +.B sync\-clone\-depth |
22 |
> +Specifies clone depth to use for DVCS repositories. Defaults to 1 |
23 |
> (only +the newest commit). If set to 0, the depth is unlimited. |
24 |
> +.TP |
25 |
> .B sync\-cvs\-repo |
26 |
> Specifies CVS repository. |
27 |
> .TP |
28 |
> diff --git a/pym/portage/repository/config.py |
29 |
> b/pym/portage/repository/config.py index 7e17e02..2c4ce8a 100644 |
30 |
> --- a/pym/portage/repository/config.py |
31 |
> +++ b/pym/portage/repository/config.py |
32 |
> @@ -88,7 +88,8 @@ class RepoConfig(object): |
33 |
> 'profile_formats', 'sign_commit', 'sign_manifest', |
34 |
> 'sync_cvs_repo', 'sync_type', 'sync_umask', 'sync_uri', 'sync_user', |
35 |
> 'thin_manifest', 'update_changelog', 'user_location', '_eapis_banned', |
36 |
> - '_eapis_deprecated', '_masters_orig') |
37 |
> + '_eapis_deprecated', '_masters_orig', |
38 |
> + 'sync_clone_depth') |
39 |
> |
40 |
> def __init__(self, name, repo_opts, local_config=True): |
41 |
> """Build a RepoConfig with options in repo_opts |
42 |
> @@ -176,6 +177,21 @@ class RepoConfig(object): |
43 |
> auto_sync = auto_sync.strip().lower() |
44 |
> self.auto_sync = auto_sync |
45 |
> |
46 |
> + sync_clone_depth = None |
47 |
> + if self.sync_type in ('git',): |
48 |
> + sync_clone_depth = |
49 |
> repo_opts.get('sync-clone-depth') |
50 |
> + if sync_clone_depth is not None: |
51 |
> + try: |
52 |
> + sync_clone_depth = |
53 |
> int(sync_clone_depth) |
54 |
> + except ValueError: |
55 |
> + sync_clone_depth = None |
56 |
> + else: |
57 |
> + if sync_clone_depth == 0: |
58 |
> + sync_clone_depth = |
59 |
> None |
60 |
> + else: |
61 |
> + sync_clone_depth = 1 |
62 |
> + self.sync_clone_depth = sync_clone_depth |
63 |
> + |
64 |
> |
65 |
|
66 |
|
67 |
This is wrong, and counter productive to the plugin-system, requiring |
68 |
that checks be performed by the plugin. |
69 |
|
70 |
|
71 |
I also prefer sync_depth as a variable name, which matches the other |
72 |
names. 'sync-cvs-repo' is a legacy exception and is replaced by the |
73 |
auto-sync option. I was hoping the git migration was done before this |
74 |
was released so it could more easily be removed. |
75 |
|
76 |
|
77 |
|
78 |
|
79 |
> # Not implemented. |
80 |
> format = repo_opts.get('format') |
81 |
> if format is not None: |
82 |
> @@ -489,6 +505,7 @@ class RepoConfigLoader(object): |
83 |
> for k in ('aliases', |
84 |
> 'auto_sync', 'eclass_overrides', 'force', 'masters', 'priority', |
85 |
> 'sync_cvs_repo', 'sync_type', 'sync_umask', 'sync_uri', 'sync_user', |
86 |
> + 'sync_clone_depth', |
87 |
> ): |
88 |
> v = |
89 |
> getattr(repos_conf_opts, k, None) if v is not None: |
90 |
> diff --git a/pym/portage/sync/modules/git/git.py |
91 |
> b/pym/portage/sync/modules/git/git.py index 35943dd..b97d501 100644 |
92 |
> --- a/pym/portage/sync/modules/git/git.py |
93 |
> +++ b/pym/portage/sync/modules/git/git.py |
94 |
> @@ -63,9 +63,13 @@ class GitSync(SyncBase): |
95 |
> sync_uri = self.repo.sync_uri |
96 |
> if sync_uri.startswith("file://"): |
97 |
> sync_uri = sync_uri[6:] |
98 |
> - exitcode = portage.process.spawn_bash("cd %s ; %s |
99 |
> clone %s ." % \ |
100 |
> + depth_arg = '' |
101 |
> + if self.repo.sync_clone_depth is not None: |
102 |
> + depth_arg = '--depth %d ' % |
103 |
> self.repo.sync_clone_depth |
104 |
> + exitcode = portage.process.spawn_bash("cd %s ; %s |
105 |
> clone %s%s ." % \ (portage._shell_quote(self.repo.location), |
106 |
> self.bin_command, |
107 |
> + depth_arg, |
108 |
> portage._shell_quote(sync_uri)), |
109 |
> **portage._native_kwargs(self.spawn_kwargs)) |
110 |
> if exitcode != os.EX_OK: |
111 |
|
112 |
|
113 |
|
114 |
-- |
115 |
Brian Dolbec <dolsen> |