<commit_before>#
# Copyright (c) 2004 Specifix, Inc.
# All rights reserved
#

import database
import log
import package
import sys

def listRollbacks(db, cfg):
    for rollbackName in db.getRollbackList():
	print "%s:" % rollbackName

	rb = db.getRollback(rollbackName)
	for cs in rb:
	    list = []
	    for pkg in cs.getNewPackageList():
		name = package.stripNamespace(cfg.packagenamespace, 
					    pkg.getName())
		list.append((name, pkg))

	    list.sort()
	    for (name, pkg) in list:
		if not pkg.getOldVersion():
		    print "\t%s %s removed" % (name,
			 pkg.getNewVersion().asString(cfg.defaultbranch))
		else:
		    print "\t%s %s -> %s" % \
			(name,
			 pkg.getOldVersion().asString(cfg.defaultbranch), 
			 pkg.getNewVersion().asString(cfg.defaultbranch))

	    list = []
	    for (pkg, version) in cs.getOldPackageList():
		name = package.stripNamespace(cfg.packagenamespace, pkg)
		list.append((name, version))

	    list.sort()
	    for (pkg, version) in list:
		print "\t%s %s added" %  \
				(package.stripNamespace(cfg.packagenamespace, 
							pkg), 
				 version.asString(cfg.defaultbranch))

	print

def apply(db, cfg, *names):
    try:
	db.applyRollbackList(names)
    except database.RollbackError, e:
	log.error("%s", e)
	sys.exit(1)<commit_msg>don't exist on error, just return an error code<commit_after>#
# Copyright (c) 2004 Specifix, Inc.
# All rights reserved
#

import database
import log
import package
import sys

def listRollbacks(db, cfg):
    for rollbackName in db.getRollbackList():
	print "%s:" % rollbackName

	rb = db.getRollback(rollbackName)
	for cs in rb:
	    list = []
	    for pkg in cs.getNewPackageList():
		name = package.stripNamespace(cfg.packagenamespace, 
					    pkg.getName())
		list.append((name, pkg))

	    list.sort()
	    for (name, pkg) in list:
		if not pkg.getOldVersion():
		    print "\t%s %s removed" % (name,
			 pkg.getNewVersion().asString(cfg.defaultbranch))
		else:
		    print "\t%s %s -> %s" % \
			(name,
			 pkg.getOldVersion().asString(cfg.defaultbranch), 
			 pkg.getNewVersion().asString(cfg.defaultbranch))

	    list = []
	    for (pkg, version) in cs.getOldPackageList():
		name = package.stripNamespace(cfg.packagenamespace, pkg)
		list.append((name, version))

	    list.sort()
	    for (pkg, version) in list:
		print "\t%s %s added" %  \
				(package.stripNamespace(cfg.packagenamespace, 
							pkg), 
				 version.asString(cfg.defaultbranch))

	print

def apply(db, cfg, *names):
    try:
	db.applyRollbackList(names)
    except database.RollbackError, e:
	log.error("%s", e)
	return 1

    return 0
{'fraction_non_alphanumeric': 0.13690705746239876, 'fraction_numerical': 0.004242190512919399, 'mean_word_length': 3.2805280528052805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2676094', 'n_tokens_mistral': 1009, 'n_tokens_neox': 871, 'n_words': 216}