// ProfileReplaceRevision replaces the old revision with a new revision
// in the profile.
352394
func ProfileReplaceRevision(profile string, rev int) (string, error) {
	if !IsValidName(profile) {
		return "", errors.BadRequestf("not a juju profile name: %q", profile)
	}
	split := strings.Split(profile, "-")
	notRev := split[:len(split)-1]
	return strings.Join(append(notRev, strconv.Itoa(rev)), "-"), nil
}
232760
func (md *RootMetadata) SetRevision(revision kbfsmd.Revision) {
	md.bareMd.SetRevision(revision)
}
1311591
func InsertOrReplaceOption(opts []interface{}, opt interface{}) []interface{} {
	if opts == nil && opt == nil {
		return nil
	}
	if opts == nil {
		return []interface{}{opt}
	}
	if opt == nil {
		return opts
	}

	t1 := reflect.Indirect(reflect.ValueOf(opt)).Type()

	var res []interface{}
	for _, o := range opts {
		t2 := reflect.Indirect(reflect.ValueOf(o)).Type()
		if t1 != t2 {
			res = append(res, o)
		}
	}
	return append(res, opt)
}
139035
func (ac *APIController) NetprofileUpdate(profile, params *contivModel.Netprofile) error {
	log.Infof("Received NetprofileUpdate: %+v, params: %+v", profile, params)

	if params.Burst > 0 && params.Burst < 2 {
		return core.Errorf("Invalid Burst size. burst size must be > 1500 bytes")
	}
	profile.Bandwidth = params.Bandwidth
	profile.DSCP = params.DSCP
	profile.Burst = params.Burst

	for key := range profile.LinkSets.EndpointGroups {
		// Find the corresponding epg
		epg := contivModel.FindEndpointGroup(key)
		if epg == nil {
			return core.Errorf("EndpointGroups not found")
		}

		err := master.UpdateEndpointGroup(params.Bandwidth, epg.GroupName, epg.TenantName, params.DSCP, params.Burst)
		if err != nil {
			log.Errorf("Error updating the EndpointGroups: %s. Err: %v", epg.GroupName, err)
		}
	}
	return nil
}
1095824
func compareReplaceInline(s1, s2 string, old, new byte) int {
	// TODO(stevvooe): We are missing an optimization when the s1 and s2 have
	// the exact same slice header. It will make the code unsafe but can
	// provide some extra performance.

	l := len(s1)
	if len(s2) < l {
		l = len(s2)
	}

	for i := 0; i < l; i++ {
		c1, c2 := s1[i], s2[i]
		if c1 == old {
			c1 = new
		}

		if c2 == old {
			c2 = new
		}

		if c1 < c2 {
			return -1
		}

		if c1 > c2 {
			return +1
		}
	}

	if len(s1) < len(s2) {
		return -1
	}

	if len(s1) > len(s2) {
		return +1
	}

	return 0
}
832362
func WithRevisions(parent context.Context, revisions []string) context.Context {
	return context.WithValue(contextOrBackground(parent), keyRevisions, revisions)
}
98713
func (g *Git) GetRevision(context.Context, string, string) ([]byte, error) {
	return nil, fmt.Errorf("not yet implemented for %s", g.Name())
}
412869
func (c *Files) ListRevisions(in *ListRevisionsInput) (out *ListRevisionsOutput, err error) {
	body, err := c.call("/files/list_revisions", in)
	if err != nil {
		return
	}
	defer body.Close()

	err = json.NewDecoder(body).Decode(&out)
	return
}
276195
func (s *Store) ListRevisions(ctx context.Context, name string) ([]backend.Revision, error) {
	p := s.passfile(name)
	return s.rcs.Revisions(ctx, p)
}
324968
func FindEqualRevisions(revisions []*apps.ControllerRevision, needle *apps.ControllerRevision) []*apps.ControllerRevision {
	var eq []*apps.ControllerRevision
	for i := range revisions {
		if EqualRevision(revisions[i], needle) {
			eq = append(eq, revisions[i])
		}
	}
	return eq
}
373482
func (s *TraceSummary) SetRevision(v int64) *TraceSummary {
	s.Revision = &v
	return s
}
810911
func (r *StateRestore) JobVersionRestore(version *structs.Job) error {
	if err := r.txn.Insert("job_version", version); err != nil {
		return fmt.Errorf("job version insert failed: %v", err)
	}
	return nil
}
516937
func (s *TaskDefinition) SetRevision(v int64) *TaskDefinition {
	s.Revision = &v
	return s
}
103009
func (s *CreateDeploymentInput) SetRevision(v *RevisionLocation) *CreateDeploymentInput {
	s.Revision = v
	return s
}
186274
func (c oauthClient) FolderRevisions() ([]wl.FolderRevision, error) {
	url := fmt.Sprintf(
		"%s/folder_revisions",
		c.apiURL,
	)

	req, err := c.newGetRequest(url)
	if err != nil {
		return nil, err
	}

	resp, err := c.do(req)
	if err != nil {
		return nil, err
	}

	if resp.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("Unexpected response code %d - expected %d", resp.StatusCode, http.StatusOK)
	}

	folders := []wl.FolderRevision{}
	err = json.NewDecoder(resp.Body).Decode(&folders)
	if err != nil {
		return nil, err
	}
	return folders, nil
}
474336
func (db *BytesConnectionEtcd) GetRevision() (revision int64, err error) {
	return getRevisionInternal(db.Logger, db.etcdClient, db.opTimeout)
}
130396
func (g *Git) GetRevision(ctx context.Context, name, revision string) ([]byte, error) {
	name = strings.TrimSpace(name)
	revision = strings.TrimSpace(revision)
	args := []string{
		"show",
		revision + ":" + name,
	}
	stdout, stderr, err := g.captureCmd(ctx, "GetRevision", args...)
	if err != nil {
		out.Debug(ctx, "Command failed: %s", string(stderr))
		return nil, err
	}
	return stdout, nil
}