1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-27 02:16:12 +01:00

osc update / checkout: don't check out a working copy, or update an existing

one, when a source link cannot be applied [bnc#409373]

 - linkinfo elements can have an "error" attribute which indicates link
   application failure, which means that updating the working copy is not
   possible. 

 - Before this fix, osc could silently remove locally modified sources!
This commit is contained in:
Dr. Peter Poeml 2008-07-16 15:14:57 +00:00
parent 2618902347
commit 6ff961279c
4 changed files with 38 additions and 3 deletions

8
NEWS
View File

@ -1,3 +1,11 @@
0.107:
- osc build: the --extra-pkgs option is now a configurable setting in .oscrc.
Default is "extra-pkgs = vim gdb strace"
- .oscrc: make tilde expansion work on the packagecachedir setting
- osc update: don't update working copy when a source link can't apply [bnc#409373]
0.106: 0.106:
- osc rdiff / osc submitreq show: diff the _expanded_ sources [bnc#408267] - osc rdiff / osc submitreq show: diff the _expanded_ sources [bnc#408267]

View File

@ -68,6 +68,10 @@ def run(prg):
print >>sys.stderr, 'BuildService API error:', e.msg print >>sys.stderr, 'BuildService API error:', e.msg
return 1 return 1
except oscerr.LinkExpandError, e:
print >>sys.stderr, 'Link cannot be expanded:\n', e
return 1
except oscerr.UnreadableFile, e: except oscerr.UnreadableFile, e:
print >>sys.stderr, e.msg print >>sys.stderr, e.msg
return 1 return 1

View File

@ -185,6 +185,7 @@ class Linkinfo:
self.xsrcmd5 = None self.xsrcmd5 = None
self.lsrcmd5 = None self.lsrcmd5 = None
self.srcmd5 = None self.srcmd5 = None
self.error = None
def read(self, linkinfo_node): def read(self, linkinfo_node):
"""read in the linkinfo metadata from the <linkinfo> element passed as """read in the linkinfo metadata from the <linkinfo> element passed as
@ -198,6 +199,7 @@ class Linkinfo:
self.xsrcmd5 = linkinfo_node.get('xsrcmd5') self.xsrcmd5 = linkinfo_node.get('xsrcmd5')
self.lsrcmd5 = linkinfo_node.get('lsrcmd5') self.lsrcmd5 = linkinfo_node.get('lsrcmd5')
self.srcmd5 = linkinfo_node.get('srcmd5') self.srcmd5 = linkinfo_node.get('srcmd5')
self.error = linkinfo_node.get('error')
def islink(self): def islink(self):
"""returns True if the linkinfo is not empty, otherwise False""" """returns True if the linkinfo is not empty, otherwise False"""
@ -211,14 +213,24 @@ class Linkinfo:
return True return True
return False return False
def haserror(self):
"""returns True if the link is in error state (could not be applied)"""
if self.error:
return True
return False
def __str__(self): def __str__(self):
"""return an informatory string representation""" """return an informatory string representation"""
if self.islink() and not self.isexpanded(): if self.islink() and not self.isexpanded():
return 'project %s, package %s, xsrcmd5 %s' \ return 'project %s, package %s, xsrcmd5 %s' \
% (self.project, self.package, self.xsrcmd5) % (self.project, self.package, self.xsrcmd5)
elif self.islink() and self.isexpanded(): elif self.islink() and self.isexpanded():
return 'expanded link to project %s, package %s, srcmd5 %s, lsrcmd5 %s' \ if self.haserror():
% (self.project, self.package, self.srcmd5, self.lsrcmd5) return 'broken link to project %s, package %s, srcmd5 %s, lsrcmd5 %s: %s' \
% (self.project, self.package, self.srcmd5, self.lsrcmd5, self.error)
else:
return 'expanded link to project %s, package %s, srcmd5 %s, lsrcmd5 %s' \
% (self.project, self.package, self.srcmd5, self.lsrcmd5)
else: else:
return 'None' return 'None'
@ -1748,10 +1760,18 @@ def show_upstream_xsrcmd5(apiurl, prj, pac):
m = show_files_meta(apiurl, prj, pac) m = show_files_meta(apiurl, prj, pac)
try: try:
# only source link packages have a <linkinfo> element. # only source link packages have a <linkinfo> element.
return ET.parse(StringIO(''.join(m))).getroot().find('linkinfo').get('xsrcmd5') li_node = ET.parse(StringIO(''.join(m))).getroot().find('linkinfo')
except: except:
return None return None
li = Linkinfo()
li.read(li_node)
if li.haserror():
raise oscerr.LinkExpandError, li.error
else:
return li.xsrcmd5
def show_upstream_rev(apiurl, prj, pac): def show_upstream_rev(apiurl, prj, pac):
m = show_files_meta(apiurl, prj, pac) m = show_files_meta(apiurl, prj, pac)

View File

@ -64,6 +64,9 @@ class WorkingCopyOutdated(OscBaseError):
% (self[0], self[1], self[2])) % (self[0], self[1], self[2]))
class LinkExpandError(OscBaseError):
"""Exception raised when source link expansion fails"""
class UnreadableFile(OscBaseError): class UnreadableFile(OscBaseError):
def __init__(self, msg): def __init__(self, msg):
OscBaseError.__init__(self) OscBaseError.__init__(self)