Mercurial > hg
comparison mercurial/copies.py @ 30360:0298a07f64d9
dirstate: change placeholder hash length to 20 bytes
Previously the new-node placeholder hash for manifests generated from the
dirstate was a 21byte long string of "!" characters. Normal hashes are only 20
bytes long. This makes it complicated to implement more efficient manifest
implementations which rely on the hashes being fixed length.
Let's change this hash to just be 20 bytes long, and rely on the astronomical
improbability of an actual hash being 20 "!" bytes in a row (just like we rely
on no hash ever being the nullid).
A future diff will do this for added and modified dirstate markers as well, so
we're putting the new newnodeid in node.py so there's a common place for these
placeholders.
author | Durham Goode <durham@fb.com> |
---|---|
date | Thu, 10 Nov 2016 02:17:22 -0800 |
parents | 69ffbbe73dd0 |
children | 1070df141718 |
comparison
equal
deleted
inserted
replaced
30359:673f0fdc1046 | 30360:0298a07f64d9 |
---|---|
276 if rev is None: | 276 if rev is None: |
277 revs = [p.rev() for p in ctx.parents()] | 277 revs = [p.rev() for p in ctx.parents()] |
278 ac = repo.changelog.ancestors(revs, inclusive=True) | 278 ac = repo.changelog.ancestors(revs, inclusive=True) |
279 ctx._ancestrycontext = ac | 279 ctx._ancestrycontext = ac |
280 def makectx(f, n): | 280 def makectx(f, n): |
281 if len(n) != 20: # in a working context? | 281 if len(n) != 20 or n in node.wdirnodes: # in a working context? |
282 if ctx.rev() is None: | 282 if ctx.rev() is None: |
283 return ctx.filectx(f) | 283 return ctx.filectx(f) |
284 return repo[None][f] | 284 return repo[None][f] |
285 fctx = repo.filectx(f, fileid=n) | 285 fctx = repo.filectx(f, fileid=n) |
286 # setup only needed for filectx not create from a changectx | 286 # setup only needed for filectx not create from a changectx |