def start(self): self.__branches_info = get_branches_info( include_tracking_status=self.verbosity >= 1) roots = set() # A map of parents to a list of their children. for branch, branch_info in self.__branches_info.iteritems(): if not branch_info: continue parent = branch_info.upstream if parent and not self.__branches_info[parent]: branch_upstream = upstream(branch) # If git can't find the upstream, mark the upstream as gone. if branch_upstream: parent = branch_upstream else: self.__gone_branches.add(parent) # A parent that isn't in the branches info is a root. roots.add(parent) self.__parent_map[parent].append(branch) self.__current_branch = current_branch() self.__current_hash = hash_one('HEAD', short=True) self.__tag_set = tags() if roots: for root in sorted(roots): self.__append_branch(root) else: no_branches = OutputLine() no_branches.append('No User Branches') self.output.append(no_branches)
def start(self): self.__branches_info = get_branches_info( include_tracking_status=self.verbosity >= 1) roots = set() # A map of parents to a list of their children. for branch, branch_info in self.__branches_info.iteritems(): if not branch_info: continue parent = branch_info.upstream if not self.__branches_info[parent]: branch_upstream = upstream(branch) # If git can't find the upstream, mark the upstream as gone. if branch_upstream: parent = branch_upstream else: self.__gone_branches.add(parent) # A parent that isn't in the branches info is a root. roots.add(parent) self.__parent_map[parent].append(branch) self.__current_branch = current_branch() self.__current_hash = hash_one('HEAD', short=True) self.__tag_set = tags() if roots: for root in sorted(roots): self.__append_branch(root) else: no_branches = OutputLine() no_branches.append('No User Branches') self.output.append(no_branches)
def main(): remote = git_common.run('remote') # Use first remote as source of truth remote = remote.split("\n")[0] if not remote: raise RuntimeError('Could not find any remote') url = scm.GIT.GetConfig(git_common.repo_root(), 'remote.%s.url' % remote) host = urllib.parse.urlparse(url).netloc if not host: raise RuntimeError('Could not find remote host') project_head = gerrit_util.GetProjectHead(GetGerritHost(host), GetGerritProject(url)) if project_head != 'refs/heads/main': raise RuntimeError("The repository is not migrated yet.") logging.info("Running fetch...") git_common.run('fetch', remote) logging.info("Updating remote HEAD...") git_common.run('remote', 'set-head', '-a', remote) branches = git_common.get_branches_info(True) if 'master' in branches: logging.info("Migrating master branch...") if 'main' in branches: logging.info( 'You already have master and main branch, consider removing ' 'master manually:\n' ' $ git branch -d master\n') else: git_common.run('branch', '-m', 'master', 'main') branches = git_common.get_branches_info(True) for name in branches: branch = branches[name] if not branch: continue if 'master' in branch.upstream: logging.info("Migrating %s branch..." % name) new_upstream = branch.upstream.replace('master', 'main') git_common.run('branch', '--set-upstream-to', new_upstream, name) git_common.remove_merge_base(name)
def start(self): self.__branches_info = get_branches_info( include_tracking_status=self.verbosity >= 1) if (self.verbosity >= 2): # Avoid heavy import unless necessary. from git_cl import get_cl_statuses, color_for_status, Changelist change_cls = [ Changelist(branchref='refs/heads/' + b) for b in self.__branches_info.keys() if b ] status_info = get_cl_statuses(change_cls, fine_grained=self.verbosity > 2, max_processes=self.maxjobs) # This is a blocking get which waits for the remote CL status to be # retrieved. for cl, status in status_info: self.__status_info[cl.GetBranch()] = (cl.GetIssueURL(), color_for_status(status), status) roots = set() # A map of parents to a list of their children. for branch, branch_info in self.__branches_info.items(): if not branch_info: continue parent = branch_info.upstream if self.__check_cycle(branch): continue if not self.__branches_info[parent]: branch_upstream = upstream(branch) # If git can't find the upstream, mark the upstream as gone. if branch_upstream: parent = branch_upstream else: self.__gone_branches.add(parent) # A parent that isn't in the branches info is a root. roots.add(parent) self.__parent_map[parent].append(branch) self.__current_branch = current_branch() self.__current_hash = hash_one('HEAD', short=True) self.__tag_set = tags() if roots: for root in sorted(roots): self.__append_branch(root) else: no_branches = OutputLine() no_branches.append('No User Branches') self.output.append(no_branches)
def start(self): self.__branches_info = get_branches_info( include_tracking_status=self.verbosity >= 1) if (self.verbosity >= 2): # Avoid heavy import unless necessary. from git_cl import get_cl_statuses, color_for_status, Changelist change_cls = [Changelist(branchref='refs/heads/'+b) for b in self.__branches_info.keys() if b] status_info = get_cl_statuses(change_cls, fine_grained=self.verbosity > 2, max_processes=self.maxjobs) # This is a blocking get which waits for the remote CL status to be # retrieved. for cl, status in status_info: self.__status_info[cl.GetBranch()] = (cl.GetIssueURL(), color_for_status(status), status) roots = set() # A map of parents to a list of their children. for branch, branch_info in self.__branches_info.iteritems(): if not branch_info: continue parent = branch_info.upstream if not self.__branches_info[parent]: branch_upstream = upstream(branch) # If git can't find the upstream, mark the upstream as gone. if branch_upstream: parent = branch_upstream else: self.__gone_branches.add(parent) # A parent that isn't in the branches info is a root. roots.add(parent) self.__parent_map[parent].append(branch) self.__current_branch = current_branch() self.__current_hash = hash_one('HEAD', short=True) self.__tag_set = tags() if roots: for root in sorted(roots): self.__append_branch(root) else: no_branches = OutputLine() no_branches.append('No User Branches') self.output.append(no_branches)
def start(self): self.__branches_info = get_branches_info( include_tracking_status=self.verbosity >= 1) if (self.verbosity >= 2): # Avoid heavy import unless necessary. from git_cl import get_cl_statuses status_info = get_cl_statuses(self.__branches_info.keys(), fine_grained=self.verbosity > 2, max_processes=self.maxjobs) for _ in xrange(len(self.__branches_info)): # This is a blocking get which waits for the remote CL status to be # retrieved. (branch, url, color) = status_info.next() self.__status_info[branch] = (url, color) roots = set() # A map of parents to a list of their children. for branch, branch_info in self.__branches_info.iteritems(): if not branch_info: continue parent = branch_info.upstream if not self.__branches_info[parent]: branch_upstream = upstream(branch) # If git can't find the upstream, mark the upstream as gone. if branch_upstream: parent = branch_upstream else: self.__gone_branches.add(parent) # A parent that isn't in the branches info is a root. roots.add(parent) self.__parent_map[parent].append(branch) self.__current_branch = current_branch() self.__current_hash = hash_one('HEAD', short=True) self.__tag_set = tags() if roots: for root in sorted(roots): self.__append_branch(root) else: no_branches = OutputLine() no_branches.append('No User Branches') self.output.append(no_branches)