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 C674A59CB2 for ; Sun, 17 Apr 2016 07:50:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D0C1F21C1EB; Sun, 17 Apr 2016 07:49:56 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 13E2F21C1D6 for ; Sun, 17 Apr 2016 07:49:55 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 49B54340B63 for ; Sun, 17 Apr 2016 07:49:53 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 222E5208E for ; Sun, 17 Apr 2016 07:49:50 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1457805461.2e1ee76d7df8b96a078b220e542278d93b0bcf20.mgorny@gentoo> Subject: [gentoo-commits] proj/portage:xml-schema commit in: pym/repoman/modules/vcs/git/, pym/repoman/, pym/repoman/modules/vcs/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/actions.py pym/repoman/modules/vcs/changes.py pym/repoman/modules/vcs/git/changes.py X-VCS-Directories: pym/repoman/modules/vcs/ pym/repoman/ pym/repoman/modules/vcs/git/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 2e1ee76d7df8b96a078b220e542278d93b0bcf20 X-VCS-Branch: xml-schema Date: Sun, 17 Apr 2016 07:49:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: bef9817c-518c-43d2-b642-eb3eb6b26437 X-Archives-Hash: 316b50329dd76bbd673ce77aa552244d commit: 2e1ee76d7df8b96a078b220e542278d93b0bcf20 Author: Brian Dolbec gentoo org> AuthorDate: Wed Feb 10 18:05:46 2016 +0000 Commit: Michał Górny gentoo org> CommitDate: Sat Mar 12 17:57:41 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=2e1ee76d repoman: Migrate vcs index update code to the vcs modules pym/repoman/actions.py | 22 +--------------------- pym/repoman/modules/vcs/changes.py | 4 ++++ pym/repoman/modules/vcs/git/changes.py | 27 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py index 4d06555..6c9de57 100644 --- a/pym/repoman/actions.py +++ b/pym/repoman/actions.py @@ -164,27 +164,7 @@ class Actions(object): if self.repo_settings.sign_manifests: self.sign_manifest(myupdates, myremoved, mymanifests) - if self.vcs_settings.vcs == 'git': - # It's not safe to use the git commit -a option since there might - # be some modified files elsewhere in the working tree that the - # user doesn't want to commit. Therefore, call git update-index - # in order to ensure that the index is updated with the latest - # versions of all new and modified files in the relevant portion - # of the working tree. - myfiles = mymanifests + myupdates - myfiles.sort() - update_index_cmd = ["git", "update-index"] - update_index_cmd.extend(f.lstrip("./") for f in myfiles) - if self.options.pretend: - print("(%s)" % (" ".join(update_index_cmd),)) - else: - retval = spawn(update_index_cmd, env=os.environ) - if retval != os.EX_OK: - writemsg_level( - "!!! Exiting on %s (shell) " - "error code: %s\n" % (self.vcs_settings.vcs, retval), - level=logging.ERROR, noiselevel=-1) - sys.exit(retval) + self.vcs_settings.changes.update_index(mymanifests, myupdates) self.add_manifest(mymanifests, myheaders, myupdates, myremoved, commitmessage) diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py index 27b627f..948407c 100644 --- a/pym/repoman/modules/vcs/changes.py +++ b/pym/repoman/modules/vcs/changes.py @@ -85,3 +85,7 @@ class ChangesBase(object): def clear_attic(myheaders): '''Old CVS leftover''' pass + + def update_index(self, mymanifests, myupdates): + '''Update the vcs's modified index if it is needed''' + pass diff --git a/pym/repoman/modules/vcs/git/changes.py b/pym/repoman/modules/vcs/git/changes.py index 1970b3a..018458c 100644 --- a/pym/repoman/modules/vcs/git/changes.py +++ b/pym/repoman/modules/vcs/git/changes.py @@ -2,11 +2,16 @@ Git module Changes class submodule ''' +import logging +import sys + from repoman.modules.vcs.changes import ChangesBase from repoman._subprocess import repoman_popen from repoman._portage import portage from portage import os from portage.package.ebuild.digestgen import digestgen +from portage.process import spawn +from portage.util import writemsg_level class Changes(ChangesBase): @@ -63,3 +68,25 @@ class Changes(ChangesBase): for x in broken_changelog_manifests: self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x) digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb) + + def update_index(self, mymanifests, myupdates): + # It's not safe to use the git commit -a option since there might + # be some modified files elsewhere in the working tree that the + # user doesn't want to commit. Therefore, call git update-index + # in order to ensure that the index is updated with the latest + # versions of all new and modified files in the relevant portion + # of the working tree. + myfiles = mymanifests + myupdates + myfiles.sort() + update_index_cmd = ["git", "update-index"] + update_index_cmd.extend(f.lstrip("./") for f in myfiles) + if self.options.pretend: + print("(%s)" % (" ".join(update_index_cmd),)) + else: + retval = spawn(update_index_cmd, env=os.environ) + if retval != os.EX_OK: + writemsg_level( + "!!! Exiting on %s (shell) " + "error code: %s\n" % (self.vcs_settings.vcs, retval), + level=logging.ERROR, noiselevel=-1) + sys.exit(retval)