def _calc_repairs(ctx): """ Scan Perforce for Git commit data and Perforce changelist descriptions, calculate which Perforce changelists need more data copied from Git backing store //.git-fusion/objects/... """ # Load repo's entire set of Commit/Changelist metadata # into memory. LOG.info("Fetching list of Git commits/changelists from %s/objects/...", p4gf_const.objects_root()) r = ctx.p4run( 'files', '{root}/repos/{repo}/commits/...'.format( root=p4gf_const.objects_root(), repo=ctx.config.repo_name)) # 'p4 print' each Git commit from its backup in # //.git-fusion/objects/... LOG.info("Fetched commit objects: {ct}".format(ct=len(r))) for rr in r: depot_path = rr.get('depotFile') if not depot_path: continue ot = ObjectType.commit_from_filepath(depot_path) SHA1_TO_OTL[ot.sha1].append(ot) LOG.debug('p4 print {}'.format(depot_path)) blob_raw = p4gf_util.print_depot_path_raw(ctx.p4, depot_path) blob = p4gf_util.bytes_to_git_object(blob_raw) par_list = commit_to_parent_list(blob) SHA1_TO_PAR_SHA1_LIST[ot.sha1] = par_list LOG.debug("{sha1:7.7} parents={par}".format( sha1=ot.sha1, par=[p4gf_util.abbrev(p) for p in par_list])) # Loop through changelists, comparing against # backup and calculating if additional data # needs to be copied to its changelist description. return _calc_repairs_loop(ctx)
def _find_commit_files(path, client_name): """Generator function that walks a directory tree, returning each commit file found for the given client. Arguments: path -- root of directory tree to walk. client_name -- name of client for which to find commits. """ for root, _dirs, files in os.walk(path): for fyle in files: fpath = os.path.join(root, fyle) # Convert the object file path to an ObjectType, but don't # let those silly non-P4GF objects stop us. ot = ObjectType.commit_from_filepath(fpath) if ot and ot.applies_to_view(client_name): yield fpath
def _find_commit_files(path, client_name): """Generator function that walks a directory tree, returning each commit file found for the given client. Arguments: path -- root of directory tree to walk. client_name -- name of client for which to find commits. """ for root, _dirs, files in os.walk(path): for fyle in files: fpath = os.path.join(root, fyle) # Convert the object file path to an ObjectType, but don't # let those silly non-P4GF objects stop us. ot = ObjectType.commit_from_filepath(fpath) if ot and ot.applies_to_view(client_name): yield fpath