// Changed returns a map of filename to lines changed in that file. Deleted
// files are ignored.
482324
func (d *Diff) Changed() map[string][]int {
	dFiles := make(map[string][]int)

	for _, f := range d.Files {
		if f.Mode == DELETED {
			continue
		}

		for _, h := range f.Hunks {
			for _, dl := range h.NewRange.Lines {
				if dl.Mode == ADDED { // TODO(waigani) return removed
					dFiles[f.NewName] = append(dFiles[f.NewName], dl.Number)
				}
			}
		}
	}

	return dFiles
}
430034
func (flag *NetworkFlag) Change(device types.BaseVirtualDevice, update types.BaseVirtualDevice) {
	current := device.(types.BaseVirtualEthernetCard).GetVirtualEthernetCard()
	changed := update.(types.BaseVirtualEthernetCard).GetVirtualEthernetCard()

	current.Backing = changed.Backing

	if changed.MacAddress != "" {
		current.MacAddress = changed.MacAddress
	}

	if changed.AddressType != "" {
		current.AddressType = changed.AddressType
	}
}
1237205
func (s *ChangesService) change(tail string, changeID string, input interface{}) (*ChangeInfo, *Response, error) {
	u := fmt.Sprintf("changes/%s/%s", changeID, tail)
	req, err := s.client.NewRequest("POST", u, input)
	if err != nil {
		return nil, nil, err
	}

	v := new(ChangeInfo)
	resp, err := s.client.Do(req, v)
	if err != nil {
		return nil, resp, err
	}
	if resp.StatusCode == http.StatusConflict {
		body, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return v, resp, err
		}
		return v, resp, errors.New(string(body[:]))
	}
	return v, resp, nil
}
671748
func scopeChanged(a, b []string) error {

	if len(a) != len(b) {
		return changeServerError{
			Code: "Scope changes detected; must get new snapshot",
		}
	}
	sort.Strings(a)
	sort.Strings(b)
	for i, v := range a {
		if v != b[i] {
			return changeServerError{
				Code: "Scope changes detected; must get new snapshot",
			}
		}
	}
	return nil
}
1072102
func (d Ploop) Replace(p *ReplaceParam) error {
	args := []string{"replace"}
	if p.UUID != "" {
		args = append(args, "-u", p.UUID)
	} else if p.CurFile != "" {
		args = append(args, "-o", p.CurFile)
	} else {
		args = append(args, "-l", strconv.Itoa(p.Level))
	}

	if p.Flags != 0 {
		if p.Flags&KeepName == KeepName {
			args = append(args, "-k")
		}
	}
	args = append(args, "-i", p.File)
	args = append(args, d.dd)

	return ploop(args...)
}
1170799
func (d *Driver) Changes(id string, idMappings *idtools.IDMappings, parent string, parentMappings *idtools.IDMappings, mountLabel string) ([]archive.Change, error) {
	if d.useNaiveDiff() || !d.isParent(id, parent) {
		return d.naiveDiff.Changes(id, idMappings, parent, parentMappings, mountLabel)
	}
	// Overlay doesn't have snapshots, so we need to get changes from all parent
	// layers.
	diffPath := d.getDiffPath(id)
	layers, err := d.getLowerDirs(id)
	if err != nil {
		return nil, err
	}

	return archive.OverlayChanges(layers, diffPath)
}
718381
func (r *DeploymentConfigReactor) ImageChanged(obj runtime.Object, tagRetriever trigger.TagRetriever) error {
	dc := obj.(*appsv1.DeploymentConfig)
	newDC := dc.DeepCopy()

	updated, resolvable, err := UpdateDeploymentConfigImages(newDC, tagRetriever)
	if err != nil {
		return err
	}
	if !resolvable {
		if klog.V(4) {
			klog.Infof("Ignoring changes to deployment config %s, has unresolved images: %s", dc.Name, printDeploymentTriggers(newDC.Spec.Triggers))
		}
		return nil
	}
	if updated == nil {
		klog.V(4).Infof("Deployment config %s has not changed", dc.Name)
		return nil
	}
	klog.V(4).Infof("Deployment config %s has changed", dc.Name)
	_, err = r.Client.DeploymentConfigs(dc.Namespace).Update(updated)
	return err
}
413732
func (fl *FolderList) userChanged(ctx context.Context, _, newUser kbname.NormalizedUsername) {
	var fs []*Folder
	func() {
		fl.mu.Lock()
		defer fl.mu.Unlock()
		for _, tlf := range fl.folders {
			if tlf, ok := tlf.(*TLF); ok {
				fs = append(fs, tlf.folder)
			}
		}
	}()
	for _, f := range fs {
		f.TlfHandleChange(ctx, nil)
	}
	if newUser != kbname.NormalizedUsername("") {
		fl.fs.config.KBFSOps().ForceFastForward(ctx)
	}
}
738906
func moveFiles(files map[string]string) error {
	filesToRecover := map[string]string{}
	for from, to := range files {
		if err := os.Rename(from, to); err != nil {
			return rollbackFiles(filesToRecover, err)
		}
		filesToRecover[to] = from
	}
	return nil
}
1239931
func (e *Ethtool) Change(intf string, config map[string]bool) error {
	names, err := e.FeatureNames(intf)
	if err != nil {
		return err
	}

	length := uint32(len(names))

	features := ethtoolSfeatures{
		cmd:  ETHTOOL_SFEATURES,
		size: (length + 32 - 1) / 32,
	}

	for key, value := range config {
		if index, ok := names[key]; ok {
			setFeatureBit(&features.blocks, index, value)
		} else {
			return fmt.Errorf("unsupported feature %q", key)
		}
	}

	return e.ioctl(intf, uintptr(unsafe.Pointer(&features)))
}
417670
func (st *MemStorage) writeChange(gun data.GUN, version int, checksum string) {
	c := Change{
		ID:        strconv.Itoa(len(st.changes) + 1),
		GUN:       gun.String(),
		Version:   version,
		SHA256:    checksum,
		CreatedAt: time.Now(),
		Category:  changeCategoryUpdate,
	}
	st.changes = append(st.changes, c)
}
625129
func (w *Window) Change(valueMask int, valueList ...uint32) {
	xproto.ChangeWindowAttributes(w.X.Conn(), w.Id,
		uint32(valueMask), valueList)
}
919731
func (p *printer) change(cl *pb.GerritChange) {
	switch {
	case cl.Host == "chromium-review.googlesource.com":
		p.linkf("https://crrev.com/c/%d/%d", cl.Change, cl.Patchset)
	case cl.Host == "chrome-internal-review.googlesource.com":
		p.linkf("https://crrev.com/i/%d/%d", cl.Change, cl.Patchset)
	default:
		p.linkf("https://%s/c/%s/+/%d/%d", cl.Host, cl.Project, cl.Change, cl.Patchset)
	}
}
34379
func (a Announcement) ChangedFields() (changed []string) {
	new := structs.New(a)
	fields := new.Names()
	if a.old == nil {
		return fields
	}
	old := structs.New(*a.old)

	for _, field := range new.Fields() {
		if !field.IsExported() || field.Name() == "old" {
			continue
		}
		if !reflect.DeepEqual(field.Value(), old.Field(field.Name()).Value()) {
			changed = append(changed, field.Name())
		}
	}

	if len(changed) == 1 && changed[0] == "UpdatedAt" {
		return []string{}
	}

	return
}
13382
func (prc *RotateProcessor) Change(params imageserver.Params) bool {
	if !params.Has(rotateParam) {
		return false
	}
	params, err := params.GetParams(rotateParam)
	if err != nil {
		return true
	}
	if params.Empty() {
		return false
	}
	if params.Has("rotation") {
		return true
	}
	return false
}
1318085
func changeFromGitiles(repoURL, branch string, commit *gitpb.Commit) buildbot.Change {
	ct, _ := ptypes.Timestamp(commit.Committer.Time)
	return buildbot.Change{
		At:         ct.Format("Mon _2 Jan 2006 15:04:05"),
		Branch:     &branch,
		Comments:   commit.Message,
		Repository: repoURL,
		Rev:        commit.Id,
		Revision:   commit.Id,
		Revlink:    fmt.Sprintf("%s/+/%s", strings.TrimSuffix(repoURL, "/"), commit.Id),
		When:       int(ct.Unix()),
		Who:        commit.Author.Email,
		// TODO(nodir): add Files if someone needs them.
	}
}
298570
func (d Device) ChangedFields() (changed []string) {
	new := structs.New(d)
	fields := new.Names()
	if d.old == nil {
		return fields
	}
	old := structs.New(*d.old)

	for _, field := range new.Fields() {
		if !field.IsExported() || field.Name() == "old" {
			continue
		}
		if !reflect.DeepEqual(field.Value(), old.Field(field.Name()).Value()) {
			changed = append(changed, field.Name())
			if field.Kind() == reflect.Struct {
				oldSubField := structs.New(old.Field(field.Name()).Value())
				for _, subField := range field.Fields() {
					if !subField.IsExported() {
						continue
					}
					if !reflect.DeepEqual(subField.Value(), oldSubField.Field(subField.Name()).Value()) {
						changed = append(changed, field.Name()+"."+subField.Name())
					}
				}
			}
		}
	}

	if len(changed) == 1 && changed[0] == "UpdatedAt" {
		return []string{}
	}

	return
}