aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdano Arendartchuk <bogdano@mandriva.org>2007-06-17 15:07:25 +0000
committerBogdano Arendartchuk <bogdano@mandriva.org>2007-06-17 15:07:25 +0000
commitb1d0787e062a976b33113f08e12c6d9193dbd2e7 (patch)
treeb560b695018a9801cdba8bf01b8808d6815cd9a1
parent1764e182d9cf9937ad78a1452fe48c167372fc1a (diff)
downloadmgarepo-b1d0787e062a976b33113f08e12c6d9193dbd2e7.tar
mgarepo-b1d0787e062a976b33113f08e12c6d9193dbd2e7.tar.gz
mgarepo-b1d0787e062a976b33113f08e12c6d9193dbd2e7.tar.bz2
mgarepo-b1d0787e062a976b33113f08e12c6d9193dbd2e7.tar.xz
mgarepo-b1d0787e062a976b33113f08e12c6d9193dbd2e7.zip
Perform less svn operations in getsrpm and rpmlog
- don't export SPECS/ when current/ is already exported - don't check for the presence of a path that will be exported in the same code, let it raise one exception - complain when no changelogs are found inside SPECS/
-rw-r--r--CHANGES1
-rw-r--r--RepSys/log.py78
-rw-r--r--RepSys/rpmutil.py2
3 files changed, 44 insertions, 37 deletions
diff --git a/CHANGES b/CHANGES
index fa45585..eee610a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,7 @@
* 1.6.18
- added the subcommand "switch" to help with mirrors support
- initialize plugins in create-srpm too
+- changelog: perform less svn calls to obtain release number and oldlog
- changelog: show epoch even in the entry not released
- changelog: make default.chlog compatible with cheetah-2
- make "sync" compatible with rpm-4.4.8 behavior
diff --git a/RepSys/log.py b/RepSys/log.py
index 7263be3..b5bf212 100644
--- a/RepSys/log.py
+++ b/RepSys/log.py
@@ -45,7 +45,7 @@ default_template = """
#end for
"""
-def getrelease(pkgdirurl, rev=None, macros=[]):
+def getrelease(pkgdirurl, rev=None, macros=[], exported=None):
"""Tries to obtain the version-release of the package for a
yet-not-markrelease revision of the package.
@@ -54,38 +54,40 @@ def getrelease(pkgdirurl, rev=None, macros=[]):
"""
from RepSys.rpmutil import rpm_macros_defs
svn = SVN(baseurl=pkgdirurl)
- tmpdir = tempfile.mktemp()
+ pkgcurrenturl = os.path.join(pkgdirurl, "current")
+ specurl = os.path.join(pkgcurrenturl, "SPECS")
+ if exported is None:
+ tmpdir = tempfile.mktemp()
+ svn.export(specurl, tmpdir, rev=rev)
+ else:
+ tmpdir = os.path.join(exported, "SPECS")
try:
- pkgname = RepSysTree.pkgname(pkgdirurl)
- pkgcurrenturl = os.path.join(pkgdirurl, "current")
- specurl = os.path.join(pkgcurrenturl, "SPECS")
- if svn.ls(specurl, noerror=1):
- svn.export(specurl, tmpdir, rev=rev)
- found = glob.glob(os.path.join(tmpdir, "*.spec"))
- if found:
- specpath = found[0]
- options = rpm_macros_defs(macros)
- command = (("rpm -q --qf '%%{EPOCH}:%%{VERSION}-%%{RELEASE}\n' "
- "--specfile %s %s 2>/dev/null") %
- (specpath, options))
- status, output = execcmd(command)
- if status != 0:
- raise Error, "Error in command %s: %s" % (command, output)
- releases = output.split()
- try:
- epoch, vr = releases[0].split(":", 1)
- version, release = vr.split("-", 1)
- except ValueError:
- raise Error, "Invalid command output: %s: %s" % \
- (command, output)
- #XXX check if this is the right way:
- if epoch == "(none)":
- ev = version
- else:
- ev = epoch + ":" + version
- return ev, release
+ found = glob.glob(os.path.join(tmpdir, "*.spec"))
+ if not found:
+ raise Error, "no .spec file found inside %s" % specurl
+ specpath = found[0]
+ options = rpm_macros_defs(macros)
+ command = (("rpm -q --qf '%%{EPOCH}:%%{VERSION}-%%{RELEASE}\n' "
+ "--specfile %s %s 2>/dev/null") %
+ (specpath, options))
+ status, output = execcmd(command)
+ if status != 0:
+ raise Error, "Error in command %s: %s" % (command, output)
+ releases = output.split()
+ try:
+ epoch, vr = releases[0].split(":", 1)
+ version, release = vr.split("-", 1)
+ except ValueError:
+ raise Error, "Invalid command output: %s: %s" % \
+ (command, output)
+ #XXX check if this is the right way:
+ if epoch == "(none)":
+ ev = version
+ else:
+ ev = epoch + ":" + version
+ return ev, release
finally:
- if os.path.isdir(tmpdir):
+ if exported is None and os.path.isdir(tmpdir):
shutil.rmtree(tmpdir)
class _Revision:
@@ -360,7 +362,7 @@ def parse_markrelease_log(relentry):
def svn2rpm(pkgdirurl, rev=None, size=None, submit=False,
- template=None, macros=[]):
+ template=None, macros=[], exported=None):
concat = config.get("log", "concat", "").split()
revoffset = get_revision_offset()
svn = SVN(baseurl=pkgdirurl)
@@ -423,7 +425,8 @@ def svn2rpm(pkgdirurl, rev=None, size=None, submit=False,
if notsubmitted:
# if they are not submitted yet, what we have to do is to add
# a release/version number from getrelease()
- version, release = getrelease(pkgdirurl, macros=macros)
+ version, release = getrelease(pkgdirurl, macros=macros,
+ exported=exported)
toprelease = make_release(entries=notsubmitted, released=False,
version=version, release=release)
releases.append(toprelease)
@@ -434,7 +437,7 @@ def svn2rpm(pkgdirurl, rev=None, size=None, submit=False,
def specfile_svn2rpm(pkgdirurl, specfile, rev=None, size=None,
- submit=False, template=None, macros=[]):
+ submit=False, template=None, macros=[], exported=None):
newlines = []
found = 0
@@ -451,7 +454,7 @@ def specfile_svn2rpm(pkgdirurl, specfile, rev=None, size=None,
# Create new changelog
newlines.append("\n\n%changelog\n")
newlines.append(svn2rpm(pkgdirurl, rev=rev, size=size, submit=submit,
- template=template, macros=macros))
+ template=template, macros=macros, exported=exported))
# Merge old changelog, if available
oldurl = config.get("log", "oldurl")
@@ -461,10 +464,13 @@ def specfile_svn2rpm(pkgdirurl, specfile, rev=None, size=None,
try:
pkgname = RepSysTree.pkgname(pkgdirurl)
pkgoldurl = os.path.join(oldurl, pkgname)
- if svn.ls(pkgoldurl, noerror=1):
+ try:
# we're using HEAD here because fixes in misc/ (oldurl) may
# be newer than packages' last changed revision.
svn.export(pkgoldurl, tmpdir)
+ except Error:
+ pass
+ else:
logfile = os.path.join(tmpdir, "log")
if os.path.isfile(logfile):
file = open(logfile)
diff --git a/RepSys/rpmutil.py b/RepSys/rpmutil.py
index bd75254..559b64c 100644
--- a/RepSys/rpmutil.py
+++ b/RepSys/rpmutil.py
@@ -77,7 +77,7 @@ def get_srpm(pkgdirurl,
if svnlog:
submit = not not revision
specfile_svn2rpm(pkgdirurl, spec, revision, submit=submit,
- template=template, macros=macros)
+ template=template, macros=macros, exported=tmpdir)
#FIXME revisioreal not needed if revision is None
#FIXME use geturl instead of pkgdirurl
revisionreal = svn.revision(pkgdirurl)