mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-28 10:46:15 +01:00
- cleanups
- fixed do_log - use "safe writes" in init_package_dir()
This commit is contained in:
parent
f023578cf2
commit
24d3b18e13
@ -4160,11 +4160,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
project = args[0]
|
project = args[0]
|
||||||
package = args[1]
|
package = args[1]
|
||||||
|
|
||||||
if opts.meta:
|
|
||||||
meta = 1
|
|
||||||
|
|
||||||
rev, dummy = parseRevisionOption(opts.revision)
|
rev, dummy = parseRevisionOption(opts.revision)
|
||||||
if rev and not checkRevision(project, package, rev, apiurl, meta):
|
if rev and not checkRevision(project, package, rev, apiurl, opts.meta):
|
||||||
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
|
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -4174,7 +4171,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if opts.xml:
|
if opts.xml:
|
||||||
format = 'xml'
|
format = 'xml'
|
||||||
|
|
||||||
log = '\n'.join(get_commitlog(apiurl, project, package, rev, format, meta))
|
log = '\n'.join(get_commitlog(apiurl, project, package, rev, format, opts.meta))
|
||||||
run_pager(log)
|
run_pager(log)
|
||||||
|
|
||||||
@cmdln.option('-f', '--failed', action='store_true',
|
@cmdln.option('-f', '--failed', action='store_true',
|
||||||
|
45
osc/core.py
45
osc/core.py
@ -845,6 +845,7 @@ class Package:
|
|||||||
|
|
||||||
self.write_conflictlist()
|
self.write_conflictlist()
|
||||||
|
|
||||||
|
# XXX: this isn't used at all
|
||||||
def write_meta_mode(self):
|
def write_meta_mode(self):
|
||||||
# XXX: the "elif" is somehow a contradiction (with current and the old implementation
|
# XXX: the "elif" is somehow a contradiction (with current and the old implementation
|
||||||
# it's not possible to "leave" the metamode again) (except if you modify pac.meta
|
# it's not possible to "leave" the metamode again) (except if you modify pac.meta
|
||||||
@ -2124,7 +2125,7 @@ def init_project_dir(apiurl, dir, project):
|
|||||||
if conf.config['do_package_tracking']:
|
if conf.config['do_package_tracking']:
|
||||||
store_write_initial_packages(dir, project, [])
|
store_write_initial_packages(dir, project, [])
|
||||||
|
|
||||||
def init_package_dir(apiurl, project, package, dir, revision=None, files=True, limit_size=None, meta=None):
|
def init_package_dir(apiurl, project, package, dir, revision=None, files=True, limit_size=None, meta=False):
|
||||||
if not os.path.isdir(store):
|
if not os.path.isdir(store):
|
||||||
os.mkdir(store)
|
os.mkdir(store)
|
||||||
os.chdir(store)
|
os.chdir(store)
|
||||||
@ -2136,31 +2137,21 @@ def init_package_dir(apiurl, project, package, dir, revision=None, files=True, l
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
if meta:
|
if meta:
|
||||||
f = open('_meta_mode', 'w')
|
store_write_string(os.pardir, '_meta_mode', '')
|
||||||
f.write("true")
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
if limit_size:
|
if limit_size:
|
||||||
f = open('_size_limit', 'w')
|
store_write_string(os.pardir, '_size_limit', str(limit_size))
|
||||||
f.write(str(limit_size))
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
if files:
|
if files:
|
||||||
f = open('_files', 'w')
|
fmeta = ''.join(show_files_meta(apiurl, project, package, revision=revision, limit_size=limit_size, meta=meta))
|
||||||
f.write(''.join(show_files_meta(apiurl, project, package, revision=revision, limit_size=limit_size, meta=meta)))
|
store_write_string(os.pardir, '_files', fmeta)
|
||||||
f.close()
|
|
||||||
else:
|
else:
|
||||||
# create dummy
|
# create dummy
|
||||||
ET.ElementTree(element=ET.Element('directory')).write('_files')
|
ET.ElementTree(element=ET.Element('directory')).write('_files')
|
||||||
|
|
||||||
f = open('_osclib_version', 'w')
|
store_write_string(os.pardir, '_osclib_version', __store_version__ + '\n')
|
||||||
f.write(__store_version__ + '\n')
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
store_write_apiurl(os.path.pardir, apiurl)
|
store_write_apiurl(os.path.pardir, apiurl)
|
||||||
|
|
||||||
os.chdir(os.pardir)
|
os.chdir(os.pardir)
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def check_store_version(dir):
|
def check_store_version(dir):
|
||||||
@ -2267,7 +2258,7 @@ def show_package_trigger_reason(apiurl, prj, pac, repo, arch):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def show_package_meta(apiurl, prj, pac, meta=None):
|
def show_package_meta(apiurl, prj, pac, meta=False):
|
||||||
query = {}
|
query = {}
|
||||||
if meta:
|
if meta:
|
||||||
query['meta'] = 1
|
query['meta'] = 1
|
||||||
@ -2487,7 +2478,7 @@ def edit_meta(metatype,
|
|||||||
f.sync()
|
f.sync()
|
||||||
|
|
||||||
|
|
||||||
def show_files_meta(apiurl, prj, pac, revision=None, expand=False, linkrev=None, linkrepair=False, limit_size=None, meta=None):
|
def show_files_meta(apiurl, prj, pac, revision=None, expand=False, linkrev=None, linkrepair=False, limit_size=None, meta=False):
|
||||||
query = {}
|
query = {}
|
||||||
if revision:
|
if revision:
|
||||||
query['rev'] = revision
|
query['rev'] = revision
|
||||||
@ -2513,12 +2504,12 @@ def show_files_meta(apiurl, prj, pac, revision=None, expand=False, linkrev=None,
|
|||||||
return ET.tostring(root)
|
return ET.tostring(root)
|
||||||
|
|
||||||
|
|
||||||
def show_upstream_srcmd5(apiurl, prj, pac, expand=False, revision=None, meta=None):
|
def show_upstream_srcmd5(apiurl, prj, pac, expand=False, revision=None, meta=False):
|
||||||
m = show_files_meta(apiurl, prj, pac, expand=expand, revision=revision, meta=meta)
|
m = show_files_meta(apiurl, prj, pac, expand=expand, revision=revision, meta=meta)
|
||||||
return ET.fromstring(''.join(m)).get('srcmd5')
|
return ET.fromstring(''.join(m)).get('srcmd5')
|
||||||
|
|
||||||
|
|
||||||
def show_upstream_xsrcmd5(apiurl, prj, pac, revision=None, linkrev=None, linkrepair=False, meta=None):
|
def show_upstream_xsrcmd5(apiurl, prj, pac, revision=None, linkrev=None, linkrepair=False, meta=False):
|
||||||
m = show_files_meta(apiurl, prj, pac, revision=revision, linkrev=linkrev, linkrepair=linkrepair, meta=meta)
|
m = show_files_meta(apiurl, prj, pac, revision=revision, linkrev=linkrev, linkrepair=linkrepair, meta=meta)
|
||||||
try:
|
try:
|
||||||
# only source link packages have a <linkinfo> element.
|
# only source link packages have a <linkinfo> element.
|
||||||
@ -2534,7 +2525,7 @@ def show_upstream_xsrcmd5(apiurl, prj, pac, revision=None, linkrev=None, linkrep
|
|||||||
return li.xsrcmd5
|
return li.xsrcmd5
|
||||||
|
|
||||||
|
|
||||||
def show_upstream_rev(apiurl, prj, pac, meta=None):
|
def show_upstream_rev(apiurl, prj, pac, meta=False):
|
||||||
m = show_files_meta(apiurl, prj, pac, meta=meta)
|
m = show_files_meta(apiurl, prj, pac, meta=meta)
|
||||||
return ET.fromstring(''.join(m)).get('rev')
|
return ET.fromstring(''.join(m)).get('rev')
|
||||||
|
|
||||||
@ -2917,7 +2908,7 @@ def download(url, filename, progress_obj = None, mtime = None):
|
|||||||
if mtime:
|
if mtime:
|
||||||
os.utime(filename, (-1, mtime))
|
os.utime(filename, (-1, mtime))
|
||||||
|
|
||||||
def get_source_file(apiurl, prj, package, filename, targetfilename=None, revision=None, progress_obj=None, mtime=None, meta=None):
|
def get_source_file(apiurl, prj, package, filename, targetfilename=None, revision=None, progress_obj=None, mtime=None, meta=False):
|
||||||
targetfilename = targetfilename or filename
|
targetfilename = targetfilename or filename
|
||||||
query = {}
|
query = {}
|
||||||
if meta:
|
if meta:
|
||||||
@ -3144,7 +3135,7 @@ def make_diff(wc, revision):
|
|||||||
|
|
||||||
def server_diff(apiurl,
|
def server_diff(apiurl,
|
||||||
old_project, old_package, old_revision,
|
old_project, old_package, old_revision,
|
||||||
new_project, new_package, new_revision, unified=False, missingok=False, meta=None):
|
new_project, new_package, new_revision, unified=False, missingok=False, meta=False):
|
||||||
query = {'cmd': 'diff', 'expand': '1'}
|
query = {'cmd': 'diff', 'expand': '1'}
|
||||||
if old_project:
|
if old_project:
|
||||||
query['oproject'] = old_project
|
query['oproject'] = old_project
|
||||||
@ -3211,7 +3202,7 @@ def make_dir(apiurl, project, package, pathname=None, prj_dir=None):
|
|||||||
|
|
||||||
def checkout_package(apiurl, project, package,
|
def checkout_package(apiurl, project, package,
|
||||||
revision=None, pathname=None, prj_obj=None,
|
revision=None, pathname=None, prj_obj=None,
|
||||||
expand_link=False, prj_dir=None, service_files=None, progress_obj=None, limit_size=None, meta=None):
|
expand_link=False, prj_dir=None, service_files=None, progress_obj=None, limit_size=None, meta=False):
|
||||||
try:
|
try:
|
||||||
# the project we're in might be deleted.
|
# the project we're in might be deleted.
|
||||||
# that'll throw an error then.
|
# that'll throw an error then.
|
||||||
@ -4030,7 +4021,7 @@ def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 't
|
|||||||
print '%s %-50s %-16s %-16s %-16s %-16s' % (endtime, package[0:49], reason[0:15], code[0:15], waitbuild, worker)
|
print '%s %-50s %-16s %-16s %-16s %-16s' % (endtime, package[0:49], reason[0:15], code[0:15], waitbuild, worker)
|
||||||
|
|
||||||
|
|
||||||
def get_commitlog(apiurl, prj, package, revision, format = 'text', meta = None):
|
def get_commitlog(apiurl, prj, package, revision, format = 'text', meta = False):
|
||||||
import time, locale
|
import time, locale
|
||||||
|
|
||||||
query = {}
|
query = {}
|
||||||
@ -4276,7 +4267,7 @@ def parseRevisionOption(string):
|
|||||||
else:
|
else:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
def checkRevision(prj, pac, revision, apiurl=None):
|
def checkRevision(prj, pac, revision, apiurl=None, meta=False):
|
||||||
"""
|
"""
|
||||||
check if revision is valid revision, i.e. it is not
|
check if revision is valid revision, i.e. it is not
|
||||||
larger than the upstream revision id
|
larger than the upstream revision id
|
||||||
@ -4287,7 +4278,7 @@ def checkRevision(prj, pac, revision, apiurl=None):
|
|||||||
if not apiurl:
|
if not apiurl:
|
||||||
apiurl = conf.config['apiurl']
|
apiurl = conf.config['apiurl']
|
||||||
try:
|
try:
|
||||||
if int(revision) > int(show_upstream_rev(apiurl, prj, pac)) \
|
if int(revision) > int(show_upstream_rev(apiurl, prj, pac, meta)) \
|
||||||
or int(revision) <= 0:
|
or int(revision) <= 0:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user