diff --git a/osc/commandline.py b/osc/commandline.py index e02e43c0..f7031eb3 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -708,6 +708,8 @@ class Osc(cmdln.Cmdln): @cmdln.alias('ci') @cmdln.alias('checkin') + @cmdln.option('-m', '--message', metavar='TEXT', + help='specify log message TEXT') def do_commit(self, subcmd, opts, *args): """${cmd_name}: Upload content to the repository server @@ -759,8 +761,9 @@ class Osc(cmdln.Cmdln): for filename in p.todo_delete: p.delete_source_file(filename) p.to_be_deleted.remove(filename) - if conf.config['do_commits'] == '1': - p.commit(msg='MESSAGE') + if conf.config['do_commits']: + print '[committing]' + p.commit(msg=opts.message) p.update_filesmeta() p.write_deletelist() @@ -1048,7 +1051,8 @@ class Osc(cmdln.Cmdln): print '\n'.join(get_prj_results(apiurl, project, show_legend=opts.legend)) - def do_log(self, subcmd, opts, platform, arch): + @cmdln.alias('bl') + def do_buildlog(self, subcmd, opts, platform, arch): """${cmd_name}: Shows the build log of a package Shows the log file of the build of a package. Can be used to follow the @@ -1306,6 +1310,21 @@ class Osc(cmdln.Cmdln): print '\n'.join(get_buildhistory(apiurl, project, package, platform, arch)) + def do_log(self, subcmd, opts): + """${cmd_name}: Shows the commit log of a package + + ${cmd_usage} + ${cmd_option_list} + """ + + wd = os.curdir + package = store_read_package(wd) + project = store_read_project(wd) + apiurl = store_read_apiurl(wd) + + print '\n'.join(get_commitlog(apiurl, project, package)) + + @cmdln.option('-f', '--failed', action='store_true', help='rebuild all failed packages') def do_rebuildpac(self, subcmd, opts, *args): diff --git a/osc/core.py b/osc/core.py index bf3ff683..c33540ae 100755 --- a/osc/core.py +++ b/osc/core.py @@ -312,7 +312,7 @@ class Package: # escaping '+' in the URL path (note: not in the URL query string) is # only a workaround for ruby on rails, which swallows it otherwise query = [] - if conf.config['do_commits'] == '1': + if conf.config['do_commits']: query.append('rev=upload') u = makeurl(self.apiurl, ['source', self.prjname, self.name, pathname2url(n)], query=query) http_PUT(u, file = os.path.join(self.dir, n)) @@ -1501,6 +1501,37 @@ def get_buildhistory(apiurl, prj, package, platform, arch): return r +def get_commitlog(apiurl, prj, package): + import time + u = makeurl(apiurl, ['source', prj, package, '_history']) + f = http_GET(u) + root = ET.parse(f).getroot() + + r = [] + revisions = root.findall('revision') + revisions.reverse() + for node in revisions: + rev = int(node.get('rev')) + #vrev = int(node.get('vrev')) # what is the meaning of vrev? + srcmd5 = node.find('srcmd5').text + version = node.find('version').text + user = node.find('user').text + try: + comment = node.find('comment').text + except: + comment = '' + t = time.localtime(int(node.find('time').text)) + t = time.strftime('%Y-%m-%d %H:%M:%S', t) + + s = '-' * 76 + \ + '\nr%s | %s | %s | %s | %s\n' % (rev, user, t, srcmd5, version) + \ + '\n' + comment + r.append(s) + + r.append('-' * 76) + return r + + def rebuild(apiurl, prj, package, repo, arch, code=None): query = [] query.append('cmd=rebuild') @@ -1616,6 +1647,7 @@ def wipebinaries(apiurl, project, package=None, arch=None, repo=None, build_disa root = ET.parse(f).getroot() return root.get('code') + def parseRevisionOption(string): """ returns a tuple which contains the revisions