def list_for_user(p4, user): '''build list of repos visible to user''' result = RepoList() for view in p4gf_util.view_list(p4): #check user permissions for view # PERM_PUSH will avoid checking the repo config file for read-permission-check = user view_perm = p4gf_group.ViewPerm.for_user_and_view( p4, user, view, p4gf_group.PERM_PUSH) #sys.stderr.write("view: {}, user: {}, perm: {}".format(view, user, view_perm)) if view_perm.can_push(): perm = NTR('push') elif view_perm.can_pull(): perm = NTR('pull') else: continue config = p4gf_config.get_repo(p4, view) charset = config.get(p4gf_config.SECTION_REPO, p4gf_config.KEY_CHARSET, fallback='') desc = config.get(p4gf_config.SECTION_REPO, p4gf_config.KEY_DESCRIPTION, fallback='') result.repos.append((view, perm, charset, desc)) result.repos.sort(key=lambda tup: tup[0]) return result
def delete_clients(args, p4, metrics): """Delete all of the Git Fusion clients, except the object cache clients. """ views = p4gf_util.view_list(p4) if not views: print(_('No Git Fusion clients found.')) return for view in views: client = p4gf_util.view_to_client_name(view) try: delete_client(args, p4, client, metrics, False) except P4.P4Exception as e: sys.stderr.write(str(e) + '\n') sys.exit(1)
def list_for_user(p4, user): '''build list of repos visible to user''' result = RepoList() for view in p4gf_util.view_list(p4): #check user permissions for view view_perm = p4gf_group.ViewPerm.for_user_and_view(p4, user, view) #sys.stderr.write("view: {}, user: {}, perm: {}".format(view, user, view_perm)) if view_perm.can_push(): result.repos.append((view, 'push')) elif view_perm.can_pull(): result.repos.append((view, 'pull')) result.repos.sort(key=lambda tup: tup[0]) return result
def _list_for_server(): ''' Return list of repos that have been copied to the given Git Fusion server. "have been copied" here means "has a .git-fusion/views/<view_name>/ directory on this server." ''' p4 = p4gf_create_p4.create_p4(client=p4gf_util.get_object_client_name()) result = [] p4gf_dir = p4gf_util.p4_to_p4gf_dir(p4) for view_name in p4gf_util.view_list(p4): view_dirs = p4gf_view_dirs.from_p4gf_dir(p4gf_dir, view_name) if os.path.exists(view_dirs.GIT_DIR): result.append(view_name) p4gf_create_p4.destroy(p4) return result
def _lock_all_repos(p4): """ Quickly acquire locks on all Git Fusion repositories, failing immediately (raises RuntimeError) if any repos are currently locked. Waiting would only increase the chance of getting blocked on another repo, so scan and fail fast instead. Returns a list of the CounterLock instances acquired. """ locks = [] views = p4gf_util.view_list(p4) if not views: print(_('No Git Fusion clients found.')) else: for view in views: lock = p4gf_lock.view_lock(p4, view) lock.acquire(-1) # If that didn't raise an error, then add to the list of locks acquired. locks.append(lock) return locks