Skip to content

Commit

Permalink
Allow commits to linked pakages.
Browse files Browse the repository at this point in the history
If the package is linked to a different project, osc will ask
permision to branch the package in the current project before
commiting.

Show a message in osc meta pkg -e in the same case.
  • Loading branch information
aplanas committed Feb 24, 2014
1 parent 87e24c3 commit a20c6f5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,23 @@ def commit(self, msg='', verbose=False, skip_local_service_run=False):
# information (like which service/command failed)
raise oscerr.ServiceRuntimeError('A service failed with error: %d' % r)

# check if it is a link, if so, branch the package
orgprj = self.get_local_origin_project()
if self.prjname != orgprj:
print('Currect project:', self.prjname)
print('Linked project:', orgprj)
repl = raw_input('The package is linked from a different project.' \
' Create a local branch before commit? (y|N) ')
if repl in('y', 'Y'):
exists, targetprj, targetpkg, srcprj, srcpkg = branch_pkg(self.apiurl, orgprj, self.name,
target_project=self.prjname)
# update _meta and _files to sychronize the local package
# to the new branched one in OBS
self.update_local_pacmeta()
self.update_local_filesmeta()
else:
return 1

if not self.todo:
self.todo = [i for i in self.to_be_added if not i in self.filenamelist] + self.filenamelist

Expand Down Expand Up @@ -1538,6 +1555,16 @@ def get_files_meta(self, revision='latest', skip_service=True):
e.set('skipped', 'true')
return ET.tostring(root, encoding=ET_ENCODING)

def get_local_meta(self):
"""Get the local _meta file for the package."""
meta = store_read_file(self.absdir, '_meta')
return meta

def get_local_origin_project(self):
"""Get the originproject from the _meta file."""
root = ET.fromstring(self.get_local_meta())
return root.get('project')

def update_datastructs(self):
"""
Update the internal data structures if the local _files
Expand Down Expand Up @@ -3376,6 +3403,17 @@ def edit_meta(metatype,
if edit:
change_is_required = True

if metatype == 'pkg':
# check if the package is a link to a different project
project, package = path_args
orgprj = ET.fromstring(''.join(data)).get('project')
if project != orgprj:
print('The package is linked from a different project.')
print('If you want to edit the meta of the package create first a branch.')
print(' osc branch %s %s %s' % (orgprj, package, unquote(project)))
print(' osc meta pkg %s %s -e' % (unquote(project), package))
return

url = make_meta_url(metatype, path_args, apiurl, force, remove_linking_repositories)
f = metafile(url, data, change_is_required, metatypes[metatype]['file_ext'])

Expand Down

0 comments on commit a20c6f5

Please sign in to comment.