1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00

basic patchinfo support, calling api for generate file and to edit it

This commit is contained in:
Adrian Schröter 2009-11-10 09:56:34 +00:00
parent cdb8fabcbb
commit 81afb0fa4d
3 changed files with 48 additions and 3 deletions

1
NEWS
View File

@ -26,6 +26,7 @@
- search: allow to limit results via existing attibutes
- added "osc meta attribute" for basic attribute creation, deletion, showing and value setting
- implement "osc mbranch" call to create projects with multiple source package (instances)
- new "osc patchinfo" command: basic patchinfo generation and modification support
0.123
- IMPORTANT: ssl certificate checks are actually performed now to

View File

@ -308,6 +308,50 @@ class Osc(cmdln.Cmdln):
print '\n'.join(l)
@cmdln.option('-f', '--force', action='store_true',
help='force generation of new patchinfo file')
@cmdln.option('--force-update', action='store_true',
help='drops away collected packages from an already built patch and let it collect again')
def do_patchinfo(self, subcmd, opts, *args):
"""${cmd_name}: Generate and edit a patchinfo file.
A patchinfo file describes the packages for an update and the kind of
problem it solves.
Examples:
osc patchinfo
osc patchinfo PATCH_NAME
${cmd_option_list}
"""
project_dir = localdir = os.getcwd()
if is_project_dir(localdir):
project = Project(localdir).name
apiurl = Project(localdir).apiurl
else:
sys.exit('This command must be called in a checked out project.')
for p in meta_get_packagelist(apiurl, project):
if p.startswith("_patchinfo:"):
patchinfo = p
if opts.force or not patchinfo:
print "Creating initial patchinfo..."
query='cmd=createpatchinfo'
if args[0]:
query += "&name=" + args[0]
url = makeurl(apiurl, ['source', project], query=query)
f = http_POST(url)
if not os.path.exists(project_dir + "/" + patchinfo):
checkout_package(apiurl, project, patchinfo, prj_dir=project_dir)
if sys.platform[:3] != 'win':
editor = os.getenv('EDITOR', default='vim')
else:
editor = os.getenv('EDITOR', default='notepad')
subprocess.call('%s %s' % (editor, project_dir + "/" + patchinfo + "/_patchinfo"), shell=True)
@cmdln.option('-a', '--attribute', metavar='ATTRIBUTE',
help='affect only a given attribute')
@cmdln.option('--attribute-defaults', action='store_true',

View File

@ -3079,15 +3079,15 @@ def attribute_branch_pkg(apiurl, attribute, maintained_update_project_attribute,
query['update_project_attribute'] = maintained_update_project_attribute
u = makeurl(apiurl, ['source'], query=query)
f = None
try:
f = http_POST(u)
except urllib2.HTTPError, e:
if not return_existing:
raise
msg = ''.join(e.readlines())
msg = msg.split('<summary>')[1]
msg = msg.split('</summary>')[0]
m = re.match(r"branch target package already exists: (\S+)/", msg)
m = re.match(r"attribute branch call failed: (\S+)/", msg)
return m
r = f.read()
r = r.split('targetproject">')[1]