2006-04-20 16:26:50 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
# Copyright (C) 2006 Peter Poeml. All rights reserved.
|
|
|
|
# This program is free software; it may be used, copied, modified
|
|
|
|
# and distributed under the terms of the GNU General Public Licence,
|
|
|
|
# either version 2, or (at your option) any later version.
|
|
|
|
|
2006-05-10 16:34:59 +02:00
|
|
|
from core import *
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
cmd = sys.argv[1]
|
|
|
|
project = package = filename = None
|
|
|
|
# try:
|
|
|
|
# project = sys.argv[2]
|
|
|
|
# package = sys.argv[3]
|
|
|
|
# filename = sys.argv[4]
|
|
|
|
# except:
|
|
|
|
# pass
|
|
|
|
|
|
|
|
if cmd == 'init':
|
|
|
|
project = sys.argv[2]
|
|
|
|
package = sys.argv[3]
|
|
|
|
init_package_dir(project, package, os.path.curdir)
|
|
|
|
print 'Initializing %s (Project: %s, Package: %s)' % (os.curdir, project, package)
|
|
|
|
|
|
|
|
elif cmd == 'ls':
|
|
|
|
if len(sys.argv) == 2:
|
|
|
|
print '\n'.join(get_slash_source())
|
|
|
|
if len(sys.argv) == 3:
|
|
|
|
project = sys.argv[2]
|
|
|
|
print '\n'.join(meta_get_packagelist(project))
|
|
|
|
if len(sys.argv) == 4:
|
|
|
|
project = sys.argv[2]
|
|
|
|
package = sys.argv[3]
|
|
|
|
print '\n'.join(meta_get_filelist(project, package))
|
|
|
|
|
|
|
|
elif cmd == 'meta':
|
|
|
|
if len(sys.argv) == 4:
|
|
|
|
project = sys.argv[2]
|
|
|
|
package = sys.argv[3]
|
|
|
|
print ''.join(show_package_meta(project, package))
|
2006-04-28 17:37:25 +02:00
|
|
|
print ''.join(show_files_meta(project, package))
|
2006-04-20 16:26:50 +02:00
|
|
|
elif len(sys.argv) == 3:
|
|
|
|
project = sys.argv[2]
|
|
|
|
print ''.join(show_project_meta(project))
|
|
|
|
|
|
|
|
elif cmd == 'diff':
|
2006-05-19 22:13:29 +02:00
|
|
|
args = parseargs()
|
|
|
|
pacs = findpacs(args)
|
|
|
|
|
|
|
|
for p in pacs:
|
|
|
|
if p.todo == []:
|
|
|
|
for i in p.filenamelist:
|
2006-05-22 16:12:06 +02:00
|
|
|
s = p.status(i)
|
|
|
|
if s == 'M' or s == 'C':
|
2006-05-19 22:13:29 +02:00
|
|
|
p.todo.append(i)
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
d = []
|
2006-05-19 22:13:29 +02:00
|
|
|
for filename in p.todo:
|
|
|
|
d.append('Index: %s\n' % filename)
|
|
|
|
d.append('===================================================================\n')
|
|
|
|
d.append(get_source_file_diff(p.dir, filename, p.rev))
|
|
|
|
if d:
|
|
|
|
print ''.join(d)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-05-11 09:27:50 +02:00
|
|
|
elif cmd == 'co' or cmd == 'checkout':
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
project = sys.argv[2]
|
|
|
|
package = sys.argv[3]
|
|
|
|
filename = sys.argv[4]
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
if filename:
|
|
|
|
get_source_file(project, package, filename)
|
|
|
|
|
|
|
|
elif package:
|
|
|
|
checkout_package(project, package)
|
|
|
|
|
|
|
|
else:
|
|
|
|
# all packages
|
|
|
|
for package in meta_get_packagelist(project):
|
|
|
|
checkout_package(project, package)
|
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'st' or cmd == 'status':
|
|
|
|
|
2006-05-11 09:27:50 +02:00
|
|
|
args = parseargs()
|
2006-05-19 22:13:29 +02:00
|
|
|
pacs = findpacs(args)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for p in pacs:
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
# no files given as argument? Take all files in current dir
|
|
|
|
if not p.todo:
|
|
|
|
p.todo = p.filenamelist + p.filenamelist_unvers
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for filename in p.todo:
|
|
|
|
s = p.status(filename)
|
|
|
|
if s == 'F':
|
|
|
|
print statfrmt('!', filename)
|
|
|
|
elif s != ' ':
|
|
|
|
print statfrmt(s, filename)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'add':
|
2006-05-11 09:27:50 +02:00
|
|
|
if len(sys.argv) < 3:
|
|
|
|
print '%s requires at least one argument' % cmd
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
filenames = parseargs()
|
|
|
|
|
2006-04-27 15:35:43 +02:00
|
|
|
for filename in filenames:
|
|
|
|
if not os.path.exists(filename):
|
|
|
|
print "file '%s' does not exist" % filename
|
|
|
|
sys.exit(1)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
pacs = findpacs(filenames)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for pac in pacs:
|
|
|
|
for filename in pac.todo:
|
|
|
|
if filename in exclude_stuff:
|
|
|
|
continue
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
pac.addfile(filename)
|
|
|
|
print statfrmt('A', filename)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
elif cmd == 'addremove':
|
|
|
|
args = parseargs()
|
|
|
|
pacs = findpacs(args)
|
|
|
|
for p in pacs:
|
2006-04-24 14:04:20 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
p.todo = p.filenamelist + p.filenamelist_unvers
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for filename in p.todo:
|
|
|
|
if filename in exclude_stuff:
|
|
|
|
continue
|
|
|
|
state = p.status(filename)
|
|
|
|
if state == '?':
|
|
|
|
p.addfile(filename)
|
|
|
|
print statfrmt('A', filename)
|
|
|
|
elif state == '!':
|
|
|
|
p.put_on_deletelist(filename)
|
|
|
|
p.write_deletelist()
|
|
|
|
os.unlink(os.path.join(p.storedir, filename))
|
|
|
|
print statfrmt('D', filename)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
elif cmd == 'ci' or cmd == 'checkin':
|
|
|
|
init_basicauth()
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
args = parseargs()
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
pacs = findpacs(args)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for p in pacs:
|
|
|
|
p.todo = p.filenamelist_unvers + p.filenamelist
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for filename in p.todo:
|
|
|
|
st = p.status(filename)
|
|
|
|
if st == 'A' or st == 'M':
|
|
|
|
p.todo_send.append(filename)
|
2006-04-20 16:26:50 +02:00
|
|
|
print 'Sending %s' % filename
|
2006-05-19 22:13:29 +02:00
|
|
|
elif st == 'D':
|
|
|
|
p.todo_delete.append(filename)
|
2006-04-20 16:26:50 +02:00
|
|
|
print 'Deleting %s' % filename
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
if not p.todo_send and not p.todo_delete:
|
|
|
|
print 'nothing to do for package %s' % p.name
|
|
|
|
continue
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
print 'Transmitting file data ',
|
2006-05-19 22:13:29 +02:00
|
|
|
for filename in p.todo_send:
|
|
|
|
put_source_file(p.prjname, p.name, os.path.join(p.dir, filename))
|
|
|
|
#copy_file(filename, os.path.join(store, filename))
|
|
|
|
for filename in p.todo_delete:
|
|
|
|
del_source_file(p.prjname, p.name, filename)
|
|
|
|
p.to_be_deleted.remove(filename)
|
|
|
|
|
|
|
|
p.update_filesmeta()
|
|
|
|
p.write_deletelist()
|
2006-04-20 16:26:50 +02:00
|
|
|
print
|
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'up' or cmd == 'update':
|
|
|
|
|
2006-05-11 09:27:50 +02:00
|
|
|
args = parseargs()
|
2006-05-22 12:50:37 +02:00
|
|
|
|
|
|
|
for arg in args:
|
|
|
|
|
|
|
|
# when 'update' is run inside a project dir, it should...
|
|
|
|
if is_project_dir(arg):
|
|
|
|
|
|
|
|
prj = Project(arg)
|
|
|
|
|
|
|
|
# (a) update all packages
|
|
|
|
for i in prj.pacs_have:
|
|
|
|
args.append(i)
|
|
|
|
|
|
|
|
# (b) fetch new packages
|
|
|
|
prj.checkout_missing_pacs()
|
|
|
|
args.remove(arg)
|
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
pacs = findpacs(args)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for p in pacs:
|
2006-04-28 17:37:25 +02:00
|
|
|
|
2006-05-22 16:12:06 +02:00
|
|
|
# save filelist and (modified) status before replacing the meta file
|
2006-05-19 22:13:29 +02:00
|
|
|
saved_filenames = p.filenamelist
|
2006-05-22 16:12:06 +02:00
|
|
|
saved_modifiedfiles = []
|
|
|
|
for i in p.filenamelist:
|
|
|
|
if p.status(i) == 'M':
|
|
|
|
saved_modifiedfiles.append(i)
|
2006-05-19 22:13:29 +02:00
|
|
|
p.update_filesmeta()
|
|
|
|
p = Package(p.dir)
|
2006-04-28 17:37:25 +02:00
|
|
|
|
|
|
|
# which files do no longer exist upstream?
|
|
|
|
disappeared = []
|
2006-05-19 22:13:29 +02:00
|
|
|
for filename in saved_filenames:
|
|
|
|
if filename not in p.filenamelist:
|
2006-04-28 17:37:25 +02:00
|
|
|
disappeared.append(filename)
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for filename in saved_filenames:
|
2006-04-28 17:37:25 +02:00
|
|
|
if filename in disappeared:
|
2006-05-19 22:13:29 +02:00
|
|
|
print statfrmt('D', filename)
|
|
|
|
p.delfile(filename)
|
2006-04-28 17:37:25 +02:00
|
|
|
continue
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for filename in p.filenamelist:
|
|
|
|
|
|
|
|
state = p.status(filename)
|
2006-05-22 16:12:06 +02:00
|
|
|
if state == 'M' and filename in saved_modifiedfiles:
|
|
|
|
print 'merging'
|
|
|
|
status_after_merge = p.mergefile(filename)
|
|
|
|
print statfrmt(status_after_merge, filename)
|
|
|
|
elif state == 'M':
|
2006-05-19 22:13:29 +02:00
|
|
|
p.updatefile(filename)
|
2006-05-23 11:59:22 +02:00
|
|
|
print statfrmt('U', filename)
|
2006-05-19 22:13:29 +02:00
|
|
|
elif state == '!':
|
|
|
|
p.updatefile(filename)
|
|
|
|
print 'Restored \'%s\'' % filename
|
|
|
|
elif state == 'F':
|
|
|
|
p.updatefile(filename)
|
|
|
|
print statfrmt('A', filename)
|
|
|
|
elif state == ' ':
|
2006-04-20 16:26:50 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
p.update_pacmeta()
|
|
|
|
|
2006-05-22 16:12:06 +02:00
|
|
|
#print ljust(p.name, 45), 'At revision %s.' % p.rev
|
|
|
|
print 'At revision %s.' % p.rev
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'rm' or cmd == 'delete':
|
2006-05-11 09:27:50 +02:00
|
|
|
if len(sys.argv) < 3:
|
2006-04-20 16:26:50 +02:00
|
|
|
print '%s requires at least one argument' % cmd
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-05-11 09:27:50 +02:00
|
|
|
args = parseargs()
|
2006-05-19 22:13:29 +02:00
|
|
|
pacs = findpacs(args)
|
2006-05-11 09:27:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for p in pacs:
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
for filename in p.todo:
|
|
|
|
p.put_on_deletelist(filename)
|
|
|
|
p.write_deletelist()
|
|
|
|
try:
|
|
|
|
os.unlink(os.path.join(p.dir, filename))
|
|
|
|
os.unlink(os.path.join(p.storedir, filename))
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
print statfrmt('D', filename)
|
2006-04-25 14:25:53 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-22 16:12:06 +02:00
|
|
|
elif cmd == 'resolved':
|
|
|
|
if len(sys.argv) < 3:
|
|
|
|
print '%s requires at least one argument' % cmd
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
args = parseargs()
|
|
|
|
pacs = findpacs(args)
|
|
|
|
|
|
|
|
for p in pacs:
|
|
|
|
|
|
|
|
for filename in p.todo:
|
|
|
|
print "Resolved conflicted state of '%s'" % filename
|
|
|
|
p.clear_from_conflictlist(filename)
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
elif cmd == 'id':
|
2006-05-22 16:57:11 +02:00
|
|
|
r = get_user_id(sys.argv[2])
|
|
|
|
if r:
|
|
|
|
print ''.join(r)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
elif cmd == 'platforms':
|
2006-05-02 10:17:45 +02:00
|
|
|
if len(sys.argv) > 2:
|
|
|
|
project = sys.argv[2]
|
2006-04-20 16:26:50 +02:00
|
|
|
print '\n'.join(get_platforms_of_project(project))
|
|
|
|
else:
|
|
|
|
print '\n'.join(get_platforms())
|
|
|
|
|
|
|
|
|
2006-04-29 22:44:09 +02:00
|
|
|
elif cmd == 'results_meta':
|
2006-04-25 18:19:42 +02:00
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
if len(sys.argv) > 2:
|
|
|
|
platform = sys.argv[2]
|
2006-04-29 22:44:09 +02:00
|
|
|
print ''.join(show_results_meta(project, package, platform))
|
2006-04-20 16:26:50 +02:00
|
|
|
else:
|
|
|
|
for platform in get_platforms_of_project(project):
|
2006-04-29 22:44:09 +02:00
|
|
|
print ''.join(show_results_meta(project, package, platform))
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-04-29 22:44:09 +02:00
|
|
|
|
|
|
|
elif cmd == 'results':
|
|
|
|
if len(sys.argv) > 3:
|
|
|
|
print 'getting results for more than one package is not supported'
|
|
|
|
print sys.exit(1)
|
|
|
|
|
|
|
|
if len(sys.argv) == 3:
|
|
|
|
wd = sys.argv[2]
|
|
|
|
else:
|
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
|
|
|
|
for platform in get_platforms_of_project(project):
|
2006-05-02 10:17:45 +02:00
|
|
|
print '\n'.join(get_results(project, package, platform))
|
2006-04-29 22:44:09 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
elif cmd == 'log':
|
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
|
|
|
|
platform = sys.argv[2]
|
|
|
|
arch = sys.argv[3]
|
|
|
|
print ''.join(get_log(project, package, platform, arch))
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
elif cmd == 'hist' or cmd == 'history':
|
|
|
|
args = parseargs()
|
|
|
|
pacs = findpacs(args)
|
|
|
|
|
|
|
|
for p in pacs:
|
|
|
|
print ''.join(get_history(p.prjname, p.name))
|
|
|
|
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
else:
|
|
|
|
print "unknown command '%s'" % cmd
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
init_basicauth()
|
|
|
|
main()
|
|
|
|
|