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 719E81387B1 for ; Mon, 21 Sep 2015 23:48:25 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6641821C05D; Mon, 21 Sep 2015 23:48:12 +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 AF8E221C059 for ; Mon, 21 Sep 2015 23:48:06 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C0B043409B9 for ; Mon, 21 Sep 2015 23:48:00 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 645CF243 for ; Mon, 21 Sep 2015 23:47:56 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1442878966.befc99fa5ff79af530be6e3126a300e182866a2f.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/actions.py X-VCS-Directories: pym/repoman/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: befc99fa5ff79af530be6e3126a300e182866a2f X-VCS-Branch: repoman Date: Mon, 21 Sep 2015 23:47:56 +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: bcb09ded-09ce-4dd7-9bd4-d808464f63fc X-Archives-Hash: 6794e335ddf66ccc0e8d43e83fc30d61 Message-ID: <20150921234756.HIiP2spZIURfvWBlGw6OYiFjhthfAy_zctzCfDtFIIQ@z> commit: befc99fa5ff79af530be6e3126a300e182866a2f Author: Brian Dolbec gentoo org> AuthorDate: Sat Sep 19 02:07:27 2015 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Mon Sep 21 23:42:46 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=befc99fa repoman/actions.py: Break out changes detectection into sudo vcs plugins pym/repoman/actions.py | 215 +++++++++++++++++++++++++++---------------------- 1 file changed, 120 insertions(+), 95 deletions(-) diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py index 611c0dd..1f70815 100644 --- a/pym/repoman/actions.py +++ b/pym/repoman/actions.py @@ -74,102 +74,9 @@ class Actions(object): self._vcs_deleted(mydeleted) - if self.vcs_settings.vcs == "cvs": - mycvstree = cvstree.getentries("./", recursive=1) - mychanged = cvstree.findchanged(mycvstree, recursive=1, basedir="./") - mynew = cvstree.findnew(mycvstree, recursive=1, basedir="./") - myremoved = portage.cvstree.findremoved(mycvstree, recursive=1, basedir="./") - bin_blob_pattern = re.compile("^-kb$") - no_expansion = set(portage.cvstree.findoption( - mycvstree, bin_blob_pattern, recursive=1, basedir="./")) - - if self.vcs_settings.vcs == "svn": - with repoman_popen("svn status") as f: - svnstatus = f.readlines() - mychanged = [ - "./" + elem.split()[-1:][0] - for elem in svnstatus - if (elem[:1] in "MR" or elem[1:2] in "M")] - mynew = [ - "./" + elem.split()[-1:][0] - for elem in svnstatus - if elem.startswith("A")] - myremoved = [ - "./" + elem.split()[-1:][0] - for elem in svnstatus - if elem.startswith("D")] - - # Subversion expands keywords specified in svn:keywords properties. - with repoman_popen("svn propget -R svn:keywords") as f: - props = f.readlines() - expansion = dict( - ("./" + prop.split(" - ")[0], prop.split(" - ")[1].split()) - for prop in props if " - " in prop) - - elif self.vcs_settings.vcs == "git": - with repoman_popen( - "git diff-index --name-only " - "--relative --diff-filter=M HEAD") as f: - mychanged = f.readlines() - mychanged = ["./" + elem[:-1] for elem in mychanged] - - with repoman_popen( - "git diff-index --name-only " - "--relative --diff-filter=A HEAD") as f: - mynew = f.readlines() - mynew = ["./" + elem[:-1] for elem in mynew] - - with repoman_popen( - "git diff-index --name-only " - "--relative --diff-filter=D HEAD") as f: - myremoved = f.readlines() - myremoved = ["./" + elem[:-1] for elem in myremoved] - - if self.vcs_settings.vcs == "bzr": - with repoman_popen("bzr status -S .") as f: - bzrstatus = f.readlines() - mychanged = [ - "./" + elem.split()[-1:][0].split('/')[-1:][0] - for elem in bzrstatus - if elem and elem[1:2] == "M"] - mynew = [ - "./" + elem.split()[-1:][0].split('/')[-1:][0] - for elem in bzrstatus - if elem and (elem[1:2] in "NK" or elem[0:1] == "R")] - myremoved = [ - "./" + elem.split()[-1:][0].split('/')[-1:][0] - for elem in bzrstatus - if elem.startswith("-")] - myremoved = [ - "./" + elem.split()[-3:-2][0].split('/')[-1:][0] - for elem in bzrstatus - if elem and (elem[1:2] == "K" or elem[0:1] == "R")] - # Bazaar expands nothing. - - if self.vcs_settings.vcs == "hg": - with repoman_popen("hg status --no-status --modified .") as f: - mychanged = f.readlines() - mychanged = ["./" + elem.rstrip() for elem in mychanged] - - with repoman_popen("hg status --no-status --added .") as f: - mynew = f.readlines() - mynew = ["./" + elem.rstrip() for elem in mynew] - - with repoman_popen("hg status --no-status --removed .") as f: - myremoved = f.readlines() - myremoved = ["./" + elem.rstrip() for elem in myremoved] + changes = self.get_vcs_changed(mydeleted) - if self.vcs_settings.vcs: - a_file_is_changed = mychanged or mynew or myremoved - a_file_is_deleted_hg = self.vcs_settings.vcs == "hg" and mydeleted - - if not (a_file_is_changed or a_file_is_deleted_hg): - utilities.repoman_sez( - "\"Doing nothing is not always good for QA.\"") - print() - print("(Didn't find any changed files...)") - print() - sys.exit(1) + mynew, mychanged, myremoved, no_expansion, expansion = changes # Manifests need to be regenerated after all other commits, so don't commit # them now even if they have changed. @@ -772,3 +679,121 @@ class Actions(object): print() print() sys.exit(1) + + + def get_vcs_changed(self, mydeleted): + '''Holding function which calls the approriate VCS module for the data''' + changed = ([], [], [], [], []) + if self.vcs_settings.vcs: + vcs_module = getattr(self, '_get_changed_%s_' % self.vcs_settings.vcs) + changed = vcs_module(mydeleted) + mynew, mychanged, myremoved, no_expansion, expansion = changed + + a_file_is_changed = mychanged or mynew or myremoved + a_file_is_deleted_hg = self.vcs_settings.vcs == "hg" and mydeleted + + if not (a_file_is_changed or a_file_is_deleted_hg): + utilities.repoman_sez( + "\"Doing nothing is not always good for QA.\"") + print() + print("(Didn't find any changed files...)") + print() + sys.exit(1) + return changed + + + def _get_changed_cvs_(self, mydeleted): + mycvstree = cvstree.getentries("./", recursive=1) + mychanged = cvstree.findchanged(mycvstree, recursive=1, basedir="./") + mynew = cvstree.findnew(mycvstree, recursive=1, basedir="./") + myremoved = portage.cvstree.findremoved(mycvstree, recursive=1, basedir="./") + bin_blob_pattern = re.compile("^-kb$") + no_expansion = set(portage.cvstree.findoption( + mycvstree, bin_blob_pattern, recursive=1, basedir="./")) + expansion = {} + return (mynew, mychanged, myremoved, no_expansion, expansion) + + def _get_changed_svn_(self, mydeleted): + with repoman_popen("svn status") as f: + svnstatus = f.readlines() + mychanged = [ + "./" + elem.split()[-1:][0] + for elem in svnstatus + if (elem[:1] in "MR" or elem[1:2] in "M")] + mynew = [ + "./" + elem.split()[-1:][0] + for elem in svnstatus + if elem.startswith("A")] + myremoved = [ + "./" + elem.split()[-1:][0] + for elem in svnstatus + if elem.startswith("D")] + # Subversion expands keywords specified in svn:keywords properties. + with repoman_popen("svn propget -R svn:keywords") as f: + props = f.readlines() + expansion = dict( + ("./" + prop.split(" - ")[0], prop.split(" - ")[1].split()) + for prop in props if " - " in prop) + no_expansion = set() + return (mynew, mychanged, myremoved, no_expansion, expansion) + + def _get_changed_git_(self, mydeleted): + with repoman_popen( + "git diff-index --name-only " + "--relative --diff-filter=M HEAD") as f: + mychanged = f.readlines() + mychanged = ["./" + elem[:-1] for elem in mychanged] + with repoman_popen( + "git diff-index --name-only " + "--relative --diff-filter=A HEAD") as f: + mynew = f.readlines() + mynew = ["./" + elem[:-1] for elem in mynew] + with repoman_popen( + "git diff-index --name-only " + "--relative --diff-filter=D HEAD") as f: + myremoved = f.readlines() + myremoved = ["./" + elem[:-1] for elem in myremoved] + no_expansion = set() + expansion = {} + return (mynew, mychanged, myremoved, no_expansion, expansion) + + def _get_changed_bzr_(self, mydeleted): + with repoman_popen("bzr status -S .") as f: + bzrstatus = f.readlines() + mychanged = [ + "./" + elem.split()[-1:][0].split('/')[-1:][0] + for elem in bzrstatus + if elem and elem[1:2] == "M"] + mynew = [ + "./" + elem.split()[-1:][0].split('/')[-1:][0] + for elem in bzrstatus + if elem and (elem[1:2] in "NK" or elem[0:1] == "R")] + myremoved = [ + "./" + elem.split()[-1:][0].split('/')[-1:][0] + for elem in bzrstatus + if elem.startswith("-")] + myremoved = [ + "./" + elem.split()[-3:-2][0].split('/')[-1:][0] + for elem in bzrstatus + if elem and (elem[1:2] == "K" or elem[0:1] == "R")] + # Bazaar expands nothing. + no_expansion = set() + expansion = {} + return (mynew, mychanged, myremoved, no_expansion, expansion) + + def _get_changed_hg_(self, mydeleted): + with repoman_popen("hg status --no-status --modified .") as f: + mychanged = f.readlines() + mychanged = ["./" + elem.rstrip() for elem in mychanged] + + with repoman_popen("hg status --no-status --added .") as f: + mynew = f.readlines() + mynew = ["./" + elem.rstrip() for elem in mynew] + + with repoman_popen("hg status --no-status --removed .") as f: + myremoved = f.readlines() + myremoved = ["./" + elem.rstrip() for elem in myremoved] + no_expansion = set() + expansion = {} + return (mynew, mychanged, myremoved, no_expansion, expansion) +