mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
- fix test for modified files
- print message after the repairlink commit - destroy upload revision if commit fails - use "latest" when revision is not specified
This commit is contained in:
parent
7c423392e1
commit
90cb8163b6
@ -1555,7 +1555,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
|
||||
# FIXME: ugly workaround for #399247
|
||||
if opts.expand_link or opts.unexpand_link:
|
||||
if [ i for i in p.filenamelist+p.filenamelist_unvers if p.status(i) != ' ' ]:
|
||||
if [ i for i in p.filenamelist+p.filenamelist_unvers if p.status(i) != ' ' and p.status(i) != '?']:
|
||||
print >>sys.stderr, 'osc: cannot expand/unexpand because your working ' \
|
||||
'copy has local modifications. Please remove them ' \
|
||||
'and try again'
|
||||
@ -2811,11 +2811,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
f = http_GET(u)
|
||||
meta = f.readlines()
|
||||
root_new = ET.parse(StringIO(''.join(meta))).getroot()
|
||||
dir_new = {'apiurl': apiurl}
|
||||
dir_new = { 'apiurl': apiurl, 'project': prj, 'package': package }
|
||||
dir_new['srcmd5'] = root_new.get('srcmd5')
|
||||
dir_new['entries'] = map(lambda e: [e.get('name'), e.get('md5')], root_new.findall('entry'))
|
||||
dir_new['project'] = prj
|
||||
dir_new['package'] = package
|
||||
|
||||
query = { 'rev': lastworkingrev }
|
||||
u = makeurl(apiurl, ['source', prj, package], query=query)
|
||||
@ -2826,22 +2824,20 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
raise oscerr.APIError('lastworking is not a source link?')
|
||||
if linkinfo_oldpatched.get('error') != None:
|
||||
raise oscerr.APIError('lastworking is not working?')
|
||||
dir_oldpatched = {'apiurl': apiurl}
|
||||
dir_oldpatched = { 'apiurl': apiurl, 'project': prj, 'package': package }
|
||||
dir_oldpatched['srcmd5'] = root_oldpatched.get('srcmd5')
|
||||
dir_oldpatched['entries'] = map(lambda e: [e.get('name'), e.get('md5')], root_oldpatched.findall('entry'))
|
||||
dir_oldpatched['project'] = prj
|
||||
dir_oldpatched['package'] = package
|
||||
|
||||
query = {}
|
||||
query['rev'] = linkinfo_oldpatched.get('srcmd5')
|
||||
u = makeurl(apiurl, ['source', linkinfo_oldpatched.get('project'), linkinfo_oldpatched.get('package')], query=query)
|
||||
f = http_GET(u)
|
||||
root_old = ET.parse(f).getroot()
|
||||
dir_old = {'apiurl': apiurl}
|
||||
dir_old['srcmd5'] = root_old.get('srcmd5')
|
||||
dir_old['entries'] = map(lambda e: [e.get('name'), e.get('md5')], root_old.findall('entry'))
|
||||
dir_old = { 'apiurl': apiurl }
|
||||
dir_old['project'] = linkinfo_oldpatched.get('project')
|
||||
dir_old['package'] = linkinfo_oldpatched.get('package')
|
||||
dir_old['srcmd5'] = root_old.get('srcmd5')
|
||||
dir_old['entries'] = map(lambda e: [e.get('name'), e.get('md5')], root_old.findall('entry'))
|
||||
|
||||
entries_old = dict(dir_old['entries'])
|
||||
entries_oldpatched = dict(dir_oldpatched['entries'])
|
||||
|
70
osc/core.py
70
osc/core.py
@ -675,8 +675,8 @@ class Package:
|
||||
# the working copy may be updated, so the .r* ending may be obsolete...
|
||||
# then we don't care
|
||||
os.unlink(upfilename)
|
||||
if self.islinkrepair():
|
||||
os.unlink(os.path.join(self.dir, n + '.old'))
|
||||
if self.islinkrepair():
|
||||
os.unlink(os.path.join(self.dir, n + '.old'))
|
||||
except:
|
||||
pass
|
||||
|
||||
@ -729,6 +729,7 @@ class Package:
|
||||
|
||||
pathn = getTransActPath(self.dir)
|
||||
|
||||
have_conflicts = False
|
||||
for filename in self.todo:
|
||||
st = self.status(filename)
|
||||
if st == 'A' or st == 'M':
|
||||
@ -736,7 +737,13 @@ class Package:
|
||||
print statfrmt('Sending', os.path.join(pathn, filename))
|
||||
elif st == 'D':
|
||||
self.todo_delete.append(filename)
|
||||
print statfrmt('Deleting', os.path.join(pathn, filename))
|
||||
print statfrmt('Deleting', os.path.join(pathn, filename))
|
||||
elif st == 'C':
|
||||
have_conflicts = True
|
||||
|
||||
if have_conflicts and self.islinkrepair():
|
||||
print 'Please resolve all conflicts before committing!'
|
||||
return 1
|
||||
|
||||
if not self.todo_send and not self.todo_delete and not self.rev == "upload":
|
||||
print 'nothing to do for package %s' % self.name
|
||||
@ -750,30 +757,29 @@ class Package:
|
||||
f = http_POST(u)
|
||||
|
||||
print 'Transmitting file data ',
|
||||
for filename in self.todo_delete:
|
||||
# do not touch local files on commit --
|
||||
# delete remotely instead
|
||||
self.delete_remote_source_file(filename)
|
||||
self.to_be_deleted.remove(filename)
|
||||
for filename in self.todo_send:
|
||||
sys.stdout.write('.')
|
||||
sys.stdout.flush()
|
||||
self.put_source_file(filename)
|
||||
|
||||
# all source files are committed - now comes the log
|
||||
query = { 'cmd' : 'commit',
|
||||
'rev' : 'upload',
|
||||
'user' : conf.get_apiurl_usr(self.apiurl),
|
||||
'comment': msg }
|
||||
if self.islink() and self.isexpanded():
|
||||
query['keeplink'] = '1'
|
||||
if self.islinkrepair():
|
||||
query['repairlink'] = '1'
|
||||
u = makeurl(self.apiurl, ['source', self.prjname, self.name], query=query)
|
||||
try:
|
||||
for filename in self.todo_delete:
|
||||
# do not touch local files on commit --
|
||||
# delete remotely instead
|
||||
self.delete_remote_source_file(filename)
|
||||
self.to_be_deleted.remove(filename)
|
||||
for filename in self.todo_send:
|
||||
sys.stdout.write('.')
|
||||
sys.stdout.flush()
|
||||
self.put_source_file(filename)
|
||||
|
||||
# all source files are committed - now comes the log
|
||||
query = { 'cmd' : 'commit',
|
||||
'rev' : 'upload',
|
||||
'user' : conf.get_apiurl_usr(self.apiurl),
|
||||
'comment': msg }
|
||||
if self.islink() and self.isexpanded():
|
||||
query['keeplink'] = '1'
|
||||
if self.islinkrepair():
|
||||
query['repairlink'] = '1'
|
||||
u = makeurl(self.apiurl, ['source', self.prjname, self.name], query=query)
|
||||
f = http_POST(u)
|
||||
except urllib2.HTTPError, e:
|
||||
e.osc_msg = 'commit failed'
|
||||
# delete upload revision
|
||||
try:
|
||||
query = { 'cmd': 'deleteuploadrev' }
|
||||
@ -782,6 +788,7 @@ class Package:
|
||||
except:
|
||||
pass
|
||||
raise e
|
||||
|
||||
root = ET.parse(f).getroot()
|
||||
self.rev = int(root.get('rev'))
|
||||
print
|
||||
@ -791,6 +798,7 @@ class Package:
|
||||
os.unlink(os.path.join(self.storedir, '_linkrepair'))
|
||||
self.linkrepair = False
|
||||
# XXX: mark package as invalid?
|
||||
print 'The source link has been repaired. This directory can now be removed.'
|
||||
if self.islink() and self.isexpanded():
|
||||
self.update_local_filesmeta(revision=self.latest_rev())
|
||||
else:
|
||||
@ -1627,6 +1635,8 @@ def meta_get_filelist(apiurl, prj, package, verbose=False, expand=False, revisio
|
||||
query['expand'] = 1
|
||||
if revision:
|
||||
query['rev'] = revision
|
||||
else:
|
||||
query['rev'] = 'latest'
|
||||
|
||||
u = makeurl(apiurl, ['source', prj, package], query=query)
|
||||
f = http_GET(u)
|
||||
@ -1850,15 +1860,17 @@ def edit_meta(metatype,
|
||||
|
||||
|
||||
def show_files_meta(apiurl, prj, pac, expand=False, revision=None, linkrev=None, linkrepair=False):
|
||||
query = None
|
||||
query = {}
|
||||
if revision:
|
||||
query = { 'rev': revision }
|
||||
query['rev'] = revision
|
||||
else:
|
||||
query['rev'] = 'latest'
|
||||
if linkrev:
|
||||
query = { 'linkrev': linkrev }
|
||||
query['linkrev'] = linkrev
|
||||
if expand:
|
||||
query = { 'expand': 1 }
|
||||
query['expand'] = 1
|
||||
if linkrepair:
|
||||
query = { 'emptylink': 1 }
|
||||
query['emptylink'] = 1
|
||||
f = http_GET(makeurl(apiurl, ['source', prj, pac], query=query))
|
||||
return f.readlines()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user