// AddBranch creates a new branch in the current model.
// A branch cannot be created with the same name as another "in-flight" branch.
// The input user indicates the operator who invoked the creation.
547041
func (st *State) AddBranch(branchName, userName string) error {
	id, err := sequence(st, "branch")
	if err != nil {
		return errors.Trace(err)
	}

	buildTxn := func(attempt int) ([]txn.Op, error) {
		if _, err := st.Branch(branchName); err != nil {
			if !errors.IsNotFound(err) {
				return nil, errors.Annotatef(err, "checking for existing branch")
			}
		} else {
			return nil, errors.Errorf("model already has branch %q", branchName)
		}

		now, err := st.ControllerTimestamp()
		if err != nil {
			return nil, errors.Trace(err)
		}
		return insertGenerationTxnOps(strconv.Itoa(id), branchName, userName, now), nil
	}
	err = st.db().Run(buildTxn)
	if err != nil {
		err = onAbort(err, ErrDead)
		logger.Errorf("cannot add branch to the model: %v", err)
	}
	return err
}
388986
func NewBranchRecoveryState(recoveryWindow uint32) *BranchRecoveryState {
	return &BranchRecoveryState{
		recoveryWindow:  recoveryWindow,
		addresses:       make(map[uint32]btcutil.Address),
		invalidChildren: make(map[uint32]struct{}),
	}
}
164253
func (s *Branch) SetBranchArn(v string) *Branch {
	s.BranchArn = &v
	return s
}
1353082
func (g *Git) NewBranch(branch string) *command.Model {
	return g.command("checkout", "-b", branch)
}
247220
func (c *Configuration) RemoteBranchForLocalBranch(localBranch string) string {
	// get remote ref to track, may not be same name
	merge := c.Find(fmt.Sprintf("branch.%s.merge", localBranch))
	if strings.HasPrefix(merge, "refs/heads/") {
		return merge[11:]
	} else {
		return localBranch
	}
}
602180
func (s *CreateBranchOutput) SetBranch(v *Branch) *CreateBranchOutput {
	s.Branch = v
	return s
}
213623
func (p *PagesSource) GetBranch() string {
	if p == nil || p.Branch == nil {
		return ""
	}
	return *p.Branch
}
594032
func ValidateBranchName(name string) error {
	if name == "" {
		return errors.NotValidf("empty branch name")
	}
	if name == GenerationMaster {
		return errors.NotValidf("branch name %q", GenerationMaster)
	}
	return nil
}
987959
func (s *GetJobInput) SetBranchName(v string) *GetJobInput {
	s.BranchName = &v
	return s
}
611277
public function addBranch(Branch $branch)
    {
        if ($this->currentBranch) {
            $branch->setParentBranch($this->currentBranch);
            $this->currentBranch = $branch;
        } else {
            $this->currentBranch = $branch;
        }

        $branch->setUniqueId($this->uniqueId);
        $branch->setLevel($this->level);

        ++$this->level;
        ++$this->uniqueId;

        if (Branch::TYPE_ROOT == $branch->getType()) {
            $this->setRootBranch($branch);
        }
    }
597173
func (cr *ConflictResolver) BeginNewBranch() {
	cr.inputLock.Lock()
	defer cr.inputLock.Unlock()
	// Reset the curr input so we don't ignore a future CR
	// request that uses the same revision number (i.e.,
	// because the previous CR failed to flush due to a
	// conflict).
	cr.currInput = conflictInput{}
}
16733
func (c *ModelCommandBase) ActiveBranch() (string, error) {
	if c._activeBranch != "" {
		return c._activeBranch, nil
	}
	// If we need to look up the model generation, we need to ensure we
	// have access to the model details.
	if err := c.maybeInitModel(); err != nil {
		return "", errors.Trace(err)
	}
	details, err := c.store.ModelByName(c._controllerName, c._modelName)
	if err != nil {
		if !c.runStarted {
			return "", errors.Trace(err)
		}
		details, err = c.modelDetails(c._controllerName, c._modelName)
		if err != nil {
			return "", errors.Trace(err)
		}
	}
	c._activeBranch = details.ActiveBranch
	return c._activeBranch, nil
}
1146727
func (s *DeleteJobInput) SetBranchName(v string) *DeleteJobInput {
	s.BranchName = &v
	return s
}
150222
func (r *Repository) Branch(name string) (*config.Branch, error) {
	cfg, err := r.Storer.Config()
	if err != nil {
		return nil, err
	}

	b, ok := cfg.Branches[name]
	if !ok {
		return nil, ErrBranchNotFound
	}

	return b, nil
}
963524
func (branch *GitBranch) FullRemoteBranchName() string {
	return fmt.Sprintf("%v/%v", branch.Remote, branch.RemoteBranchName)
}
161657
func (c *Client) TrackBranch(branchName string, entities []string) error {
	var result params.ErrorResults
	arg := params.BranchTrackArg{
		BranchName: branchName,
	}
	if len(entities) == 0 {
		return errors.New("no units or applications specified")
	}
	for _, entity := range entities {
		switch {
		case names.IsValidApplication(entity):
			arg.Entities = append(arg.Entities,
				params.Entity{Tag: names.NewApplicationTag(entity).String()})
		case names.IsValidUnit(entity):
			arg.Entities = append(arg.Entities,
				params.Entity{Tag: names.NewUnitTag(entity).String()})
		default:
			return errors.Errorf("%q is not an application or a unit", entity)
		}
	}
	err := c.facade.FacadeCall("TrackBranch", arg, &result)
	if err != nil {
		return errors.Trace(err)
	}

	if err := result.Combine(); err != nil {
		return errors.Trace(err)
	}
	return nil
}
783295
func (g *Git) Add(pathspec string) *command.Model {
	return g.command("add", pathspec)
}