From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RFaqW-0001NR-OR for garchives@archives.gentoo.org; Mon, 17 Oct 2011 00:14:25 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 752A321C0C4; Mon, 17 Oct 2011 00:14:16 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 25E4421C0C4 for ; Mon, 17 Oct 2011 00:14:16 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 87E061B4022 for ; Mon, 17 Oct 2011 00:14:15 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id A3A3580042 for ; Mon, 17 Oct 2011 00:14:14 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/repoman/, bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/repoman pym/repoman/utilities.py X-VCS-Directories: pym/repoman/ bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: f757cd2a4dd2d3634743c207a4aadb3f217bfce1 Date: Mon, 17 Oct 2011 00:14:14 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 82390856afb9b876639660e3392faafd commit: f757cd2a4dd2d3634743c207a4aadb3f217bfce1 Author: Fabian Groffen gentoo org> AuthorDate: Sun Oct 16 22:31:07 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Oct 16 22:31:07 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Df757cd2a repoman: implemented echangelog functionality Instead of calling echangelog, which on its turn has to query the VCS again, use the existing information on changes made to the current directory, and update the ChangeLog from Python itself. This avoids a call to echangelog, and avoids again retrieving the same VCS information as repoman already did. It makes repoman independent from external tools it didn't install itself, and should be faster in general. --- bin/repoman | 117 ++++++++++++++++++++++------------------= ---- pym/repoman/utilities.py | 122 ++++++++++++++++++++++++++++++++++++++++= +++++- 2 files changed, 179 insertions(+), 60 deletions(-) diff --git a/bin/repoman b/bin/repoman index b1a2ac3..1d7d71a 100755 --- a/bin/repoman +++ b/bin/repoman @@ -18,7 +18,6 @@ import optparse import re import signal import stat -import subprocess import sys import tempfile import textwrap @@ -73,7 +72,7 @@ from portage.process import find_binary, spawn from portage.output import bold, create_color_func, \ green, nocolor, red from portage.output import ConsoleStyleFile, StyleWriter -from portage.util import cmp_sort_key, writemsg_level, writemsg_stdout +from portage.util import cmp_sort_key, writemsg_level from portage.package.ebuild.digestgen import digestgen from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use =20 @@ -645,19 +644,15 @@ if options.echangelog is None and \ if vcs is None: options.echangelog =3D 'n' =20 -if 'commit' =3D=3D options.mode and \ - options.echangelog =3D=3D 'y' and \ - find_binary('echangelog') is None: - logging.error("echangelog not found, and --echangelog is enabled") - sys.exit(1) - # The --echangelog option causes automatic ChangeLog generation, # which invalidates changelog.ebuildadded and changelog.missing # checks. -# Note: We don't use ChangeLogs in distributed SCMs. +# Note: Some don't use ChangeLogs in distributed SCMs. # It will be generated on server side from scm log, # before package moves to the rsync server. -# This is needed because we try to avoid merge collisions. +# This is needed because they try to avoid merge collisions. +# Gentoo's Council decided to always use the ChangeLog file. +# TODO: shouldn't this just be switched on the repo, iso the VCS? check_changelog =3D options.echangelog !=3D 'y' and vcs in ('cvs', 'svn'= ) =20 # Generate an appropriate PORTDIR_OVERLAY value for passing into the @@ -2284,36 +2279,6 @@ else: myautoadd+=3D[myunadded[x]] del myunadded[x] =20 - if myautoadd: - print(">>> Auto-Adding missing Manifest(s)...") - if options.pretend: - if vcs =3D=3D "cvs": - print("(cvs add "+" ".join(myautoadd)+")") - elif vcs =3D=3D "svn": - print("(svn add "+" ".join(myautoadd)+")") - elif vcs =3D=3D "git": - print("(git add "+" ".join(myautoadd)+")") - elif vcs =3D=3D "bzr": - print("(bzr add "+" ".join(myautoadd)+")") - elif vcs =3D=3D "hg": - print("(hg add "+" ".join(myautoadd)+")") - retval=3D0 - else: - if vcs =3D=3D "cvs": - retval=3Dos.system("cvs add "+" ".join(myautoadd)) - elif vcs =3D=3D "svn": - retval=3Dos.system("svn add "+" ".join(myautoadd)) - elif vcs =3D=3D "git": - retval=3Dos.system("git add "+" ".join(myautoadd)) - elif vcs =3D=3D "bzr": - retval=3Dos.system("bzr add "+" ".join(myautoadd)) - elif vcs =3D=3D "hg": - retval=3Dos.system("hg add "+" ".join(myautoadd)) - if retval: - writemsg_level("!!! Exiting on %s (shell) error code: %s\n" % \ - (vcs, retval), level=3Dlogging.ERROR, noiselevel=3D-1) - sys.exit(retval) - if myunadded: print(red("!!! The following files are in your local tree but are not = added to the master")) print(red("!!! tree. Please remove them from the local tree or add the= m to the master tree.")) @@ -2402,8 +2367,6 @@ else: myheaders =3D [] mydirty =3D [] =20 - print("* %s files being committed..." % green(str(len(myupdates))), end= =3D' ') - commitmessage =3D options.commitmsg if options.commitmsgfile: try: @@ -2473,22 +2436,60 @@ else: if changelog_modified: continue =20 - myupdates.append(changelog_path) - logging.info("calling echangelog for package %s" % x) - # --no-strict is required if only manifest(s) have changed - echangelog_args =3D ["echangelog", "--no-strict", - "--vcs", vcs, changelog_msg] - if options.pretend: - writemsg_stdout("(%s)\n" % (" ".join(echangelog_args),), - noiselevel=3D-1) - continue - echangelog_args =3D [_unicode_encode(arg) for arg in echangelog_args] - echangelog_cwd =3D _unicode_encode(checkdir, - encoding=3D_encodings['fs'], errors=3D'strict') - retcode =3D subprocess.call(echangelog_args, cwd=3Dechangelog_cwd) - if retcode !=3D os.EX_OK: - logging.error("echangelog exited with '%s' status" % retcode) - sys.exit(retcode) + # get changes for this package + cdrlen =3D len(checkdir_relative) + clnew =3D [elem[cdrlen:] for elem in mynew if elem.startswith(checkdi= r_relative)] + clremoved =3D [elem[cdrlen:] for elem in myremoved if elem.startswith= (checkdir_relative)] + clchanged =3D [elem[cdrlen:] for elem in mychanged if elem.startswith= (checkdir_relative)] + new_changelog =3D utilities.UpdateChangeLog(checkdir_relative, \ + catdir, pkgdir, \ + clnew, clremoved, clchanged, \ + changelog_msg, options.pretend) + if new_changelog is None: + writemsg_level("!!! Updating the ChangeLog failed\n", \ + level=3Dlogging.ERROR, noiselevel=3D-1) + sys.exit(1) + + # if the ChangeLog was just created, add it to vcs + if new_changelog: + myautoadd.append(changelog_path) + # myautoadd is appended to myupdates below + else: + myupdates.append(changelog_path) + + if myautoadd: + print(">>> Auto-Adding missing Manifest/ChangeLog file(s)...") + if options.pretend: + if vcs =3D=3D "cvs": + print("(cvs add "+" ".join(myautoadd)+")") + elif vcs =3D=3D "svn": + print("(svn add "+" ".join(myautoadd)+")") + elif vcs =3D=3D "git": + print("(git add "+" ".join(myautoadd)+")") + elif vcs =3D=3D "bzr": + print("(bzr add "+" ".join(myautoadd)+")") + elif vcs =3D=3D "hg": + print("(hg add "+" ".join(myautoadd)+")") + retval =3D os.EX_OK + else: + if vcs =3D=3D "cvs": + retval =3D os.system("cvs add "+" ".join(myautoadd)) + elif vcs =3D=3D "svn": + retval =3D os.system("svn add "+" ".join(myautoadd)) + elif vcs =3D=3D "git": + retval =3D os.system("git add "+" ".join(myautoadd)) + elif vcs =3D=3D "bzr": + retval =3D os.system("bzr add "+" ".join(myautoadd)) + elif vcs =3D=3D "hg": + retval =3D os.system("hg add "+" ".join(myautoadd)) + if retval !=3D os.EX_OK: + writemsg_level("!!! Exiting on %s (shell) error code: %s\n" % \ + (vcs, retval), level=3Dlogging.ERROR, noiselevel=3D-1) + sys.exit(retval) + + myupdates +=3D myautoadd + + print("* %s files being committed..." % green(str(len(myupdates))), end= =3D' ') =20 if vcs not in ('cvs', 'svn'): # With git, bzr and hg, there's never any keyword expansion, so diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py index 7913703..8f7d5d5 100644 --- a/pym/repoman/utilities.py +++ b/pym/repoman/utilities.py @@ -5,6 +5,8 @@ """This module contains utility functions to help repoman find ebuilds t= o scan""" =20 +from __future__ import print_function + __all__ =3D [ "detect_vcs_conflicts", "editor_is_executable", @@ -17,13 +19,22 @@ __all__ =3D [ "have_profile_dir", "parse_metadata_use", "UnknownHerdsError", - "check_metadata" + "check_metadata", + "UpdateChangeLog" ] =20 import errno import io +from itertools import chain import logging +import pwd import sys +import time +import textwrap +import difflib +import shutil +from tempfile import mkstemp + from portage import os from portage import subprocess_getstatusoutput from portage import _encodings @@ -308,7 +319,6 @@ def get_commit_message_with_editor(editor, message=3D= None): @rtype: string or None @returns: A string on success or None if an error occurs. """ - from tempfile import mkstemp fd, filename =3D mkstemp() try: os.write(fd, _unicode_encode(_( @@ -511,3 +521,111 @@ def FindVCS(): outvcs =3D seek() =20 return outvcs + +def UpdateChangeLog(pkgdir, category, package, new, removed, changed, ms= g, pretend): + """ Write an entry to an existing ChangeLog, or create a new one. """ + + # figure out who to write as + if 'GENTOO_COMMITTER_NAME' in os.environ and \ + 'GENTOO_COMMITTER_EMAIL' in os.environ: + user =3D '%s <%s>' % (os.environ['GENTOO_COMMITTER_NAME'], \ + os.environ['GENTOO_COMMITTER_EMAIL']) + elif 'GENTOO_AUTHOR_NAME' in os.environ and \ + 'GENTOO_AUTHOR_EMAIL' in os.environ: + user =3D '%s <%s>' % (os.environ['GENTOO_AUTHOR_NAME'], \ + os.environ['GENTOO_AUTHOR_EMAIL']) + elif 'ECHANGELOG_USER' in os.environ: + user =3D os.environ['ECHANGELOG_USER'] + else: + (login, _, _, _, gecos, _, _) =3D pwd.getpwuid(os.getuid()) + gecos =3D gecos.split(',')[0] # bug #80011 + user =3D '%s <%s@gentoo.org>' % (gecos, login) + + if '