mirror of
				https://github.com/openSUSE/osc.git
				synced 2025-10-31 11:32:16 +01:00 
			
		
		
		
	- added optional apiurl parameter to the following methods:
meta_exists, make_meta_url, checkRevision if no apiurl parameter is specified the global value (conf.config['apiurl']) will be used. This should fix bug #361764 - some small apiurl fixes in the make_diff method (the package_tracking branch already has this fix)
This commit is contained in:
		| @@ -942,7 +942,7 @@ class Osc(cmdln.Cmdln): | |||||||
|  |  | ||||||
|         if opts.revision and ( len(args) == 1): |         if opts.revision and ( len(args) == 1): | ||||||
|             rev, dummy = parseRevisionOption(opts.revision) |             rev, dummy = parseRevisionOption(opts.revision) | ||||||
|             if not checkRevision(pacs[0].prjname, pacs[0].name, rev): |             if not checkRevision(pacs[0].prjname, pacs[0].name, rev, pacs[0].apiurl): | ||||||
|                 print >>sys.stderr, 'Revision \'%s\' does not exist' % rev |                 print >>sys.stderr, 'Revision \'%s\' does not exist' % rev | ||||||
|                 sys.exit(1) |                 sys.exit(1) | ||||||
|         else: |         else: | ||||||
| @@ -1461,7 +1461,7 @@ class Osc(cmdln.Cmdln): | |||||||
|         project = store_read_project(wd) |         project = store_read_project(wd) | ||||||
|         apiurl = store_read_apiurl(wd) |         apiurl = store_read_apiurl(wd) | ||||||
|         rev, dummy = parseRevisionOption(opts.revision) |         rev, dummy = parseRevisionOption(opts.revision) | ||||||
|         if rev and not checkRevision(project, package, rev): |         if rev and not checkRevision(project, package, rev, apiurl): | ||||||
|             print >>sys.stderr, 'Revision \'%s\' does not exist' % rev |             print >>sys.stderr, 'Revision \'%s\' does not exist' % rev | ||||||
|             sys.exit(1) |             sys.exit(1) | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								osc/core.py
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								osc/core.py
									
									
									
									
									
								
							| @@ -1043,10 +1043,13 @@ metatypes = { 'prj':     { 'path': 'source/%s/_meta', | |||||||
| def meta_exists(metatype, | def meta_exists(metatype, | ||||||
|                 path_args=None, |                 path_args=None, | ||||||
|                 template_args=None, |                 template_args=None, | ||||||
|                 create_new=True): |                 create_new=True, | ||||||
|  |                 apiurl=None): | ||||||
|  |  | ||||||
|     data = None |     data = None | ||||||
|     url = make_meta_url(metatype, path_args) |     if not apiurl: | ||||||
|  |         apiurl = conf.config['apiurl'] | ||||||
|  |     url = make_meta_url(metatype, path_args, apiurl) | ||||||
|     try: |     try: | ||||||
|         data = http_GET(url).readlines() |         data = http_GET(url).readlines() | ||||||
|     except urllib2.HTTPError, e: |     except urllib2.HTTPError, e: | ||||||
| @@ -1060,7 +1063,9 @@ def meta_exists(metatype, | |||||||
|                                 % (metatype, url) |                                 % (metatype, url) | ||||||
|     return data |     return data | ||||||
|  |  | ||||||
| def make_meta_url(metatype, path_args=None): | def make_meta_url(metatype, path_args=None, apiurl=None): | ||||||
|  |     if not apiurl: | ||||||
|  |         apiurl = conf.config['apiurl'] | ||||||
|     if metatype not in metatypes.keys(): |     if metatype not in metatypes.keys(): | ||||||
|         sys.exit('unknown metatype %s' % metatype) |         sys.exit('unknown metatype %s' % metatype) | ||||||
|     path = metatypes[metatype]['path'] |     path = metatypes[metatype]['path'] | ||||||
| @@ -1068,7 +1073,7 @@ def make_meta_url(metatype, path_args=None): | |||||||
|     if path_args: |     if path_args: | ||||||
|         path = path % path_args |         path = path % path_args | ||||||
|  |  | ||||||
|     return makeurl(conf.config['apiurl'], [path]) |     return makeurl(apiurl, [path]) | ||||||
|  |  | ||||||
|  |  | ||||||
| def edit_meta(metatype,  | def edit_meta(metatype,  | ||||||
| @@ -1381,7 +1386,7 @@ def make_diff(wc, revision): | |||||||
|         olddir = os.getcwd() |         olddir = os.getcwd() | ||||||
|         tmpdir  = tempfile.mkdtemp(revision, wc.name, '/tmp') |         tmpdir  = tempfile.mkdtemp(revision, wc.name, '/tmp') | ||||||
|         os.chdir(tmpdir) |         os.chdir(tmpdir) | ||||||
|         init_package_dir(conf.config['apiurl'], wc.prjname, wc.name, tmpdir, revision) |         init_package_dir(wc.apiurl, wc.prjname, wc.name, tmpdir, revision) | ||||||
|         cmp_pac = Package(tmpdir) |         cmp_pac = Package(tmpdir) | ||||||
|         if wc.todo: |         if wc.todo: | ||||||
|             for file in wc.todo: |             for file in wc.todo: | ||||||
| @@ -1434,7 +1439,7 @@ def make_diff(wc, revision): | |||||||
|         olddir = os.getcwd() |         olddir = os.getcwd() | ||||||
|         tmpdir  = tempfile.mkdtemp(dir='/tmp') |         tmpdir  = tempfile.mkdtemp(dir='/tmp') | ||||||
|         os.chdir(tmpdir) |         os.chdir(tmpdir) | ||||||
|         init_package_dir(conf.config['apiurl'], wc.prjname, wc.name, tmpdir, wc.rev) |         init_package_dir(wc.apiurl, wc.prjname, wc.name, tmpdir, wc.rev) | ||||||
|         tmp_pac = Package(tmpdir) |         tmp_pac = Package(tmpdir) | ||||||
|         os.chdir(olddir) |         os.chdir(olddir) | ||||||
|  |  | ||||||
| @@ -1497,7 +1502,7 @@ def checkout_package(apiurl, project, package, revision=None): | |||||||
|     olddir = os.getcwd() |     olddir = os.getcwd() | ||||||
|  |  | ||||||
|     path = (quote_plus(project), quote_plus(package)) |     path = (quote_plus(project), quote_plus(package)) | ||||||
|     if meta_exists(metatype='pkg', path_args=path, create_new=False) == None: |     if meta_exists(metatype='pkg', path_args=path, create_new=False, apiurl=apiurl) == None: | ||||||
|         print >>sys.stderr, 'error 404 - package or package does not exist' |         print >>sys.stderr, 'error 404 - package or package does not exist' | ||||||
|         sys.exit(1) |         sys.exit(1) | ||||||
|   |   | ||||||
| @@ -2071,12 +2076,14 @@ def parseRevisionOption(string): | |||||||
|     else: |     else: | ||||||
|         return None, None |         return None, None | ||||||
|  |  | ||||||
| def checkRevision(prj, pac, revision): | def checkRevision(prj, pac, revision, apiurl=None): | ||||||
|     """ |     """ | ||||||
|     check if revision is valid revision |     check if revision is valid revision | ||||||
|     """ |     """ | ||||||
|  |     if not apiurl: | ||||||
|  |         apiurl = conf.config['apiurl'] | ||||||
|     try: |     try: | ||||||
|         if int(revision) > int(show_upstream_rev(conf.config['apiurl'], prj, pac)) \ |         if int(revision) > int(show_upstream_rev(apiurl, prj, pac)) \ | ||||||
|            or int(revision) <= 0: |            or int(revision) <= 0: | ||||||
|             return False |             return False | ||||||
|         else: |         else: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user