def status(): branch = git.current_branch() print "# On branch %s, tracking database %s" % (branch, database) tracked = [db[len(database):] for db in list_databases() if db.startswith(database)] tracked[tracked.index("")] = branch print "# Currently tracking local branches: %s" % tracked print "# Patches applied:" print "# %s" % list_applied_patches(branch, database) print "# Patches not applied:" print "# %s" % [patch for patch in list_file_patches(branch, database) if patch not in list_applied_patches(branch, database) and patch not in list_ignored_patches(branch, database)] print "# Patches ignored:" print "# %s" % list_ignored_patches(branch, database) print "# Patches stashed:" print "# %s" % list_stashed_patches(branch, database) last_commit = git.last_commit_time() if fast_check_sqlchanges(database, last_commit): with amalgamated_sql(branch, database) as amalgamated_sql_file: sql_difference = calculate_difference(amalgamated_sql_file, database, [filters.filter_auto_increment, lambda input: filters.filter_renames(input, database, git.last_commit_time())]) if sql_difference: print "# Untracked SQL code since last commit at '%s'." % (last_commit) else: print "# SQL database clean." else: print "# SQL database clean."
def handle_pull(branch, database): logging.info("New patches from pull:") if branch != "master": logging.warn("gitdb does not currently support remote tracking branches.") else: patches = [patch for patch in list_file_patches(branch, database) if patch not in list_applied_patches(branch, database) and patch not in list_ignored_patches(branch, database)] logging.info(patches) try: apply_patch(database, patches, True) for patch in patches: add_patch_to_db(branch, database, patch) except MySqlException: logging.error("Patches from pull failed to apply.") logging.error("Feel free to do whatever you like to the database to make it consistent. Then run git db merge.")
def ignore_patches(): # Mark certain patches as to be ignored / unignored. branch = git.current_branch() patches = dict([(i, patch) for i, patch in enumerate(list_file_patches(branch, database)) if patch not in list_applied_patches(branch, database) and patch not in list_ignored_patches(branch, database)]) if not patches: print "No patches to be ignored." return pprint(patches) try: input = raw_input("Please enter a space separated list of patch #s to ignore: ") if input != "": to_ignore = [int(i) for i in input.split(" ")] for ignored in to_ignore: add_ignored_to_db(git.current_branch(), database, patches[ignored]) except: print "Invalid input." return add_event_to_db(database, "ignored patches, %s: ", time.time())