Check if some related tracked fields have changed
439126
def _has_changed_related(instance):
    
    tracked_related_fields = getattr(
        instance,
        '_tracked_related_fields',
        {}
    ).keys()
    for field, value in instance._original_fields.items():
        if field != 'pk' and \
           not isinstance(instance._meta.get_field(field), ManyToManyField):
            if field in tracked_related_fields:
                if isinstance(instance._meta.get_field(field), ForeignKey):
                    if getattr(instance, '{0}_id'.format(field)) != value:
                        return True
                else:
                    if getattr(instance, field) != value:
                        return True
    return False
111115
def _track_class_related_field(cls, field):
    
    # field = field on current model
    # related_field = field on related model
    (field, related_field) = field.split('__', 1)
    field_obj = cls._meta.get_field(field)
    related_cls = field_obj.remote_field.model
    related_name = field_obj.remote_field.get_accessor_name()

    if not hasattr(related_cls, '_tracked_related_fields'):
        setattr(related_cls, '_tracked_related_fields', {})
    if related_field not in related_cls._tracked_related_fields.keys():
        related_cls._tracked_related_fields[related_field] = []

    # There can be several field from different or same model
    # related to a single model.
    # Thus _tracked_related_fields will be of the form:
    # {
    #     'field name on related model': [
    #         ('field name on current model', 'field name to current model'),
    #         ('field name on another model', 'field name to another model'),
    #         ...
    #     ],
    #     ...
    # }

    related_cls._tracked_related_fields[related_field].append(
        (field, related_name)
    )
    _add_signals_to_cls(related_cls)
    # Detect m2m fields changes
    if isinstance(related_cls._meta.get_field(related_field), ManyToManyField):
        m2m_changed.connect(
            tracking_m2m,
            sender=getattr(related_cls, related_field).through,
            dispatch_uid=repr(related_cls),
        )
953672
def check_for_changes(name=nil)
      changed = []
      if name == nil
        self.cache_hash.keys.dup.each do |name|
          if reload_on_change(name)
            changed << name
          end
        end
      else
        name = name.to_s
        if reload_on_change(name)
          changed << name
        end
      end
      logger.debug "check_for_changes(#{name.inspect}) => #{changed.inspect}"
      changed
    end
329327
def tracked_find(self, *args, **kwargs):
        
        _log.info("tracked_find.begin")
        # if tracking is off, just call find (ie do nothing)
        if self._tracking_off:
            _log.info("tracked_find.end, tracking=off")
            return self._coll_find(*args, **kwargs)
        # otherwise do somethin' real
        # fish 'filter' out of args or kwargs
        if len(args) > 0:
            filt = args[0]
        else:
            if 'filter' not in kwargs:
                kwargs['filter'] = {}
            filt = kwargs['filter']
        # update filter with tracker query
        filt.update(self._mark.query)
        # delegate to "real" find()
        _log.info("tracked_find.end, call: {}.find(args={} kwargs={})".format(self._coll.name, args, kwargs))
        return self._coll_find(*args, **kwargs)
520401
private void trackUsingKlt(List<CombinedTrack<TD>> tracks) {
		for( int i = 0; i < tracks.size();  ) {
			CombinedTrack<TD> track = tracks.get(i);

			if( !trackerKlt.performTracking(track.track) ) {
				// handle the dropped track
				tracks.remove(i);
				tracksDormant.add(track);
			} else {
				track.set(track.track.x,track.track.y);
				i++;
			}
		}
	}
451011
function _markAsChanged(treeData, changed) {
        changed.forEach(function (filePath) {
            var objectPath = _filePathToObjectPath(treeData, filePath);
            if (objectPath) {
                treeData = treeData.updateIn(objectPath, _addTimestamp);
            }
        });
        return treeData;
    }
829422
def _check_if_all_updated(self):
        """"""
        for g in self.toc.toc:
            if g not in self.values:
                return False
            for n in self.toc.toc[g]:
                if n not in self.values[g]:
                    return False

        return True
122090
def _track_changes(self):
        
        if self._field and getattr(self._parent, '_track_changes',
                                   None) is not None and self.untrack is False:
            self._parent._track_changes.add(self._field)
1204520
def _create_update_tracking_event(instance):
    
    event = _create_event(instance, UPDATE)
    for field in instance._tracked_fields:
        if not isinstance(instance._meta.get_field(field), ManyToManyField):
            try:
                if isinstance(instance._meta.get_field(field), ForeignKey):
                    # Compare pk
                    value = getattr(instance, '{0}_id'.format(field))
                else:
                    value = getattr(instance, field)
                if instance._original_fields[field] != value:
                    _create_tracked_field(event, instance, field)
            except TypeError:
                # Can't compare old and new value, should be different.
                _create_tracked_field(event, instance, field)
1145702
def previous(self, field):
        """"""

        # handle deferred fields that have not yet been loaded from the database
        if self.instance.pk and field in self.deferred_fields and field not in self.saved_data:

            # if the field has not been assigned locally, simply fetch and un-defer the value
            if field not in self.instance.__dict__:
                self.get_field_value(field)

            # if the field has been assigned locally, store the local value, fetch the database value,
            # store database value to saved_data, and restore the local value
            else:
                current_value = self.get_field_value(field)
                self.instance.refresh_from_db(fields=[field])
                self.saved_data[field] = deepcopy(self.get_field_value(field))
                setattr(self.instance, self.field_map[field], current_value)

        return self.saved_data.get(field)
1364845
protected function hasGitTrackedFilesChanged()
    {
        $task = $this->getGitBuildStack()
            ->exec("status --untracked-files=no --porcelain");

        /** @var Result $result */
        $result = $this->runSilentCommand($task);

        $changes = array_filter(
            explode("\n", $result->getMessage())
        );

        return (bool) count($changes) != 0;
    }
111488
def text_has_changed(self, text):
        """"""
        text = to_text_string(text)
        if text:
            self.lineno = int(text)
        else:
            self.lineno = None
1198304
function checkForChanges(){
		var changed = false;
		for (var i = 0; i < scopeList.length; i++){
			// if a scope is modified
			if (getValueFromPath(currentTheme, scopeList[i].objPath[0]) !== getValueFromPath(originalTheme, scopeList[i].objPath[0])){
				document.getElementById("scopeList").childNodes[i].classList.add('modified');//$NON-NLS-1$ //$NON-NLS-0$
				changed = true;
			}
			else {
				document.getElementById("scopeList").childNodes[i].classList.remove('modified');//$NON-NLS-1$ //$NON-NLS-0$
			}
		}
		//when there is a changed value, theme is now deletable/revertable/renamable
		if (changed){
			document.getElementById("scopeChanged").classList.remove('hide');//$NON-NLS-1$ //$NON-NLS-0$
			document.getElementById("scopeOriginal").classList.add('hide');//$NON-NLS-1$ //$NON-NLS-0$
		}
		else {
			document.getElementById("scopeChanged").classList.add('hide');//$NON-NLS-1$ //$NON-NLS-0$
			document.getElementById("scopeOriginal").classList.remove('hide');//$NON-NLS-1$ //$NON-NLS-0$
		}
	}
987916
public function isChanged()
    {
        // When unbound, use the local changed flag
        if (! ($this->record instanceof DataObject)) {
            return $this->isChanged;
        }

        // Defer to parent record
        foreach ($this->compositeDatabaseFields() as $field => $spec) {
            $key = $this->getName() . $field;
            if ($this->record->isChanged($key)) {
                return true;
            }
        }
        return false;
    }
155772
public boolean hasChanges() {
        for (Map.Entry<Object, DocumentInfo> entity : documentsByEntity.entrySet()) {
            ObjectNode document = entityToJson.convertEntityToJson(entity.getKey(), entity.getValue());
            if (entityChanged(document, entity.getValue(), null)) {
                return true;
            }
        }

        return !deletedEntities.isEmpty();
    }
829537
def related_items_changed(self, instance, related_manager):
        
        try:
            count = related_manager.count_queryset()
        except AttributeError:
            count = related_manager.count()
        count_field_name = list(self.fields.keys())[0] % \
                           self.related_field_name
        setattr(instance, count_field_name, count)
        instance.save()
580480
private void checkExistingTracks() {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                for (Map.Entry<DeckReference, TrackMetadata> entry : MetadataFinder.getInstance().getLoadedTracks().entrySet()) {
                    if (entry.getKey().hotCue == 0) {  // The track is currently loaded in a main player deck
                        checkIfSignatureReady(entry.getKey().player);
                    }
                }
            }
        });
    }