Hello community,

here is the log from the commit of package openSUSE-release-tools for 
openSUSE:Factory checked in at 2019-08-09 16:54:15
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/openSUSE-release-tools (Old)
 and      /work/SRC/openSUSE:Factory/.openSUSE-release-tools.new.9556 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "openSUSE-release-tools"

Fri Aug  9 16:54:15 2019 rev:200 rq:721868 version:20190808.410ee514

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/openSUSE-release-tools/openSUSE-release-tools.changes
    2019-08-06 17:27:33.140684978 +0200
+++ 
/work/SRC/openSUSE:Factory/.openSUSE-release-tools.new.9556/openSUSE-release-tools.changes
  2019-08-09 16:54:23.297454258 +0200
@@ -1,0 +2,11 @@
+Thu Aug 08 20:23:10 UTC 2019 - [email protected]
+
+- Update to version 20190808.410ee514:
+  * gocd: provide OS.Origin.Manager.Update.
+  * osc-origin: provide update command.
+  * osclib/origin: provide origin_update() to process updating single package.
+  * osclib/core: provide request_create_delete().
+  * osclib/core: provide request_create_submit() and RequestFuture.
+  * osclib/core: provide message_suffix() and utilize in source_file_save().
+
+-------------------------------------------------------------------

Old:
----
  openSUSE-release-tools-20190806.914d1061.obscpio

New:
----
  openSUSE-release-tools-20190808.410ee514.obscpio

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ openSUSE-release-tools.spec ++++++
--- /var/tmp/diff_new_pack.LM6Kv0/_old  2019-08-09 16:54:25.137453817 +0200
+++ /var/tmp/diff_new_pack.LM6Kv0/_new  2019-08-09 16:54:25.141453816 +0200
@@ -20,7 +20,7 @@
 %define source_dir openSUSE-release-tools
 %define announcer_filename factory-package-news
 Name:           openSUSE-release-tools
-Version:        20190806.914d1061
+Version:        20190808.410ee514
 Release:        0
 Summary:        Tools to aid in staging and release work for openSUSE/SUSE
 License:        GPL-2.0-or-later AND MIT

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.LM6Kv0/_old  2019-08-09 16:54:25.169453809 +0200
+++ /var/tmp/diff_new_pack.LM6Kv0/_new  2019-08-09 16:54:25.169453809 +0200
@@ -1,6 +1,6 @@
 <servicedata>
   <service name="tar_scm">
     <param 
name="url">https://github.com/openSUSE/openSUSE-release-tools.git</param>
-    <param 
name="changesrevision">914d106184f64f4c1ff2e58bdb2bdf733c79fc76</param>
+    <param 
name="changesrevision">ff7bfdca711bc6f6c2e44828b09d298cb74860b8</param>
   </service>
 </servicedata>

++++++ openSUSE-release-tools-20190806.914d1061.obscpio -> 
openSUSE-release-tools-20190808.410ee514.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/openSUSE-release-tools-20190806.914d1061/gocd/checkers.opensuse.gocd.yaml 
new/openSUSE-release-tools-20190808.410ee514/gocd/checkers.opensuse.gocd.yaml
--- 
old/openSUSE-release-tools-20190806.914d1061/gocd/checkers.opensuse.gocd.yaml   
    2019-08-06 14:39:54.000000000 +0200
+++ 
new/openSUSE-release-tools-20190808.410ee514/gocd/checkers.opensuse.gocd.yaml   
    2019-08-08 22:22:04.000000000 +0200
@@ -247,3 +247,21 @@
           - staging-bot
         tasks:
           - script: ./origin-manager.py -A https://api.opensuse.org --debug 
review
+  OS.Origin.Manager.Update:
+    group: openSUSE.Checkers
+    lock_behavior: unlockWhenFinished
+    environment_variables:
+      OSC_CONFIG: /home/go/config/oscrc-origin-manager
+    materials:
+      script:
+        git: https://github.com/openSUSE/openSUSE-release-tools.git
+    timer:
+      spec: 0 7 * ? * *
+      only_on_changes: false
+    stages:
+    - Run:
+        approval: manual
+        resources:
+          - staging-bot
+        tasks:
+          - script: osc -A https://api.opensuse.org origin -p 
openSUSE:Leap:15.2 update
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/openSUSE-release-tools-20190806.914d1061/osc-origin.py 
new/openSUSE-release-tools-20190808.410ee514/osc-origin.py
--- old/openSUSE-release-tools-20190806.914d1061/osc-origin.py  2019-08-06 
14:39:54.000000000 +0200
+++ new/openSUSE-release-tools-20190808.410ee514/osc-origin.py  2019-08-08 
22:22:04.000000000 +0200
@@ -19,10 +19,13 @@
 from osclib.origin import origin_history
 from osclib.origin import origin_potentials
 from osclib.origin import origin_revision_state
+from osclib.origin import origin_update
 from osclib.util import mail_send
 from shutil import copyfile
 import sys
 import time
+import traceback
+from urllib.error import HTTPError
 import yaml
 
 OSRT_ORIGIN_LOOKUP_TTL = 60 * 60 * 24 * 7
@@ -48,6 +51,7 @@
     potentials: list potential origins of a package
     projects: list all projects with an OSRT:OriginConfig attribute
     report: print origin summary report
+    update: handle package source changes as either delete or submit requests
 
     Usage:
         osc origin config [--origins-only]
@@ -58,12 +62,14 @@
         osc origin potentials [--format json|yaml] PACKAGE
         osc origin projects [--format json|yaml]
         osc origin report [--diff] [--force-refresh] [--mail]
+        osc origin update [PACKAGE...]
     """
 
     if len(args) == 0:
         raise oscerr.WrongArgs('A command must be indicated.')
     command = args[0]
-    if command not in ['config', 'cron', 'history', 'list', 'package', 
'potentials', 'projects', 'report']:
+    if command not in ['config', 'cron', 'history', 'list', 'package', 
'potentials',
+                       'projects', 'report', 'update']:
         raise oscerr.WrongArgs('Unknown command: {}'.format(command))
     if command == 'package' and len(args) < 2:
         raise oscerr.WrongArgs('A package must be indicated.')
@@ -330,3 +336,28 @@
     if opts.mail:
         mail_send(apiurl, opts.project, 'release-list', '{} origin 
report'.format(opts.project),
                   body, None, dry=opts.dry)
+
+def osrt_origin_update(apiurl, opts, *packages):
+    if len(packages) == 0:
+        packages = package_list_kind_filtered(apiurl, opts.project)
+
+    return_value = 0
+    for package in packages:
+        request_future = origin_update(apiurl, opts.project, package)
+        if not request_future:
+            continue
+
+        print(request_future)
+        if opts.dry:
+            continue
+
+        try:
+            request_id = request_future.create()
+            if request_id:
+                print('-> created request {}'.format(request_id))
+        except HTTPError:
+            return_value = 1
+            traceback.print_exc()
+
+    if return_value != 0:
+        sys.exit(return_value)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/openSUSE-release-tools-20190806.914d1061/osclib/core.py 
new/openSUSE-release-tools-20190808.410ee514/osclib/core.py
--- old/openSUSE-release-tools-20190806.914d1061/osclib/core.py 2019-08-06 
14:39:54.000000000 +0200
+++ new/openSUSE-release-tools-20190808.410ee514/osclib/core.py 2019-08-08 
22:22:04.000000000 +0200
@@ -13,6 +13,7 @@
     #python 2.x
     from urllib2 import HTTPError
 
+from osc.core import create_submit_request
 from osc.core import get_binarylist
 from osc.core import get_commitlog
 from osc.core import get_dependson
@@ -30,10 +31,12 @@
 from osc.util.helper import decode_it
 from osclib.conf import Config
 from osclib.memoize import memoize
+import subprocess
 
 BINARY_REGEX = 
r'(?:.*::)?(?P<filename>(?P<name>.*)-(?P<version>[^-]+)-(?P<release>[^-]+)\.(?P<arch>[^-\.]+))'
 RPM_REGEX = BINARY_REGEX + r'\.rpm'
 BinaryParsed = namedtuple('BinaryParsed', ('package', 'filename', 'name', 
'arch'))
+REQUEST_STATES_MINUS_ACCEPTED = ['new', 'review', 'declined', 'revoked', 
'superseded']
 
 @memoize(session=True)
 def group_members(apiurl, group, maintainers=False):
@@ -272,10 +275,7 @@
         return None
 
 def source_file_save(apiurl, project, package, filename, content, 
comment=None):
-    if not comment:
-        comment = 'update by OSRT tools'
-    comment += ' (host {})'.format(socket.gethostname())
-
+    comment = message_suffix('updated', comment)
     url = makeurl(apiurl, ['source', project, package, filename], {'comment': 
comment})
     http_PUT(url, data=content)
 
@@ -920,3 +920,67 @@
         types.append('submit')
 
     yield from request_action_list(apiurl, project, package, states, types)
+
+def request_create_submit(apiurl, source_project, source_package,
+                          target_project, target_package=None, message=None, 
revision=None):
+    if not target_package:
+        target_package = source_package
+
+    source_hash = package_source_hash(apiurl, target_project, target_package)
+    source_hash_consider = package_source_hash(apiurl, source_project, 
source_package, revision)
+    if source_hash_consider == source_hash:
+        # No sense submitting identical sources.
+        return False
+
+    for request, action in request_action_single_list(
+        apiurl, target_project, target_package, REQUEST_STATES_MINUS_ACCEPTED, 
'submit'):
+        source_hash_pending = package_source_hash(
+            apiurl, action.src_project, action.src_package, action.src_rev)
+        if source_hash_pending == source_hash_consider:
+            # Pending request with identical sources.
+            return False
+
+    message = message_suffix('created', message)
+
+    def create_function():
+        return create_submit_request(apiurl, source_project, source_package,
+                                     target_project, target_package,
+                                     message=message, orev=revision)
+
+    return RequestFuture('submit {}/{} -> {}/{}'.format(
+        source_project, source_package, target_project, target_package), 
create_function)
+
+def request_create_delete(apiurl, target_project, target_package, 
message=None):
+    for request, action in request_action_single_list(
+        apiurl, target_project, target_package, REQUEST_STATES_MINUS_ACCEPTED, 
'delete'):
+        return False
+
+    # No proper API function to perform the same operation.
+    message = message_suffix('created', message)
+
+    def create_function():
+        subprocess.check_call(
+            ' '.join(['osc', 'dr', '-m', message, target_project, 
target_package]), shell=True)
+
+        # Would be nicer to return newly create request ID, but not worth 
rewriting.
+        return True
+
+    return RequestFuture('delete {}/{}'.format(target_project, 
target_package), create_function)
+
+class RequestFuture:
+    def __init__(self, description, create_function):
+        self.description = description
+        self.create_function = create_function
+
+    def create(self):
+        return self.create_function()
+
+    def __str__(self):
+        return self.description
+
+def message_suffix(action, message=None):
+    if not message:
+        message = '{} by OSRT tools'.format(action)
+
+    message += ' (host {})'.format(socket.gethostname())
+    return message
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/openSUSE-release-tools-20190806.914d1061/osclib/origin.py 
new/openSUSE-release-tools-20190808.410ee514/osclib/origin.py
--- old/openSUSE-release-tools-20190806.914d1061/osclib/origin.py       
2019-08-06 14:39:54.000000000 +0200
+++ new/openSUSE-release-tools-20190808.410ee514/osclib/origin.py       
2019-08-08 22:22:04.000000000 +0200
@@ -12,6 +12,8 @@
 from osclib.core import project_remote_apiurl
 from osclib.core import request_action_key
 from osclib.core import request_action_list_source
+from osclib.core import request_create_delete
+from osclib.core import request_create_submit
 from osclib.core import request_remote_identifier
 from osclib.core import review_find_last
 from osclib.core import reviews_remaining
@@ -540,6 +542,16 @@
     # To simplify usage which is left-right (oldest-newest) place oldest first.
     return list(reversed(revisions))
 
+def origin_potential(apiurl, target_project, package):
+    config = config_load(apiurl, target_project)
+    for origin, _ in config_origin_generator(config['origins'], apiurl, 
target_project, package, True):
+        version = package_version(apiurl, origin, package)
+        if version is not False:
+            # Package exists in origin, but may still have unknown version.
+            return origin, version
+
+    return None, None
+
 def origin_potentials(apiurl, target_project, package):
     potentials = {}
 
@@ -568,3 +580,49 @@
         })
 
     return history
+
+def origin_update(apiurl, target_project, package):
+    origin_info = origin_find(apiurl, target_project, package)
+    if not origin_info:
+        origin, version = origin_potential(apiurl, target_project, package)
+        if origin is None:
+            # Package is not found in any origin so request deletion.
+            message = 'Package not available from any potential origin.'
+            return request_create_delete(apiurl, target_project, package, 
message)
+
+        message = 'Submitting package from highest potential origin.'
+        return request_create_submit(apiurl, origin, package, target_project, 
message=message)
+
+    if origin_workaround_check(origin_info.project):
+        # Do not attempt to update workarounds as the expected flow is to 
either
+        # to explicitely switched back to non-workaround or source to match at
+        # some point and implicitily switch.
+        return False
+
+    if origin_info.pending:
+        # Already accepted source ahead of origin so nothing to do.
+        return False
+
+    policy = policy_get(apiurl, target_project, package, origin_info.project)
+    if not policy['automatic_updates']:
+        return False
+
+    if policy['pending_submission_allow']:
+        request_id = origin_update_pending(apiurl, origin_info.project, 
package, target_project)
+        if request_id:
+            return request_id
+
+    message = 'Newer source available from package origin.'
+    return request_create_submit(apiurl, origin_info.project, package, 
target_project, message=message)
+
+def origin_update_pending(apiurl, origin_project, package, target_project):
+    apiurl_remote, project_remote = project_remote_apiurl(apiurl, 
origin_project)
+    request_actions = request_action_list_source(
+        apiurl_remote, project_remote, package, include_release=True)
+    for request, action in sorted(request_actions, key=lambda i: i[0].reqid, 
reverse=True):
+        identifier = request_remote_identifier(apiurl, apiurl_remote, 
request.reqid)
+        message = 'Newer pending source available from package origin. See 
{}.'.format(identifier)
+        return request_create_submit(apiurl, action.src_project, 
action.src_package,
+                                     target_project, package, message=message, 
revision=action.src_rev)
+
+    return False

++++++ openSUSE-release-tools.obsinfo ++++++
--- /var/tmp/diff_new_pack.LM6Kv0/_old  2019-08-09 16:54:25.561453715 +0200
+++ /var/tmp/diff_new_pack.LM6Kv0/_new  2019-08-09 16:54:25.561453715 +0200
@@ -1,5 +1,5 @@
 name: openSUSE-release-tools
-version: 20190806.914d1061
-mtime: 1565095194
-commit: 914d106184f64f4c1ff2e58bdb2bdf733c79fc76
+version: 20190808.410ee514
+mtime: 1565295724
+commit: 410ee5140a8e02990865f2f3ec73577ef706349b
 


Reply via email to