Hide history-resync updates from "All history" (#19435)

* [web] hide history-resync updates from "All history"

* Revert "[web] hide history-resync updates from "All history""

This reverts commit e9d5e7638eabe2baccf36f8c80bb4cd619e383ea.

* filter history resync update in summarizeUpdates

* used isHistoryResyncUpdate for merging

* remove merging for history-resync

* Revert "remove merging for history-resync"

This reverts commit 6ce48bc3f906867a64c0acc12e2dc61c05436c41.

GitOrigin-RevId: 0335eb9c05815fb66188d453a90dd09531504a55
This commit is contained in:
Domagoj Kriskovic 2024-07-18 10:42:11 +02:00 committed by Copybot
parent 523e340a0d
commit 6afb067737
2 changed files with 19 additions and 55 deletions

View file

@ -189,10 +189,10 @@ function _summarizeUpdates(updates, labels, existingSummarizedUpdates, toV) {
toV = update.v + 1
}
// Skip empty updates (only record their version). Empty updates are
// updates that only contain comment operations. We don't have a UI for
// Skip empty and history-resync updates (only record their version).
// Empty updates are updates that only contain comment operations. We don't have a UI for
// these yet.
if (isUpdateEmpty(update)) {
if (isUpdateEmpty(update) || isHistoryResyncUpdate(update)) {
continue
}
@ -282,11 +282,8 @@ function _shouldMergeUpdate(update, summarizedUpdate, labels) {
const updateHasFileOps = update.project_ops.length > 0
const summarizedUpdateHasTextOps = summarizedUpdate.pathnames.size > 0
const summarizedUpdateHasFileOps = summarizedUpdate.project_ops.length > 0
const isHistoryResync =
update.meta.origin &&
['history-resync', 'history-migration'].includes(update.meta.origin.kind)
if (
!isHistoryResync &&
!isHistoryResyncUpdate(update) &&
((updateHasTextOps && summarizedUpdateHasFileOps) ||
(updateHasFileOps && summarizedUpdateHasTextOps))
) {
@ -346,3 +343,10 @@ function _mergeUpdate(update, summarizedUpdate) {
function isUpdateEmpty(update) {
return update.project_ops.length === 0 && update.pathnames.length === 0
}
function isHistoryResyncUpdate(update) {
return (
update.meta.origin?.kind === 'history-resync' ||
update.meta.origin?.kind === 'history-migration'
)
}

View file

@ -595,12 +595,12 @@ describe('SummarizedUpdatesManager', function () {
makeUpdate({
startTs: 20,
v: 3,
origin: { kind: 'history-resync' },
origin: { kind: 'origin-a' },
}),
makeUpdate({
startTs: 30,
v: 4,
origin: { kind: 'history-resync' },
origin: { kind: 'origin-a' },
}),
makeUpdate({ startTs: 40, v: 5 }),
makeUpdate({ startTs: 50, v: 6 }),
@ -617,7 +617,7 @@ describe('SummarizedUpdatesManager', function () {
endTs: 40,
fromV: 3,
toV: 5,
origin: { kind: 'history-resync' },
origin: { kind: 'origin-a' },
}),
makeSummary({ startTs: 0, endTs: 20, fromV: 1, toV: 3 }),
]
@ -687,13 +687,7 @@ describe('SummarizedUpdatesManager', function () {
describe('history resync updates', function () {
setupChunks([
[
makeUpdate({
startTs: 0,
v: 1,
origin: { kind: 'history-resync' },
projectOps: [{ add: { pathname: 'file1.tex' } }],
pathnames: [],
}),
makeUpdate({ startTs: 0, v: 1 }),
makeUpdate({
startTs: 20,
v: 2,
@ -709,47 +703,13 @@ describe('SummarizedUpdatesManager', function () {
v: 3,
origin: { kind: 'history-resync' },
projectOps: [{ add: { pathname: 'file4.tex' } }],
pathnames: [],
}),
makeUpdate({
startTs: 60,
v: 4,
origin: { kind: 'history-resync' },
projectOps: [],
pathnames: ['file1.tex', 'file2.tex', 'file5.tex'],
}),
makeUpdate({
startTs: 80,
v: 5,
origin: { kind: 'history-resync' },
projectOps: [],
pathnames: ['file4.tex'],
}),
makeUpdate({ startTs: 100, v: 6, pathnames: ['file1.tex'] }),
makeUpdate({ startTs: 60, v: 4 }),
makeUpdate({ startTs: 80, v: 5 }),
],
])
expectSummaries('should merge creates and edits', {}, [
makeSummary({
startTs: 100,
endTs: 110,
fromV: 6,
toV: 7,
pathnames: ['file1.tex'],
}),
makeSummary({
startTs: 0,
endTs: 90,
fromV: 1,
toV: 6,
origin: { kind: 'history-resync' },
pathnames: ['file5.tex'],
projectOps: [
{ add: { pathname: 'file4.tex' }, atV: 3 },
{ add: { pathname: 'file2.tex' }, atV: 2 },
{ add: { pathname: 'file3.tex' }, atV: 2 },
{ add: { pathname: 'file1.tex' }, atV: 1 },
],
}),
expectSummaries('should skip history-resync updates', {}, [
makeSummary({ startTs: 0, endTs: 90, fromV: 1, toV: 6 }),
])
})
})