mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
- first attempt at "osc pull" and "linkcontrol"
This commit is contained in:
parent
3285fafaac
commit
72e6edc997
@ -4361,6 +4361,39 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
print 'run \'osc resolved ...\', and commit the changes.'
|
||||
|
||||
|
||||
def do_pull(self, subcmd, opts, *args):
|
||||
"""${cmd_name}: merge the changes of the link target into your working copy.
|
||||
|
||||
${cmd_option_list}
|
||||
"""
|
||||
|
||||
if not is_package_dir('.'):
|
||||
raise oscerr.NoWorkingCopy("Error: \"%s\" is not an osc working copy." % os.path.abspath("."))
|
||||
p = Package('.')
|
||||
# check if everything is committed
|
||||
for filename in p.filenamelist:
|
||||
st = p.status(filename)
|
||||
if st != ' ':
|
||||
raise oscerr.WrongArgs('Please commit your local changes first!')
|
||||
# check if we need to update
|
||||
upstream_rev = p.latest_rev()
|
||||
if p.rev != upstream_rev:
|
||||
raise oscerr.WorkingCopyOutdated((p.absdir, p.rev, upstream_rev))
|
||||
if not p.islink():
|
||||
raise oscerr.WrongArgs('osc pull only works on linked packages.')
|
||||
if not p.isexpanded():
|
||||
raise oscerr.WrongArgs('osc pull only works on expanded links.')
|
||||
|
||||
# hack
|
||||
conf.config['linkcontrol'] = 0
|
||||
# do the update
|
||||
pulledrev=p.latest_rev()
|
||||
if pulledrev == p.rev:
|
||||
raise oscerr.WrongArgs('Already up-to-date.')
|
||||
p.update(rev=pulledrev)
|
||||
store_write_string(p.absdir, '_pulled', '')
|
||||
|
||||
|
||||
@cmdln.option('--create', action='store_true', default=False,
|
||||
help='create new gpg signing key for this project')
|
||||
@cmdln.option('--delete', action='store_true', default=False,
|
||||
|
@ -106,6 +106,7 @@ DEFAULTS = { 'apiurl': 'https://api.opensuse.org',
|
||||
'check_filelist': '1',
|
||||
# check for pending requests after executing an action (e.g. checkout, update, commit)
|
||||
'check_for_request_on_action': '0',
|
||||
'linkcontrol': '0',
|
||||
|
||||
# Maintenance defaults to OBS instance defaults
|
||||
'maintained_attribute': 'OBS:Maintained',
|
||||
@ -117,7 +118,7 @@ DEFAULTS = { 'apiurl': 'https://api.opensuse.org',
|
||||
config = DEFAULTS.copy()
|
||||
|
||||
boolean_opts = ['debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'traceback', 'check_filelist', 'plaintext_passwd',
|
||||
'checkout_no_colon', 'check_for_request_on_action']
|
||||
'checkout_no_colon', 'check_for_request_on_action', 'linkcontrol']
|
||||
|
||||
new_conf_template = """
|
||||
[general]
|
||||
|
16
osc/core.py
16
osc/core.py
@ -827,7 +827,7 @@ class Package:
|
||||
print 'Please resolve all conflicts before committing using "osc resolved FILE"!'
|
||||
return 1
|
||||
|
||||
if not self.todo_send and not self.todo_delete and not self.rev == "upload" and not self.islinkrepair():
|
||||
if not self.todo_send and not self.todo_delete and not self.rev == "upload" and not self.islinkrepair() and not self.ispulled():
|
||||
print 'nothing to do for package %s' % self.name
|
||||
return 1
|
||||
|
||||
@ -857,6 +857,8 @@ class Package:
|
||||
'comment': msg }
|
||||
if self.islink() and self.isexpanded():
|
||||
query['keeplink'] = '1'
|
||||
if conf.config['linkcontrol']:
|
||||
query['linkrev'] = self.linkinfo.srcmd5
|
||||
if self.islinkrepair():
|
||||
query['repairlink'] = '1'
|
||||
u = makeurl(self.apiurl, ['source', self.prjname, self.name], query=query)
|
||||
@ -876,6 +878,7 @@ class Package:
|
||||
print
|
||||
print 'Committed revision %s.' % self.rev
|
||||
|
||||
os.unlink(os.path.join(self.storedir, '_pulled'))
|
||||
if self.islinkrepair():
|
||||
os.unlink(os.path.join(self.storedir, '_linkrepair'))
|
||||
self.linkrepair = False
|
||||
@ -1039,6 +1042,10 @@ class Package:
|
||||
"""tells us if we are repairing a broken source link."""
|
||||
return self.linkrepair
|
||||
|
||||
def ispulled(self):
|
||||
"""tells us if we have pulled a link."""
|
||||
return os.path.isfile(os.path.join(self.storedir, '_pulled'))
|
||||
|
||||
def haslinkerror(self):
|
||||
"""
|
||||
Returns True if the link is broken otherwise False.
|
||||
@ -1244,7 +1251,10 @@ rev: %s
|
||||
if self.islinkrepair():
|
||||
upstream_rev = show_upstream_xsrcmd5(self.apiurl, self.prjname, self.name, linkrepair=1)
|
||||
elif self.islink() and self.isexpanded():
|
||||
upstream_rev = show_upstream_xsrcmd5(self.apiurl, self.prjname, self.name)
|
||||
if conf.config['linkcontrol'] and self.ispulled():
|
||||
upstream_rev = show_upstream_xsrcmd5(self.apiurl, self.prjname, self.name, linkrev=self.linkinfo.srcmd5)
|
||||
else:
|
||||
upstream_rev = show_upstream_xsrcmd5(self.apiurl, self.prjname, self.name)
|
||||
else:
|
||||
upstream_rev = show_upstream_rev(self.apiurl, self.prjname, self.name)
|
||||
return upstream_rev
|
||||
@ -2279,6 +2289,8 @@ def show_files_meta(apiurl, prj, pac, revision=None, expand=False, linkrev=None,
|
||||
query['rev'] = 'latest'
|
||||
if linkrev:
|
||||
query['linkrev'] = linkrev
|
||||
elif conf.config['linkcontrol']:
|
||||
query['linkrev'] = 'base'
|
||||
if expand:
|
||||
query['expand'] = 1
|
||||
if linkrepair:
|
||||
|
Loading…
Reference in New Issue
Block a user