//applyRingChange attempts to actually apply and persist the disk the given ring change.
7232
func (s *Server) applyRingChange(c *RingChange) error {
	builderErr, ringErr := s.rbPersistFn(c, false)
	if builderErr != nil {
		s.ctxlog.WithFields(log.Fields{
			"path":    fmt.Sprintf("%s/%s.builder", s.cfg.RingDir, s.servicename),
			"ringver": c.v,
			"err":     builderErr,
		}).Warning("Unable to persist builder")
		return builderErr
	}
	if ringErr != nil {
		s.ctxlog.WithFields(log.Fields{
			"path":    fmt.Sprintf("%s/%s.ring", s.cfg.RingDir, s.servicename),
			"ringver": c.v,
			"err":     ringErr,
		}).Warning("Unable to persist ring")
		return ringErr
	}
	newRB, newBB, err := s.loadRingBuilderBytes(c.v)
	if err != nil {
		return fmt.Errorf("Failed to load new ring/builder bytes: %s", err)
	}
	err = s.replicateRing(c.r, newRB, newBB)
	if err != nil {
		return fmt.Errorf("Ring replicate failed: %s", err)
	}
	//now update the current working ring
	builderErr, ringErr = s.rbPersistFn(c, true)
	s.rb = newRB
	s.bb = newBB
	s.b = c.b
	s.r = c.r
	if len(c.removedNodes) != 0 {
		s.removeManagedNodes(c.removedNodes)
	}
	go s.NotifyNodes()
	return nil
}
746395
func (l Listener) OnUserChange(e *gumble.UserChangeEvent) {
	if l.UserChange != nil {
		l.UserChange(e)
	}
}
225413
func (s *UserPendingChanges) SetPendingChange(v string) *UserPendingChanges {
	s.PendingChange = &v
	return s
}
469188
func (d *Driver) ApplyDiff(id string, parent string, diff archive.Reader) (size int64, err error) {
	dir := path.Join(virtPath, id)
	// dir := path.Join("/tmp/chainfs/", id)

	logrus.Infof("Applying diff at path %s\n", dir)

	if err := chrootarchive.UntarUncompressed(diff, dir, nil); err != nil {
		logrus.Warnf("Error while applying diff to %s: %v", id, err)
		return 0, err
	}

	// show invalid whiteouts warning.
	files, err := ioutil.ReadDir(path.Join(dir, archive.WhiteoutLinkDir))
	if err == nil && len(files) > 0 {
		logrus.Warnf("Archive contains aufs hardlink references that are not supported.")
	}

	return d.DiffSize(id, parent)
}
1174232
func applyString(src string, target *string) bool {
	if src != "" {
		*target = src
		return true
	}
	return false
}
841197
func (d *Driver) ApplyDiff(id string, idMappings *idtools.IDMappings, parent string, mountLabel string, diff io.Reader) (size int64, err error) {
	if !d.isParent(id, parent) {
		return d.naiveDiff.ApplyDiff(id, idMappings, parent, mountLabel, diff)
	}

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

	applyDir := d.getDiffPath(id)

	logrus.Debugf("Applying tar in %s", applyDir)
	// Overlay doesn't need the parent id to apply the diff
	if err := untar(diff, applyDir, &archive.TarOptions{
		UIDMaps:        idMappings.UIDs(),
		GIDMaps:        idMappings.GIDs(),
		WhiteoutFormat: d.getWhiteoutFormat(),
		InUserNS:       rsystem.RunningInUserNS(),
	}); err != nil {
		return 0, err
	}

	_, convert := d.convert[id]
	if convert {
		if err := ostree.ConvertToOSTree(d.options.ostreeRepo, applyDir, id); err != nil {
			return 0, err
		}
	}

	return directory.Size(applyDir)
}
1200331
func (v *DNSView) ApplyChangeset(zone DNSZoneInfo, removeRecords []*DNSRecord, createRecords []*DNSRecord) error {
	var removeTags []string
	for _, record := range removeRecords {
		tagKey, err := buildTagKey(zone, record)
		if err != nil {
			return err
		}
		removeTags = append(removeTags, tagKey)
	}

	createTags := make(map[string]string)
	for _, record := range createRecords {
		tagKey, err := buildTagKey(zone, record)
		if err != nil {
			return err
		}
		if createTags[tagKey] != "" {
			return fmt.Errorf("duplicate record %q being created", tagKey)
		}
		createTags[tagKey] = strings.Join(record.Rrdatas, ",")
	}

	return v.gossipState.UpdateValues(removeTags, createTags)
}
1359490
func (n *Node) applyUpdateNode(ctx context.Context, cc raftpb.ConfChange) error {
	newMember := &api.RaftMember{}
	err := proto.Unmarshal(cc.Context, newMember)
	if err != nil {
		return err
	}

	if newMember.RaftID == n.Config.ID {
		return nil
	}
	if err := n.transport.UpdatePeer(newMember.RaftID, newMember.Addr); err != nil {
		return err
	}
	return n.cluster.UpdateMember(newMember.RaftID, newMember)
}
913532
func PutChange(ch *Changeset, field string, value interface{}, opts ...Option) {
	options := Options{
		message: PutChangeErrorMessage,
	}
	options.apply(opts)

	if typ, exist := ch.types[field]; exist {
		if value != (interface{})(nil) {
			valTyp := reflect.TypeOf(value)
			if valTyp.Kind() == reflect.Ptr {
				valTyp = valTyp.Elem()
			}

			if valTyp.ConvertibleTo(typ) {
				ch.changes[field] = value
				return
			}
		} else {
			ch.changes[field] = reflect.Zero(reflect.PtrTo(typ)).Interface()
			return
		}
	}

	msg := strings.Replace(options.message, "{field}", field, 1)
	AddError(ch, field, msg)
}
256478
func NewChange(key string, value proto.Message, rev int64, changeType datasync.Op) *Change {
	return &Change{
		changeType: changeType,
		KeyVal:     &KeyVal{key, &lazyProto{value}, rev},
	}
}
840608
func (d *Driver) ApplyDiff(id string, idMappings *idtools.IDMappings, parent, mountLabel string, diff io.Reader) (int64, error) {
	panicIfUsedByLcow()
	var layerChain []string
	if parent != "" {
		rPId, err := d.resolveID(parent)
		if err != nil {
			return 0, err
		}
		parentChain, err := d.getLayerChain(rPId)
		if err != nil {
			return 0, err
		}
		parentPath, err := hcsshim.GetLayerMountPath(d.info, rPId)
		if err != nil {
			return 0, err
		}
		layerChain = append(layerChain, parentPath)
		layerChain = append(layerChain, parentChain...)
	}

	size, err := d.importLayer(id, diff, layerChain)
	if err != nil {
		return 0, err
	}

	if err = d.setLayerChain(id, layerChain); err != nil {
		return 0, err
	}

	return size, nil
}
635658
func SelectionChange(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "selectionchange", Listener: listener}
}
262504
func (s *StringCodeGenerator) ToolChange(t int) {
	if s.Tool == t {
		if s.Lines[len(s.Lines)-1] == fmt.Sprintf("T%d", t) {
			s.Lines[len(s.Lines)-1] = fmt.Sprintf("M6 T%d", t)
		} else {
			s.put("M6")
		}
	} else {
		s.put(fmt.Sprintf("M6 T%d", t))
		s.Tool = t
	}
	s.ForceModeWrite = true
}
307828
func (u *Updater) Apply() error {
	updateAvailable, err := u.HasUpdate(false)
	if err != nil {
		return err
	}
	if !updateAvailable {
		return nil
	}

	checksum, err := u.getSHA256(u.Filename)
	if err != nil {
		return err
	}

	newRelease, err := u.getFile(u.Filename)
	if err != nil {
		return err
	}
	defer newRelease.Close()

	return update.Apply(newRelease, update.Options{
		Checksum: checksum,
	})
}
1346164
func (k *SimpleFS) LocalChange(
	ctx context.Context, node libkbfs.Node, _ libkbfs.WriteRange) {
	k.subscribeLock.RLock()
	defer k.subscribeLock.RUnlock()
	if node.GetFolderBranch() == k.subscribeCurrFB {
		k.config.Reporter().NotifyPathUpdated(ctx, k.subscribeCurrTlfPathFromGUI)
	}
}
1153428
func VolumeChange(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "volumechange", Listener: listener}
}
1079365
func (s *ChangesService) SubmitChange(changeID string, input *SubmitInput) (*ChangeInfo, *Response, error) {
	return s.change("submit", changeID, input)
}