1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-13 17:16:23 +01:00

add rdiff subcommand, to allow server-side diffs between arbitrary packages

This commit is contained in:
Dr. Peter Poeml 2007-11-29 17:22:57 +00:00
parent d4bfd42bb4
commit 620bc2ea68
2 changed files with 49 additions and 0 deletions

View File

@ -599,6 +599,33 @@ class Osc(cmdln.Cmdln):
print diff
@cmdln.option('--oldprj', metavar='OLDPRJ',
help='project to diff against')
@cmdln.option('--oldpkg', metavar='OLDPKG',
help='package to diff against')
@cmdln.option('-r', '--revision', metavar='N[:M]',
help='revision id, where N = old revision and M = new revision')
def do_rdiff(self, subcmd, opts, new_project, new_package):
"""${cmd_name}: server-side "pretty" diff of two packages
Note that this command doesn't reply a normal diff which can be applied as patch.
${cmd_usage}
${cmd_option_list}
"""
old_revision = None
new_revision = None
if opts.revision:
old_revision, new_revision = parseRevisionOption(opts.revision)
rdiff = pretty_diff(conf.config['apiurl'],
opts.oldprj, opts.oldpkg, old_revision,
new_project, new_package, new_revision)
print rdiff
def do_repourls(self, subcmd, opts, *args):
"""${cmd_name}: shows URLs of .repo files

View File

@ -1440,6 +1440,28 @@ def make_diff(wc, revision):
delete_tmpdir(tmp_pac.absdir)
return diff
def pretty_diff(apiurl,
old_project, old_package, old_revision,
new_project, new_package, new_revision):
query = []
query.append('cmd=diff')
if old_project:
query.append('oproject=%s' % quote_plus(old_project))
if old_package:
query.append('opackage=%s' % quote_plus(old_package))
if old_revision:
query.append('orev=%s' % quote_plus(old_revision))
if new_revision:
query.append('rev=%s' % quote_plus(new_revision))
u = makeurl(apiurl, ['source', new_project, new_package], query=query)
f = http_POST(u)
return f.read()
def make_dir(apiurl, project, package):
#print "creating directory '%s'" % project
if not os.path.exists(project):