Skip to content
Browse files

implement "mbranch" call as documented on

  • Loading branch information...
1 parent 4d0db61 commit 33dcce48cee11f0f40cbf3871d4cd2fcfd7ae379 @adrianschroeter adrianschroeter committed Nov 2, 2009
Showing with 98 additions and 3 deletions.
  1. +2 −1 NEWS
  2. +61 −0 osc/commandline.py
  3. +4 −0 osc/conf.py
  4. +31 −2 osc/core.py
View
3 NEWS
@@ -1,4 +1,3 @@
- - partial fix for bnc#551147
0.124
- added 'osc bugowner' as a more intelligent version of 'osc maintainer -B'
@@ -15,11 +14,13 @@
* This is meant as a proof of concept. I intend to generalize this usage of '.'
for all osc commands. Feedback welcome.
- support http proxies when using python 2.6 or newer (#551004)
+ - partial fix for checkout problems (bnc#551147)
#
# Features which require OBS 1.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)
0.123
- IMPORTANT: ssl certificate checks are actually performed now to
View
61 osc/commandline.py
@@ -1294,6 +1294,67 @@ def do_copypac(self, subcmd, opts, *args):
print r
+ @cmdln.option('-c', '--checkout', action='store_true',
+ help='Checkout branched package afterwards ' \
+ '(\'osc bco\' is a shorthand for this option)' )
+ @cmdln.option('-a', '--attribute', metavar='ATTRIBUTE',
+ help='Use this attribute to find affected packages (default is OBS:Maintained)')
+ @cmdln.option('-u', '--update-project-attribute', metavar='UPDATE_ATTRIBUTE',
+ help='Use this attribute to find update projects (default is OBS:UpdateProject) ')
+ def do_mbranch(self, subcmd, opts, *args):
+ """${cmd_name}: Multiple branch of a package
+
+ [See http://en.opensuse.org/Build_Service/Concepts/Maintenance for information
+ on this topic.]
+
+ This command is used for creating multiple links of defined version of a package
+ in one project. This is esp. used for maintenance updates.
+
+ The branched package will live in
+ home:USERNAME:branches:ATTRIBUTE:PACKAGE
+ if nothing else specified.
+
+ usage:
+ osc mbranch [ SOURCEPACKAGE [ TARGETPROJECT ] ]
+ ${cmd_option_list}
+ """
+ args = slash_split(args)
+ tproject = None
+
+ maintained_attribute = conf.config['maintained_attribute']
+ maintained_update_project_attribute = conf.config['maintained_update_project_attribute']
+
+ if not (len(args) >= 1 and len(args) <= 2):
+ raise oscerr.WrongArgs('Wrong number of arguments.')
+ if len(args) >= 1:
+ package = args[0]
+ if len(args) >= 2:
+ tproject = args[1]
+
+ r = attribute_branch_pkg(conf.config['apiurl'], maintained_attribute, maintained_update_project_attribute, \
+ package, tproject)
+
+ if r is None:
+ print >>sys.stderr, 'ERROR: Attribute branch call came not back with a project.'
+ sys.exit(1)
+
+ print "Project " + r + " created."
+
+ if opts.checkout:
+ init_project_dir(conf.config['apiurl'], r, r)
+ print statfrmt('A', r)
+
+ # all packages
+ for package in meta_get_packagelist(conf.config['apiurl'], r):
+ try:
+ checkout_package(conf.config['apiurl'], r, package, expand_link = True, prj_dir = r)
+ except:
+ print >>sys.stderr, 'Error while checkout package:\n', package
+
+ if conf.config['verbose']:
+ print 'Note: You can use "osc delete" or "osc submitpac" when done.\n'
+
+
@cmdln.alias('branchco')
@cmdln.alias('bco')
@cmdln.alias('getpac')
View
4 osc/conf.py
@@ -106,6 +106,10 @@
'check_filelist': '1',
# check for pending requests after executing an action (e.g. checkout, update, commit)
'check_for_request_on_action': '0',
+
+ # Maintenance defaults to OBS instance defaults
+ 'maintained_attribute': 'OBS:Maintained',
+ 'maintained_update_project_attribute': 'OBS:UpdateProject',
}
# being global to this module, this dict can be accessed from outside
View
33 osc/core.py
@@ -1783,8 +1783,6 @@ def makeurl(baseurl, l, query=[]):
function. In case of a list not -- this is to be backwards compatible.
"""
- print 'makeurl:', baseurl, l, query
-
if type(query) == type(list()):
query = '&'.join(query)
elif type(query) == type(dict()):
@@ -3063,6 +3061,37 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map =
http_PUT(u, data=aggregate_template)
print 'Done.'
+
+def attribute_branch_pkg(apiurl, attribute, maintained_update_project_attribute, package, targetproject):
+ """
+ Branch packages defined via attributes (via API call)
+ """
+ query = { 'cmd': 'branch' }
+ query['attribute'] = attribute
+ if targetproject:
+ query['target_project'] = targetproject
+ if package:
+ query['package'] = package
+ if maintained_update_project_attribute:
+ query['update_project_attribute'] = maintained_update_project_attribute
+
+ u = makeurl(apiurl, ['source'], query=query)
+ 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)
+
+ r = f.read()
+ r = r.split('targetproject">')[1]
+ r = r.split('</data>')[0]
+ return r
+
+
def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None, target_project=None, target_package=None, return_existing=False):
"""
Branch a package (via API call)

0 comments on commit 33dcce4

Please sign in to comment.
Something went wrong with that request. Please try again.