// attachRevisionInfo attaches a buildbucket-style BuildSet, and sets one or
// more ManifestKeys on this build summary.
167421
func attachRevisionInfo(c context.Context, b *buildbot.Build, bs *model.BuildSummary) error {
	funcs := []struct {
		Name string
		CB   func() (string, error)
	}{
		{"GitilesCommit", func() (string, error) {
			repoI, revI := b.PropertyValue("repository"), b.PropertyValue("revision")
			repo, _ := repoI.(string)
			rev, _ := revI.(string)
			revBytes, _ := hex.DecodeString(rev)

			if repo == "" || len(revBytes) != sha1.Size {
				return "", errMissingProperties
			}

			u, err := url.Parse(repo)
			if err != nil {
				return "", errors.Annotate(err, "bad url").Err()
			}

			if !strings.HasSuffix(u.Host, ".googlesource.com") {
				return "", errors.Reason("unknown host: %q", u.Host).Err()
			}

			if strings.Contains(u.Path, "+") {
				return "", errors.Reason("path has '+': %q", u.Path).Err()
			}

			commit := &buildbucketpb.GitilesCommit{
				Project: strings.TrimSuffix(strings.TrimPrefix(u.Path, "/"), ".git"),
				Host:    u.Host,
				Id:      rev,
			}
			return protoutil.GitilesBuildSet(commit), nil
		}},

		{"GerritChange", func() (string, error) {
			pgu, _ := b.PropertyValue("patch_gerrit_url").(string)
			pi, _ := b.PropertyValue("patch_issue").(float64)
			ps, _ := b.PropertyValue("patch_set").(float64)

			if pgu == "" || pi == 0 || ps == 0 {
				return "", errMissingProperties
			}

			u, err := url.Parse(pgu)
			if err != nil {
				return "", errors.Annotate(err, "parsing url").Err()
			}

			if !strings.HasSuffix(u.Host, ".googlesource.com") {
				return "", errors.Reason("unknown host: %q", u.Host).Err()
			}

			change := &buildbucketpb.GerritChange{
				Host:     u.Host,
				Change:   int64(pi),
				Patchset: int64(ps),
			}
			return protoutil.GerritBuildSet(change), nil
		}},
	}

	for _, f := range funcs {
		if bset, err := f.CB(); err == nil {
			bs.BuildSet = append(bs.BuildSet, bset)
		} else if err != errMissingProperties {
			logging.WithError(err).Warningf(c, "failed to apply %s", f.Name)
		}
	}

	return bs.AddManifestKeysFromBuildSets(c)
}
534597
func checkoutRevision(gitClient git.Client, commitSHA string) (string, error) {
	err := gitClient.Init()
	if err != nil {
		return "", status.Errorf(codes.Internal, "Failed to initialize git repo: %v", err)
	}
	err = gitClient.Fetch()
	if err != nil {
		return "", status.Errorf(codes.Internal, "Failed to fetch git repo: %v", err)
	}
	err = gitClient.Checkout(commitSHA)
	if err != nil {
		return "", status.Errorf(codes.Internal, "Failed to checkout %s: %v", commitSHA, err)
	}
	return gitClient.CommitSHA()
}
553498
func (l *tarexporter) releaseLayerReferences(imgDescr map[image.ID]*imageDescriptor) error {
	for _, descr := range imgDescr {
		if descr.layerRef != nil {
			os := descr.image.OS
			if os == "" {
				os = runtime.GOOS
			}
			l.lss[os].Release(descr.layerRef)
		}
	}
	return nil
}
1140655
func (s *ActionTypeSettings) SetRevisionUrlTemplate(v string) *ActionTypeSettings {
	s.RevisionUrlTemplate = &v
	return s
}
580460
func (r *Store) GetRevision(ctx context.Context, name, revision string) (store.Secret, error) {
	ctx, store, name := r.getStore(ctx, name)
	return store.GetRevision(ctx, name, revision)
}
447301
func LastRevision(allRSs []*apps.ReplicaSet) int64 {
	max, secMax := int64(0), int64(0)
	for _, rs := range allRSs {
		if v, err := Revision(rs); err != nil {
			// Skip the replica sets when it failed to parse their revision information
			klog.V(4).Infof("Error: %v. Couldn't parse revision for replica set %#v, deployment controller will skip it when reconciling revisions.", err, rs)
		} else if v >= max {
			secMax = max
			max = v
		} else if v > secMax {
			secMax = v
		}
	}
	return secMax
}
974871
func (s *Store) ListRevisions(context.Context, string) ([]backend.Revision, error) {
	return nil, fmt.Errorf("not supported")
}
1152771
func (s *UpdateSimulationApplicationOutput) SetRevisionId(v string) *UpdateSimulationApplicationOutput {
	s.RevisionId = &v
	return s
}
58601
func (s *Store) GetRevision(context.Context, string, string) (store.Secret, error) {
	return nil, fmt.Errorf("not supported")
}
98713
func (g *Git) GetRevision(context.Context, string, string) ([]byte, error) {
	return nil, fmt.Errorf("not yet implemented for %s", g.Name())
}
855791
func WithRevision(ctx context.Context, rev string) context.Context {
	return context.WithValue(ctx, ctxKeyRevision, rev)
}
296864
func (dbclient *CouchDatabase) getDocumentRevision(id string) string {

	var rev = ""

	//See if the document already exists, we need the rev for saves and deletes
	_, revdoc, err := dbclient.ReadDoc(id)
	if err == nil {
		//set the revision to the rev returned from the document read
		rev = revdoc
	}
	return rev
}
634546
func (c *scannedConfigs) setRevision(revision string) {
	newRevPathMap := make(map[lookupKey]*config.Config, len(c.contentRevPathMap))
	for k, v := range c.contentRevPathMap {
		k.revision = revision
		v.Revision = revision
		newRevPathMap[k] = v
	}
	c.contentRevPathMap = newRevPathMap

	newRevProject := make(map[lookupKey]*config.Project, len(c.contentRevProject))
	for k, v := range c.contentRevProject {
		k.revision = revision
		newRevProject[k] = v
	}
	c.contentRevProject = newRevProject
}
672004
func (r Repository) UploadBundleWithRevision(id *charm.URL, bundleData charm.Bundle, promulgatedRevision int) error {
	_, err := r.UploadBundle(id, bundleData)
	if err != nil {
		return errors.Trace(err)
	}
	r.revisions[r.channel][*id] = promulgatedRevision
	return nil
}
529246
func (s *GetApplicationRevisionOutput) SetRevisionInfo(v *GenericRevisionInfo) *GetApplicationRevisionOutput {
	s.RevisionInfo = v
	return s
}
1232982
func (v *volumeAttachmentPlan) PlanInfo() (VolumeAttachmentPlanInfo, error) {
	if v.doc.PlanInfo == nil {
		return VolumeAttachmentPlanInfo{}, errors.NotProvisionedf("volume attachment plan %q on %q", v.doc.Volume, v.doc.Machine)
	}
	return *v.doc.PlanInfo, nil
}
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
}