Page MenuHomePhabricator

narrow: show repo corruption when commiting empty files
ClosedPublic

Authored by valentin.gatienbaron on Sep 10 2021, 3:13 PM.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Alphare accepted this revision.Sep 13 2021, 6:01 AM
Alphare added a subscriber: Alphare.

In theory we'd use (known-bad-output !) and (missing-correct-output !) where appropriate, but given that you're fixing it in the next change, it does seem overkill to ask you to do so.

This revision is now accepted and ready to land.Sep 13 2021, 6:01 AM
Alphare updated this revision to Diff 30215.Sep 13 2021, 11:35 AM

It seems that this kind of corruption can propagate between clones as well. Sadness.

Ouch, that's unfortunate. Can this be easily checked during an addgroup?

Maybe the server could reject such changes, but I'd rather simply roll clients with the fix.

Separately, it's not exactly the kind of corruption from the test that can propagate, because push would fail in the example of the test.
But if the filelog exists (or presumably, is created afterwards), then the push can succeed. And then hg status when wdir is at such a revision in a non-narrow clone would always report the empty file as being modified.

I doubt someone else cares, but just in case, one can find problematic revisions with this command:

@command(
    b'zzz',
    [
        (b'r', b'rev', b'', _(b'revision to display'), _(b'REV')),
    ],
    intents={INTENT_READONLY},
)
def zzz(ui, repo, **opts):
    """"""
    opts = pycompat.byteskwargs(opts)
    repo = repo.unfiltered()
    revs = scmutil.revrange(repo, [opts.get(b'rev')])
    for r in revs:
        node = repo[r].node()
        mnode = repo[r].manifestnode()
        for (f, fnode) in repo.manifestlog[mnode].readdelta().iteritems():
            if fnode == repo.nullid:
                ui.write(b'%b %b\n' % (hex(node), f))