// Changes produces a list of changes between the specified layer
// and its parent layer. If parent is "", then all changes will be ADD changes.
551607
func (gdw *NaiveDiffDriver) Changes(id string, idMappings *idtools.IDMappings, parent string, parentMappings *idtools.IDMappings, mountLabel string) ([]archive.Change, error) {
	driver := gdw.ProtoDriver

	if idMappings == nil {
		idMappings = &idtools.IDMappings{}
	}
	if parentMappings == nil {
		parentMappings = &idtools.IDMappings{}
	}

	options := MountOpts{
		MountLabel: mountLabel,
	}
	layerFs, err := driver.Get(id, options)
	if err != nil {
		return nil, err
	}
	defer driver.Put(id)

	parentFs := ""

	if parent != "" {
		options := MountOpts{
			MountLabel: mountLabel,
		}
		parentFs, err = driver.Get(parent, options)
		if err != nil {
			return nil, err
		}
		defer driver.Put(parent)
	}

	return archive.ChangesDirs(layerFs, idMappings, parentFs, parentMappings)
}
776674
func (prc ListProcessor) Change(params imageserver.Params) bool {
	for _, p := range prc {
		if p.Change(params) {
			return true
		}
	}
	return false
}
159655
func (c *CommitFile) GetChanges() int {
	if c == nil || c.Changes == nil {
		return 0
	}
	return *c.Changes
}
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
	}
}
1059246
func (info *FileInfo) Changes(oldInfo *FileInfo) []Change {
	var changes []Change

	info.addChanges(oldInfo, &changes)

	return changes
}
759129
func (t *DryRunTarget) HasChanges() bool {
	return len(t.changes)+len(t.deletions) != 0
}
625129
func (w *Window) Change(valueMask int, valueList ...uint32) {
	xproto.ChangeWindowAttributes(w.X.Conn(), w.Id,
		uint32(valueMask), valueList)
}
563442
func (client *Client) Changes(cid string) ([]ContainerChange, error) {
	uri := fmt.Sprintf("/containers/%s/changes", cid)
	resp, err := client.DoRequest("GET", uri, nil)
	var changes []ContainerChange
	if err != nil {
		return changes, err
	}
	if err = jsonUnmarshal(resp, &changes); err != nil {
		return changes, fmt.Errorf("docker: changes: %v", err)
	}
	return changes, nil
}
1190302
func (s *Session) Changed() bool {
	if s.changed {
		return true
	}
	if s.flash != nil && s.flash.Changed() {
		s.changed = true
		return true
	}
	return false
}
1217615
func (s *Settings) changes() settings.ItemChanges {
	var changes settings.ItemChanges

	for key := range cacheKeys(s.disk, s.core) {
		old, onDisk := s.disk[key]
		live, inCore := s.core[key]
		if reflect.DeepEqual(live, old) {
			continue
		}

		var change settings.ItemChange
		switch {
		case inCore && onDisk:
			change = settings.MakeModification(key, old, live)
		case inCore && !onDisk:
			change = settings.MakeAddition(key, live)
		case onDisk && !inCore:
			change = settings.MakeDeletion(key, old)
		default:
			panic("unreachable")
		}
		changes = append(changes, change)
	}
	sort.Sort(changes)
	return changes
}
845127
func (cl FileChangelist) Add(c Change) error {
	cJSON, err := json.Marshal(c)
	if err != nil {
		return err
	}
	filename := fmt.Sprintf("%020d_%s.change", time.Now().UnixNano(), uuid.Generate())
	return ioutil.WriteFile(filepath.Join(cl.dir, filename), cJSON, 0644)
}
264533
func (mc *MembershipChanges) Changed() bool {
	return len(mc.AddedNodes) > 0 || len(mc.RemovedNodes) > 0
}
661786
func (s *DataMsgServiceServer) DataChanges(stream msg.DataMsgService_DataChangesServer) error {
	for {
		chng, err := stream.Recv()

		if err == io.EOF {
			return nil
		}
		if err != nil {
			return err
		}

		for _, sub := range s.adapter.base.Subscriptions() {
			for _, keyPrefix := range sub.KeyPrefixes {
				if strings.HasPrefix(chng.Key, keyPrefix) {
					sub.ChangeChan <- msg.NewChangeWatchResp(context.Background(), chng, func(err2 error) {
						err = stream.Send(&msg.DataChangeReply{Key: chng.Key, OperationType: chng.OperationType,
							Result: 0 /*TODO VPP Result*/})
						if err != nil {
							logrus.DefaultLogger().Error(err) //Not able to propagate it somewhere else
						}
					})
				}
			}
		}
	}
}
1025262
func (f *PropertyFilter) apply(ctx *Context, change types.ObjectUpdate) types.ObjectUpdate {
	parents := make(map[string]bool)
	set := change.ChangeSet
	change.ChangeSet = nil

	for i, p := range set {
		if f.matches(ctx, change.Obj, &p) {
			if p.Name != set[i].Name {
				// update matches a parent field from the spec.
				if parents[p.Name] {
					continue // only return 1 instance of the parent
				}
				parents[p.Name] = true
			}
			change.ChangeSet = append(change.ChangeSet, p)
		}
	}

	return change
}
1134319
func (s *HTTPServer) syncChanges() {
	if err := s.agent.State.SyncChanges(); err != nil {
		s.agent.logger.Printf("[ERR] agent: failed to sync changes: %v", err)
	}
}
759203
func (c *Checkout) ChangedFiles(ctx context.Context, ref string) ([]string, error) {
	list, err := changed(ctx, c.dir, ref, c.config.Paths)
	if err == nil {
		for i, file := range list {
			list[i] = filepath.Join(c.dir, file)
		}
	}
	return list, err
}
866227
func (gdw *NaiveDiffDriver) Diff(id, parent string) (arch io.ReadCloser, err error) {
	startTime := time.Now()
	driver := gdw.ProtoDriver

	layerRootFs, err := driver.Get(id, "")
	if err != nil {
		return nil, err
	}
	layerFs := layerRootFs.Path()

	defer func() {
		if err != nil {
			driver.Put(id)
		}
	}()

	if parent == "" {
		archive, err := archive.Tar(layerFs, archive.Uncompressed)
		if err != nil {
			return nil, err
		}
		return ioutils.NewReadCloserWrapper(archive, func() error {
			err := archive.Close()
			driver.Put(id)
			return err
		}), nil
	}

	parentRootFs, err := driver.Get(parent, "")
	if err != nil {
		return nil, err
	}
	defer driver.Put(parent)

	parentFs := parentRootFs.Path()

	changes, err := archive.ChangesDirs(layerFs, parentFs)
	if err != nil {
		return nil, err
	}

	archive, err := archive.ExportChanges(layerFs, changes, gdw.uidMaps, gdw.gidMaps)
	if err != nil {
		return nil, err
	}

	return ioutils.NewReadCloserWrapper(archive, func() error {
		err := archive.Close()
		driver.Put(id)

		// NaiveDiffDriver compares file metadata with parent layers. Parent layers
		// are extracted from tar's with full second precision on modified time.
		// We need this hack here to make sure calls within same second receive
		// correct result.
		time.Sleep(time.Until(startTime.Truncate(time.Second).Add(time.Second)))
		return err
	}), nil
}