bool operator< ( const CDictionaryBasedTempPath& lhs , const CDictionaryBasedTempPath& rhs) { // both elements should be from the same container // (otherwise, some shortcuts may not be justified) assert (lhs.GetDictionary() == rhs.GetDictionary()); // quick compare: indices and counters ptrdiff_t diff = lhs.GetBasePath().GetIndex() - rhs.GetBasePath().GetIndex(); if (diff < 0) return true; if (diff > 0) return false; diff = lhs.GetRelPathElements().size() - rhs.GetRelPathElements().size(); if (diff < 0) return true; if (diff > 0) return false; // long and boring comparison return lhs.GetRelPathElements() < rhs.GetRelPathElements(); }
bool CDictionaryBasedTempPath::operator==(const CDictionaryBasedTempPath& rhs) const { return (GetBasePath() == rhs.GetBasePath()) && (relPathElements.size() == rhs.relPathElements.size()) && (std::equal ( relPathElements.begin() , relPathElements.end() , rhs.relPathElements.begin())); }
bool CLogIteratorBase::PathInRevision ( const CRevisionInfoContainer::CChangesIterator& first , const CRevisionInfoContainer::CChangesIterator& last , const CDictionaryBasedTempPath& path) { // close examination of all changes for ( CRevisionInfoContainer::CChangesIterator iter = first ; iter != last ; ++iter) { // if (and only if) path is a cached path, // it may be a parent of the changedPath // (i.e. report a change of this or some sub-path) CDictionaryBasedPath changedPath = iter->GetPath(); if ( path.IsFullyCachedPath() && path.GetBasePath().IsSameOrParentOf (changedPath)) return true; // this change affects a true parent path or completely unrelated path // -> ignore mere modifications (e.g. properties on a folder) if (iter->GetAction() == CRevisionInfoContainer::ACTION_CHANGED) continue; // this is an add / delete / replace. // does it affect our path? if (changedPath.IsSameOrParentOf (path.GetBasePath())) return true; } // no paths that we were looking for return false; }
void CFullGraphFinalizer::InitWCRevs() { // collect revisions to show std::vector<revision_t> revisions; revisions.push_back (history.GetWCInfo().minCommit); revisions.push_back (history.GetWCInfo().maxCommit); revisions.push_back (history.GetWCInfo().minAtRev); revisions.push_back (history.GetWCInfo().maxAtRev); std::sort (revisions.begin(), revisions.end()); revisions.erase ( std::unique_copy ( revisions.begin() , revisions.end() , revisions.begin()) , revisions.end()); // assign paths CDictionaryBasedTempPath path = *history.GetWCPath(); revision_t pathRevision = history.GetPegRevision(); while ( !revisions.empty() && (revisions.back() >= pathRevision) && path.IsValid()) { wcRevs.insert ( wcRevs.begin() , std::make_pair (revisions.back(), path.GetBasePath())); revisions.pop_back(); } while (!revisions.empty()) { revision_t revision = revisions.back(); revisions.pop_back(); // efficiently follow path changes only const CCachedLogInfo* cache = history.GetCache(); const CRevisionIndex& revisionIndices = cache->GetRevisions(); const CRevisionInfoContainer& info = cache->GetLogInfo(); while (revision < pathRevision) { index_t index = revisionIndices[pathRevision]; if ( (index != NO_INDEX) && (info.GetSumChanges (index) & CRevisionInfoContainer::HAS_COPY_FROM) && (info.GetRootPath (index).IsSameOrParentOf (path.GetBasePath()))) { CCopyFollowingLogIterator iterator (cache, pathRevision, path); iterator.Advance(); pathRevision = iterator.GetRevision(); path = iterator.GetPath(); } else { --pathRevision; } } if (path.IsValid()) wcRevs.insert ( wcRevs.begin() , std::make_pair (revision, path.GetBasePath())); } }