From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 79563138A1A for ; Sun, 18 Jan 2015 09:42:22 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 65028E08A8; Sun, 18 Jan 2015 09:42:21 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C3997E08A6 for ; Sun, 18 Jan 2015 09:42:20 +0000 (UTC) Received: from big_daddy.dol-sen.ca (S010634bdfa9ecf80.vc.shawcable.net [96.49.31.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dolsen) by smtp.gentoo.org (Postfix) with ESMTPSA id 965033406E6 for ; Sun, 18 Jan 2015 09:42:19 +0000 (UTC) Date: Sun, 18 Jan 2015 01:41:59 -0800 From: Brian Dolbec To: gentoo-portage-dev@lists.gentoo.org Subject: Re: [gentoo-portage-dev] [PATCH] sync: support sync-clone-depth for DVCS-es (git --depth) Message-ID: <20150118014159.4b1104e8.dolsen@gentoo.org> In-Reply-To: <1421495899-2473-1-git-send-email-mgorny@gentoo.org> References: <1421495899-2473-1-git-send-email-mgorny@gentoo.org> Organization: Gentoo Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 472c9996-d9c3-448d-b03d-f30c913988a0 X-Archives-Hash: eb274a029975f6e1dd859c961204155d On Sat, 17 Jan 2015 12:58:19 +0100 Micha=C5=82 G=C3=B3rny wrote: > 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(-) >=20 > 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') > =20 > def __init__(self, name, repo_opts, local_config=3DTrue): > """Build a RepoConfig with options in repo_opts > @@ -176,6 +177,21 @@ class RepoConfig(object): > auto_sync =3D auto_sync.strip().lower() > self.auto_sync =3D auto_sync > =20 > + sync_clone_depth =3D None > + if self.sync_type in ('git',): > + sync_clone_depth =3D > repo_opts.get('sync-clone-depth') > + if sync_clone_depth is not None: > + try: > + sync_clone_depth =3D > int(sync_clone_depth) > + except ValueError: > + sync_clone_depth =3D None > + else: > + if sync_clone_depth =3D=3D 0: > + sync_clone_depth =3D > None > + else: > + sync_clone_depth =3D 1 > + self.sync_clone_depth =3D sync_clone_depth > + >=20 This is wrong, and counter productive to the plugin-system, requiring that checks be performed by the plugin. I also prefer sync_depth as a variable name, which matches the other names. 'sync-cvs-repo' is a legacy exception and is replaced by the auto-sync option. I was hoping the git migration was done before this was released so it could more easily be removed. > # Not implemented. > format =3D 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 =3D > 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 =3D self.repo.sync_uri > if sync_uri.startswith("file://"): > sync_uri =3D sync_uri[6:] > - exitcode =3D portage.process.spawn_bash("cd %s ; %s > clone %s ." % \ > + depth_arg =3D '' > + if self.repo.sync_clone_depth is not None: > + depth_arg =3D '--depth %d ' % > self.repo.sync_clone_depth > + exitcode =3D 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 !=3D os.EX_OK: --=20 Brian Dolbec