Skip to content

Commit

Permalink
- patchinfo call can work without checked out copy now
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Jan 9, 2012
1 parent bb373a9 commit 94a670e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
0.134
-
- patchinfo call can work without checked out copy now
#
# Features which requires OBS 2.3
#
Expand Down
51 changes: 28 additions & 23 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,46 +437,51 @@ def do_patchinfo(self, subcmd, opts, *args):
Examples:
osc patchinfo
osc patchinfo PATCH_NAME
osc patchinfo [PROJECT [PATCH_NAME]]
${cmd_option_list}
"""

apiurl = self.get_api_url()
project_dir = localdir = os.getcwd()
patchinfo = None
if is_project_dir(localdir):
project = store_read_project(localdir)
apiurl = self.get_api_url()
for p in meta_get_packagelist(apiurl, project):
if p.startswith("_patchinfo") or p.startswith("patchinfo"):
patchinfo = p
else:
if is_package_dir(localdir):
project = store_read_project(localdir)
patchinfo = store_read_package(localdir)
apiurl = self.get_api_url()
patchinfo = 'patchinfo'
if len(args) == 0:
if is_project_dir(localdir):
project = store_read_project(localdir)
apiurl = self.get_api_url()
for p in meta_get_packagelist(apiurl, project):
if p.startswith("_patchinfo") or p.startswith("patchinfo"):
patchinfo = p
else:
sys.exit('This command must be called in a checked out project or patchinfo package.')
if is_package_dir(localdir):
project = store_read_project(localdir)
patchinfo = store_read_package(localdir)
apiurl = self.get_api_url()
else:
sys.exit('This command must be called in a checked out project or patchinfo package.')
else:
project = args[0]
if len(args) > 1:
patchinfo = args[1]

filelist = None
if patchinfo:
filelist = meta_get_filelist(apiurl, project, patchinfo)
try:
filelist = meta_get_filelist(apiurl, project, patchinfo)
except urllib2.HTTPError:
pass

if opts.force or not patchinfo or not '_patchinfo' in filelist:
print "Creating initial patchinfo..."
query='cmd=createpatchinfo'
if opts.force or not filelist or not '_patchinfo' in filelist:
print "Creating new patchinfo..."
query='cmd=createpatchinfo&name=' + patchinfo
if opts.force:
query += "&force=1"
if args and args[0]:
query += "&name=" + args[0]
elif patchinfo:
query += "&name=" + patchinfo
url = makeurl(apiurl, ['source', project], query=query)
f = http_POST(url)
for p in meta_get_packagelist(apiurl, project):
if p.startswith("_patchinfo") or p.startswith("patchinfo"):
patchinfo = p
else:
print "Update _patchinfo file..."
print "Update existing _patchinfo file..."
query='cmd=updatepatchinfo'
url = makeurl(apiurl, ['source', project, patchinfo], query=query)
f = http_POST(url)
Expand Down

0 comments on commit 94a670e

Please sign in to comment.