summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2010-01-16 18:21:25 +0100
committerSebastian Pipping <sebastian@pipping.org>2010-01-16 18:21:25 +0100
commit6c7d833b16fbe0c4d39af665e76fa47811edcad2 (patch)
treed8a4c74297e6fbbbf81b0a7870ac28e5cace5269
parent8d8f7a47dd95ad6a69b8058888cb7aaae9430c76 (diff)
downloadlayman-6c7d833b16fbe0c4d39af665e76fa47811edcad2.tar.gz
layman-6c7d833b16fbe0c4d39af665e76fa47811edcad2.tar.bz2
layman-6c7d833b16fbe0c4d39af665e76fa47811edcad2.zip
Fix syncing of overlays gone from remote lists
-rw-r--r--CHANGES7
-rw-r--r--layman/action.py46
-rw-r--r--layman/overlay.py5
3 files changed, 45 insertions, 13 deletions
diff --git a/CHANGES b/CHANGES
index 51ab56f..5ef7dd0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,13 @@
CHANGES
-------
+Version TODO
+=======================================
+
+ - Syncing failed for overlays that no longer exist in the remote
+ lists with no need to (bug #301174)
+
+
Version 1.3.0_rc1 - Released 2010/01/15
=======================================
diff --git a/layman/action.py b/layman/action.py
index 2701030..02ba1ce 100644
--- a/layman/action.py
+++ b/layman/action.py
@@ -111,17 +111,41 @@ class Sync:
warnings = []
success = []
for i in self.selection:
- ordb = self.rdb.select(i)
- odb = self.db.select(i)
- current_src = odb.sources[0].src
- available_srcs = set(e.src for e in ordb.sources)
- if ordb and odb and not current_src in available_srcs:
- warnings.append(
- 'The source of the overlay "' + i + '" seems to have c'
- 'hanged. You currently sync from "' + current_src + '" whi'
- 'le the global layman list reports "' + '" and "'.join(available_srcs) + '" '
- 'as correct location(s). Please consider removing and rea'
- 'dding the overlay!')
+ try:
+ ordb = self.rdb.select(i)
+ except:
+ warnings.append(\
+ 'Overlay "%s" could not be found in the remote lists.\n'
+ 'Please check if it has been renamed and re-add if necessary.' % i)
+ else:
+ odb = self.db.select(i)
+ current_src = odb.sources[0].src
+ available_srcs = set(e.src for e in ordb.sources)
+ if ordb and odb and not current_src in available_srcs:
+ if len(available_srcs) == 1:
+ plural = ''
+ candidates = ' %s' % tuple(available_srcs)[0]
+ else:
+ plural = 's'
+ candidates = '\n'.join((' %d. %s' % (i + 1, v)) for i, v in enumerate(available_srcs))
+
+ warnings.append(
+ 'The source of the overlay "%(repo_name)s" seems to have changed.\n'
+ 'You currently sync from\n'
+ '\n'
+ ' %(current_src)s\n'
+ '\n'
+ 'while the remote lists report\n'
+ '\n'
+ '%(candidates)s\n'
+ '\n'
+ 'as correct location%(plural)s.\n'
+ 'Please consider removing and re-adding the overlay.' % {
+ 'repo_name':i,
+ 'current_src':current_src,
+ 'candidates':candidates,
+ 'plural':plural,
+ })
try:
self.db.sync(i, self.quiet)
diff --git a/layman/overlay.py b/layman/overlay.py
index 0ea11f0..1058723 100644
--- a/layman/overlay.py
+++ b/layman/overlay.py
@@ -149,8 +149,9 @@ class Overlays:
>>> list(a.select('wrobel-stable').source_uris())
[u'rsync://gunnarwrobel.de/wrobel-stable']
'''
- if overlay in self.overlays.keys():
- return self.overlays[overlay]
+ if not overlay in self.overlays.keys():
+ raise Exception('No overlay "%s" in database' % overlay)
+ return self.overlays[overlay]
def list(self, verbose = False, width = 0):
'''