Mercurial > public > mercurial-scm > hg
comparison mercurial/verify.py @ 31761:b044c339c06d
verify: document corner cases
It seems a good idea to list all kinds of "surprises" and expected behavior
to make the upcoming changes easier to understand.
Note: the comment added does not reflect the actual behavior of the current
code.
author | Jun Wu <quark@fb.com> |
---|---|
date | Wed, 29 Mar 2017 14:45:01 -0700 |
parents | 5249b6470de9 |
children | dff03f68ef11 |
comparison
equal
deleted
inserted
replaced
31758:04ec317b8128 | 31761:b044c339c06d |
---|---|
377 if havemf and n not in filenodes[f]: | 377 if havemf and n not in filenodes[f]: |
378 self.err(lr, _("%s not in manifests") % (short(n)), f) | 378 self.err(lr, _("%s not in manifests") % (short(n)), f) |
379 else: | 379 else: |
380 del filenodes[f][n] | 380 del filenodes[f][n] |
381 | 381 |
382 # verify contents | 382 # Verify contents. 4 cases to care about: |
383 # | |
384 # common: the most common case | |
385 # rename: with a rename | |
386 # meta: file content starts with b'\1\n', the metadata | |
387 # header defined in filelog.py, but without a rename | |
388 # ext: content stored externally | |
389 # | |
390 # More formally, their differences are shown below: | |
391 # | |
392 # | common | rename | meta | ext | |
393 # ------------------------------------------------------- | |
394 # flags() | 0 | 0 | 0 | not 0 | |
395 # renamed() | False | True | False | ? | |
396 # rawtext[0:2]=='\1\n'| False | True | True | ? | |
397 # | |
398 # "rawtext" means the raw text stored in revlog data, which | |
399 # could be retrieved by "revision(rev, raw=True)". "text" | |
400 # mentioned below is "revision(rev, raw=False)". | |
401 # | |
402 # There are 3 different lengths stored physically: | |
403 # 1. L1: rawsize, stored in revlog index | |
404 # 2. L2: len(rawtext), stored in revlog data | |
405 # 3. L3: len(text), stored in revlog data if flags==0, or | |
406 # possibly somewhere else if flags!=0 | |
407 # | |
408 # L1 should be equal to L2. L3 could be different from them. | |
409 # "text" may or may not affect commit hash depending on flag | |
410 # processors (see revlog.addflagprocessor). | |
411 # | |
412 # | common | rename | meta | ext | |
413 # ------------------------------------------------- | |
414 # rawsize() | L1 | L1 | L1 | L1 | |
415 # size() | L1 | L2-LM | L1(*) | L1 (?) | |
416 # len(rawtext) | L2 | L2 | L2 | L2 | |
417 # len(text) | L2 | L2 | L2 | L3 | |
418 # len(read()) | L2 | L2-LM | L2-LM | L3 (?) | |
419 # | |
420 # LM: length of metadata, depending on rawtext | |
421 # (*): not ideal, see comment in filelog.size | |
422 # (?): could be "- len(meta)" if the resolved content has | |
423 # rename metadata | |
424 # | |
425 # Checks needed to be done: | |
426 # 1. length check: L1 == L2, in all cases. | |
427 # 2. hash check: depending on flag processor, we may need to | |
428 # use either "text" (external), or "rawtext" (in revlog). | |
383 try: | 429 try: |
384 l = len(fl.read(n)) | 430 l = len(fl.read(n)) |
385 rp = fl.renamed(n) | 431 rp = fl.renamed(n) |
386 if l != fl.size(i): | 432 if l != fl.size(i): |
387 if len(fl.revision(n)) != fl.size(i): | 433 if len(fl.revision(n)) != fl.size(i): |