mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-09 22:36:14 +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:
parent
2618902347
commit
6ff961279c
8
NEWS
8
NEWS
@ -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:
|
||||
|
||||
- osc rdiff / osc submitreq show: diff the _expanded_ sources [bnc#408267]
|
||||
|
@ -68,6 +68,10 @@ def run(prg):
|
||||
print >>sys.stderr, 'BuildService API error:', e.msg
|
||||
return 1
|
||||
|
||||
except oscerr.LinkExpandError, e:
|
||||
print >>sys.stderr, 'Link cannot be expanded:\n', e
|
||||
return 1
|
||||
|
||||
except oscerr.UnreadableFile, e:
|
||||
print >>sys.stderr, e.msg
|
||||
return 1
|
||||
|
26
osc/core.py
26
osc/core.py
@ -185,6 +185,7 @@ class Linkinfo:
|
||||
self.xsrcmd5 = None
|
||||
self.lsrcmd5 = None
|
||||
self.srcmd5 = None
|
||||
self.error = None
|
||||
|
||||
def read(self, linkinfo_node):
|
||||
"""read in the linkinfo metadata from the <linkinfo> element passed as
|
||||
@ -198,6 +199,7 @@ class Linkinfo:
|
||||
self.xsrcmd5 = linkinfo_node.get('xsrcmd5')
|
||||
self.lsrcmd5 = linkinfo_node.get('lsrcmd5')
|
||||
self.srcmd5 = linkinfo_node.get('srcmd5')
|
||||
self.error = linkinfo_node.get('error')
|
||||
|
||||
def islink(self):
|
||||
"""returns True if the linkinfo is not empty, otherwise False"""
|
||||
@ -211,14 +213,24 @@ class Linkinfo:
|
||||
return True
|
||||
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):
|
||||
"""return an informatory string representation"""
|
||||
if self.islink() and not self.isexpanded():
|
||||
return 'project %s, package %s, xsrcmd5 %s' \
|
||||
% (self.project, self.package, self.xsrcmd5)
|
||||
elif self.islink() and self.isexpanded():
|
||||
return 'expanded link to project %s, package %s, srcmd5 %s, lsrcmd5 %s' \
|
||||
% (self.project, self.package, self.srcmd5, self.lsrcmd5)
|
||||
if self.haserror():
|
||||
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:
|
||||
return 'None'
|
||||
|
||||
@ -1748,10 +1760,18 @@ def show_upstream_xsrcmd5(apiurl, prj, pac):
|
||||
m = show_files_meta(apiurl, prj, pac)
|
||||
try:
|
||||
# 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:
|
||||
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):
|
||||
m = show_files_meta(apiurl, prj, pac)
|
||||
|
@ -64,6 +64,9 @@ class WorkingCopyOutdated(OscBaseError):
|
||||
% (self[0], self[1], self[2]))
|
||||
|
||||
|
||||
class LinkExpandError(OscBaseError):
|
||||
"""Exception raised when source link expansion fails"""
|
||||
|
||||
class UnreadableFile(OscBaseError):
|
||||
def __init__(self, msg):
|
||||
OscBaseError.__init__(self)
|
||||
|
Loading…
Reference in New Issue
Block a user