From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH] sync: support sync-clone-depth for DVCS-es (git --depth)
Date: Sat, 17 Jan 2015 12:58:19 +0100 [thread overview]
Message-ID: <1421495899-2473-1-git-send-email-mgorny@gentoo.org> (raw)
Support sync-clone-depth with the default set to 1. This allows the user
to reduce the number of historical commits fetched along with the
repository (git --depth).
---
man/portage.5 | 4 ++++
pym/portage/repository/config.py | 19 ++++++++++++++++++-
pym/portage/sync/modules/git/git.py | 6 +++++-
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/man/portage.5 b/man/portage.5
index f0b0e20..3fb511c 100644
--- a/man/portage.5
+++ b/man/portage.5
@@ -903,6 +903,10 @@ since operations performed by these tools are inherently
.B priority
Specifies priority of given repository.
.TP
+.B sync\-clone\-depth
+Specifies clone depth to use for DVCS repositories. Defaults to 1 (only
+the newest commit). If set to 0, the depth is unlimited.
+.TP
.B sync\-cvs\-repo
Specifies CVS repository.
.TP
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index 7e17e02..2c4ce8a 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -88,7 +88,8 @@ class RepoConfig(object):
'profile_formats', 'sign_commit', 'sign_manifest', 'sync_cvs_repo',
'sync_type', 'sync_umask', 'sync_uri', 'sync_user', 'thin_manifest',
'update_changelog', 'user_location', '_eapis_banned',
- '_eapis_deprecated', '_masters_orig')
+ '_eapis_deprecated', '_masters_orig',
+ 'sync_clone_depth')
def __init__(self, name, repo_opts, local_config=True):
"""Build a RepoConfig with options in repo_opts
@@ -176,6 +177,21 @@ class RepoConfig(object):
auto_sync = auto_sync.strip().lower()
self.auto_sync = auto_sync
+ sync_clone_depth = None
+ if self.sync_type in ('git',):
+ sync_clone_depth = repo_opts.get('sync-clone-depth')
+ if sync_clone_depth is not None:
+ try:
+ sync_clone_depth = int(sync_clone_depth)
+ except ValueError:
+ sync_clone_depth = None
+ else:
+ if sync_clone_depth == 0:
+ sync_clone_depth = None
+ else:
+ sync_clone_depth = 1
+ self.sync_clone_depth = sync_clone_depth
+
# Not implemented.
format = repo_opts.get('format')
if format is not None:
@@ -489,6 +505,7 @@ class RepoConfigLoader(object):
for k in ('aliases', 'auto_sync', 'eclass_overrides',
'force', 'masters', 'priority', 'sync_cvs_repo',
'sync_type', 'sync_umask', 'sync_uri', 'sync_user',
+ 'sync_clone_depth',
):
v = getattr(repos_conf_opts, k, None)
if v is not None:
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 35943dd..b97d501 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -63,9 +63,13 @@ class GitSync(SyncBase):
sync_uri = self.repo.sync_uri
if sync_uri.startswith("file://"):
sync_uri = sync_uri[6:]
- exitcode = portage.process.spawn_bash("cd %s ; %s clone %s ." % \
+ depth_arg = ''
+ if self.repo.sync_clone_depth is not None:
+ depth_arg = '--depth %d ' % self.repo.sync_clone_depth
+ exitcode = portage.process.spawn_bash("cd %s ; %s clone %s%s ." % \
(portage._shell_quote(self.repo.location),
self.bin_command,
+ depth_arg,
portage._shell_quote(sync_uri)),
**portage._native_kwargs(self.spawn_kwargs))
if exitcode != os.EX_OK:
--
2.2.1
next reply other threads:[~2015-01-17 11:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-17 11:58 Michał Górny [this message]
2015-01-17 22:04 ` [gentoo-portage-dev] [PATCH] sync: support sync-clone-depth for DVCS-es (git --depth) Zac Medico
2015-01-18 9:41 ` Brian Dolbec
2015-01-18 10:33 ` [gentoo-portage-dev] [PATCH v2] sync: support sync-depth " Michał Górny
2015-01-18 16:33 ` Brian Dolbec
2015-02-05 14:51 ` [gentoo-portage-dev] Regarding ACKs to the effect of "looks OK except..." Alexander Berntsen
2015-02-05 16:34 ` Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1421495899-2473-1-git-send-email-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-portage-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox