aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2011-01-25 18:14:00 +0000
committerNicolas Vigier <boklm@mageia.org>2011-01-25 18:14:00 +0000
commitdcfc80655d393f99a03d966af92b15c853f2d71a (patch)
treeef8d9f233d8447bca1c7f26ecad4287e083e6cd6
parent4f9a8fc5b69a342cff98726552184c8a33a57acd (diff)
downloadmgarepo-dcfc80655d393f99a03d966af92b15c853f2d71a.tar
mgarepo-dcfc80655d393f99a03d966af92b15c853f2d71a.tar.gz
mgarepo-dcfc80655d393f99a03d966af92b15c853f2d71a.tar.bz2
mgarepo-dcfc80655d393f99a03d966af92b15c853f2d71a.tar.xz
mgarepo-dcfc80655d393f99a03d966af92b15c853f2d71a.zip
add binrepo remove function
-rw-r--r--MgaRepo/binrepo.py26
-rw-r--r--MgaRepo/commands/del.py5
-rw-r--r--MgaRepo/rpmutil.py8
3 files changed, 26 insertions, 13 deletions
diff --git a/MgaRepo/binrepo.py b/MgaRepo/binrepo.py
index 9186980..1af5d6b 100644
--- a/MgaRepo/binrepo.py
+++ b/MgaRepo/binrepo.py
@@ -287,7 +287,8 @@ def update_sources(topdir, added=[], removed=[]):
entries = parse_sources(path)
f = open(path, "w") # open before calculating hashes
for name in removed:
- entries.pop(removed)
+ if name in entries:
+ del entries[name]
for added_path in added:
name = os.path.basename(added_path)
entries[name] = file_hash(added_path)
@@ -301,6 +302,29 @@ def update_sources_threaded(*args, **kwargs):
t.join()
return t
+def remove(path, message=None, commit=True):
+ from MgaRepo.rpmutil import getpkgtopdir
+ svn = SVN()
+ if not os.path.exists(path):
+ raise Error, "not found: %s" % path
+ bpath = os.path.basename(path)
+ topdir = getpkgtopdir()
+ bintopdir = translate_topdir(topdir)
+ update = update_sources_threaded(topdir, removed=[bpath])
+ sources = sources_path(topdir)
+ silent = config.get("log", "ignore-string", "SILENT")
+ if not message:
+ message = "%s: delete binary file %s" % (silent, bpath)
+ if commit:
+ svn.commit(topdir + " " + sources, log=message, nonrecursive=True)
+ binlink = os.path.join(topdir, "SOURCES", bpath)
+ if os.path.islink(binlink):
+ os.unlink(binlink)
+ binpath = os.path.join(topdir, BINARIES_CHECKOUT_NAME, bpath)
+ svn.remove(binpath)
+ if commit:
+ svn.commit(binpath, log=message)
+
def upload(path, message=None):
from MgaRepo.rpmutil import getpkgtopdir
svn = SVN()
diff --git a/MgaRepo/commands/del.py b/MgaRepo/commands/del.py
index 79d9d3f..c55d1aa 100644
--- a/MgaRepo/commands/del.py
+++ b/MgaRepo/commands/del.py
@@ -7,18 +7,13 @@ Usage: mgarepo del [OPTIONS] [PATH]
Remove a given file from the binary sources repository.
-Changes in the sources file will be left uncommited.
-
Options:
- -c automatically commit the 'sources' file
-h help
"""
def parse_options():
parser = OptionParser(help=HELP)
- parser.add_option("-c", dest="commit", default=False,
- action="store_true")
opts, args = parser.parse_args()
if len(args):
opts.paths = args
diff --git a/MgaRepo/rpmutil.py b/MgaRepo/rpmutil.py
index 74421a0..64afe95 100644
--- a/MgaRepo/rpmutil.py
+++ b/MgaRepo/rpmutil.py
@@ -666,16 +666,10 @@ def upload(paths):
binrepo.upload(path)
def binrepo_delete(paths, commit=False):
- #TODO handle files tracked by svn
refurl = binrepo.svn_root(paths[0])
if not binrepo.enabled(refurl):
raise Error, "binary repository is not enabled for %s" % refurl
- added, deleted = binrepo.remove(paths)
- if commit:
- svn = SVN()
- spath = binrepo.sources_path(paths[0])
- log = _sources_log(added, deleted)
- svn.commit(spath, log=log)
+ binrepo.remove(paths[0])
def switch(mirrorurl=None):
svn = SVN()