def new_branch(branchname): catalog_branches = reposadocommon.getCatalogBranches() if branchname in catalog_branches: reposadocommon.print_stderr('Branch %s already exists!', branchname) abort(401) catalog_branches[branchname] = [] reposadocommon.writeCatalogBranches(catalog_branches) return jsonify(result='success')
def diff_branches(branch_list): '''Displays differences between two branches''' catalog_branches = reposadocommon.getCatalogBranches() for branch in branch_list: if branch not in catalog_branches: reposadocommon.print_stderr( 'ERROR: %s is not a valid branch name.' % branch) return branch1 = set(catalog_branches[branch_list[0]]) branch2 = set(catalog_branches[branch_list[1]]) unique_to_first = branch1 - branch2 if len(unique_to_first) == 0: print('No items to move.')
def delete_branch(branchname): catalog_branches = reposadocommon.getCatalogBranches() if not branchname in catalog_branches: reposadocommon.print_stderr("Branch %s does not exist!", branchname) return del catalog_branches[branchname] # this is not in the common library, so we have to duplicate code # from repoutil for catalog_URL in reposadocommon.pref("AppleCatalogURLs"): localcatalogpath = reposadocommon.getLocalPathNameFromURL(catalog_URL) # now strip the '.sucatalog' bit from the name if localcatalogpath.endswith(".sucatalog"): localcatalogpath = localcatalogpath[0:-10] branchcatalogpath = localcatalogpath + "_" + branchname + ".sucatalog" if os.path.exists(branchcatalogpath): reposadocommon.print_stdout("Removing %s", os.path.basename(branchcatalogpath)) os.remove(branchcatalogpath) reposadocommon.writeCatalogBranches(catalog_branches) return jsonify(result=True)
def delete_branch(branchname): catalog_branches = reposadocommon.getCatalogBranches() if not branchname in catalog_branches: reposadocommon.print_stderr('Branch %s does not exist!', branchname) return del catalog_branches[branchname] # this is not in the common library, so we have to duplicate code # from repoutil for catalog_URL in reposadocommon.pref('AppleCatalogURLs'): localcatalogpath = reposadocommon.getLocalPathNameFromURL(catalog_URL) # now strip the '.sucatalog' bit from the name if localcatalogpath.endswith('.sucatalog'): localcatalogpath = localcatalogpath[0:-10] branchcatalogpath = localcatalogpath + '_' + branchname + '.sucatalog' if os.path.exists(branchcatalogpath): reposadocommon.print_stdout( 'Removing %s', os.path.basename(branchcatalogpath)) os.remove(branchcatalogpath) reposadocommon.writeCatalogBranches(catalog_branches) return jsonify(result=True);