Compares the two Git trees (with caching).
764
private List<DiffEntry> blockingCompareTrees(RevTree treeA, RevTree treeB) {
        if (cache == null) {
            return blockingCompareTreesUncached(treeA, treeB, TreeFilter.ALL);
        }

        final CacheableCompareTreesCall key = new CacheableCompareTreesCall(this, treeA, treeB);
        CompletableFuture<List<DiffEntry>> existingFuture = cache.getIfPresent(key);
        if (existingFuture != null) {
            final List<DiffEntry> existingDiffEntries = existingFuture.getNow(null);
            if (existingDiffEntries != null) {
                // Cached already.
                return existingDiffEntries;
            }
        }

        // Not cached yet. Acquire a lock so that we do not compare the same tree pairs simultaneously.
        final List<DiffEntry> newDiffEntries;
        final Lock lock = key.coarseGrainedLock();
        lock.lock();
        try {
            existingFuture = cache.getIfPresent(key);
            if (existingFuture != null) {
                final List<DiffEntry> existingDiffEntries = existingFuture.getNow(null);
                if (existingDiffEntries != null) {
                    // Other thread already put the entries to the cache before we acquire the lock.
                    return existingDiffEntries;
                }
            }

            newDiffEntries = blockingCompareTreesUncached(treeA, treeB, TreeFilter.ALL);
            cache.put(key, newDiffEntries);
        } finally {
            lock.unlock();
        }

        logger.debug("Cache miss: {}", key);
        return newDiffEntries;
    }
375718
def git_clone(uri, pull=True, reflect=False, cache_dir=None, chdir=True):
    '''
    
    '''
    cache_dir = cache_dir or CACHE_DIR
    # make the uri safe for filesystems
    repo_path = os.path.expanduser(os.path.join(cache_dir, safestr(uri)))
    if not os.path.exists(repo_path):
        from_cache = False
        logger.info(
            'Locally caching git repo [%s] to [%s]' % (uri, repo_path))
        cmd = 'git clone %s %s' % (uri, repo_path)
        sys_call(cmd)
    else:
        from_cache = True
        logger.info(
            'GIT repo loaded from local cache [%s])' % (repo_path))
    if pull and not from_cache:
        os.chdir(repo_path)
        cmd = 'git pull'
        sys_call(cmd, cwd=repo_path)
    if chdir:
        os.chdir(repo_path)
    if reflect:
        if not HAS_DULWICH:
            raise RuntimeError("`pip install dulwich` required!")
        return Repo(repo_path)
    else:
        return repo_path
403697
def is_dirty(self, index=True, working_tree=True, untracked_files=False,
                 submodules=True, path=None):
        
        if self._bare:
            # Bare repositories with no associated working directory are
            # always consired to be clean.
            return False

        # start from the one which is fastest to evaluate
        default_args = ['--abbrev=40', '--full-index', '--raw']
        if not submodules:
            default_args.append('--ignore-submodules')
        if path:
            default_args.append(path)
        if index:
            # diff index against HEAD
            if osp.isfile(self.index.path) and \
                    len(self.git.diff('--cached', *default_args)):
                return True
        # END index handling
        if working_tree:
            # diff index against working tree
            if len(self.git.diff(*default_args)):
                return True
        # END working tree handling
        if untracked_files:
            if len(self._get_untracked_files(path, ignore_submodules=not submodules)):
                return True
        # END untracked files
        return False
251370
def get_cached_commit_times(root_folder, parent_dir, sorted_relpaths):
    
    result = get_all_cached_commit_times(root_folder)

    for item in result:
        if sorted(item.get("sorted_relpaths", [])) == sorted_relpaths and item.get("parent_dir") == parent_dir:
            return item.get("commit"), item.get("commit_times")

    return None, {}
1271485
def compare(self, other, components=[]):
        
        lg.debug("Comparing publish %s (%s) and %s (%s)" % (self.name, self.storage or "local", other.name, other.storage or "local"))

        diff, equal = ({}, {})

        for component, snapshots in self.components.items():
            if component not in list(other.components.keys()):
                # Component is missing in other
                diff[component] = snapshots
                continue

            equal_snapshots = list(set(snapshots).intersection(other.components[component]))
            if equal_snapshots:
                lg.debug("Equal snapshots for %s: %s" % (component, equal_snapshots))
                equal[component] = equal_snapshots

            diff_snapshots = list(set(snapshots).difference(other.components[component]))
            if diff_snapshots:
                lg.debug("Different snapshots for %s: %s" % (component, diff_snapshots))
                diff[component] = diff_snapshots

        return (diff, equal)
1162764
def git_hook(error=True):
    """"""
    _, files_modified, _ = run("git diff-index --cached --name-only HEAD")

    options = parse_options()
    setup_logger(options)
    if sys.version_info >= (3,):
        candidates = [f.decode('utf-8') for f in files_modified]
    else:
        candidates = [str(f) for f in files_modified]

    if candidates:
        process_paths(options, candidates=candidates, error=error)
138871
def compare_files(pyc_filename1, pyc_filename2, verify):
    """"""
    (version1, timestamp, magic_int1, code_obj1, is_pypy,
     source_size) = uncompyle6.load_module(pyc_filename1)
    (version2, timestamp, magic_int2, code_obj2, is_pypy,
        source_size) = uncompyle6.load_module(pyc_filename2)
    if (magic_int1 != magic_int2) and verify == 'verify':
         verify = 'weak_verify'
    cmp_code_objects(version1, is_pypy, code_obj1, code_obj2, verify)
300860
private RepositoryResource compareNonProductResourceAppliesTo(RepositoryResource res1, RepositoryResource res2) {

        // all types other than INSTALLS or TOOLS use appliesTo to determine which is the higher level
        String res1AppliesTo = ((ApplicableToProduct) res1).getAppliesTo();
        String res2AppliesTo = ((ApplicableToProduct) res2).getAppliesTo();

        // on the basis that we will work with the appliesTo of a resource, if we find one that has an applies to
        // and one that doesn't we will the one WITH the applies to is assumed to be newer (if both null we look
        // at the version field)
        if (res1AppliesTo == null && res2AppliesTo == null) {
            // if both appliesTo are null look at the versions
            return getNonProductResourceWithHigherVersion(res1, res2);

        } else if (res1AppliesTo == null || res2AppliesTo == null) {
            // if one of them is null we can't compare them so return res1
            return res1;
        }

        MinAndMaxVersion res1MinMax = getMinAndMaxAppliesToVersionFromAppliesTo(res1AppliesTo);
        MinAndMaxVersion res2MinMax = getMinAndMaxAppliesToVersionFromAppliesTo(res2AppliesTo);

        // compare the versions and return the resource that applies to the higher minimum version
        if (res1MinMax.min.compareTo(res2MinMax.min) > 0) {
            return res1;
        } else if (res1MinMax.min.compareTo(res2MinMax.min) == 0) {

            // if they apply to the same minimum version then select the one with the highest max versions
            if (res1MinMax.max.compareTo(res2MinMax.max) > 0) {
                return res1;
            } else if (res1MinMax.max.compareTo(res2MinMax.max) < 0) {
                return res2;
            } else {
                // if they are still the same decide on the version
                return getNonProductResourceWithHigherVersion(res1, res2);
            }

        } else {
            return res2;
        }
    }
1158590
def fetch_compare(older, newer)
      unless @compares["#{older}...#{newer}"]
        compare_data = check_github_response { @client.compare(user_project, older, newer || "HEAD") }
        raise StandardError, "Sha #{older} and sha #{newer} are not related; please file a github-changelog-generator issues and describe how to replicate this issue." if compare_data["status"] == "diverged"

        @compares["#{older}...#{newer}"] = stringify_keys_deep(compare_data.to_hash)
      end
      @compares["#{older}...#{newer}"]
    end
644342
def _check_worktree_support(failhard=True):
    '''
    
    '''
    git_version = version(versioninfo=False)
    if _LooseVersion(git_version) < _LooseVersion('2.5.0'):
        if failhard:
            raise CommandExecutionError(
                'Worktrees are only supported in git 2.5.0 and newer '
                '(detected git version: ' + git_version + ')'
            )
        return False
    return True
297957
def ls_tree(options, treeish, *paths)
      sha = rev_parse({}, treeish)
      ruby_git.ls_tree(sha, paths.flatten, options.delete(:r))
    rescue Grit::GitRuby::Repository::NoSuchShaFound
      ''
    end
1081466
def clone_or_update
      if File.directory?(@dir + "/.git")
        if Git.open(@dir).remote.url == @config.repository_url
          update
        else
          clone
        end
      else
        clone
      end

      @repo.checkout(@config.branch)
    end
1335287
function CompareTreeModel(rootPath, fetchItems, root) {
		this.rootPath = rootPath;
		this.fetchItems = fetchItems;
		this.root = root;
	}
747649
def _recursive_compare(v1, v2):
    '''
    
    '''
    if isinstance(v1, list):
        if v2 is None:
            v2 = []
        if len(v1) != len(v2):
            return False
        v1.sort(key=_id_or_key)
        v2.sort(key=_id_or_key)
        for x, y in zip(v1, v2):
            if not _recursive_compare(x, y):
                return False
        return True
    elif isinstance(v1, dict):
        if v2 is None:
            v2 = {}
        v1 = dict(v1)
        v2 = dict(v2)
        if sorted(v1) != sorted(v2):
            return False
        for k in v1:
            if not _recursive_compare(v1[k], v2[k]):
                return False
        return True
    else:
        return v1 == v2
609069
function diff(node) {
		var oldBundle = (cachedData.loader.bundle || []).slice();

		return getDependencies(node.load).then(function(result){
			var newBundle = (cachedData.loader.bundle || []).slice();

			// If the deps are the same we can return the existing graph.
			if(same(node.deps, result.deps) &&
			   same(oldBundle, newBundle)) {
				clean(node, result.source);

				if(result.virtualModules.length) {
					var promises = result.virtualModules.map(function(l){
						var node = cachedData.graph[l.name];
						node.load.source = l.source;
						node.load.metadata.useSource = true;
						return diff(node);
					});

					return Promise.all(promises).then(function(results){
						result.same = results.every(function(res){
							return res.same;
						});
						return result;
					});
				}

				result.same = true;
			}
			return result;
		});

	}
470099
public static function DeepEqualWithCollation( $context, $iter1, $iter2, $collation )
	{
		// TreeComparer comparer = new TreeComparer( $context->RunningContext->GetCulture( $collation ) );
		/**
		 * @var TreeComparer $comparer
		 */
		$comparer = new TreeComparer( $context, $collation );
		return $comparer->DeepEqualByIterator( $iter1, $iter2 );
	}
178420
public static function compareVersion($version1, $version2)
    {
        if ($version1 == $version2) {
            return 0;
        }

        $v1 = Parser::parse($version1);
        $v2 = Parser::parse($version2);

        return self::compare($v1, $v2);
    }