Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 21835:b342c3e2518a
memctx: add _manifest implementation that computes the filenode
This is an initial implementation of having a manifest for memctx that computes
the hash in the same way that filenodes are computed elsewhere.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Thu, 29 May 2014 16:12:59 -0500 |
parents | e4d35aa9056c |
children | 7cfd94ec5d30 |
comparison
equal
deleted
inserted
replaced
21834:e4d35aa9056c | 21835:b342c3e2518a |
---|---|
11 import match as matchmod | 11 import match as matchmod |
12 import os, errno, stat | 12 import os, errno, stat |
13 import obsolete as obsmod | 13 import obsolete as obsmod |
14 import repoview | 14 import repoview |
15 import fileset | 15 import fileset |
16 import revlog | |
16 | 17 |
17 propertycache = util.propertycache | 18 propertycache = util.propertycache |
18 | 19 |
19 class basectx(object): | 20 class basectx(object): |
20 """A basectx object represents the common logic for its children: | 21 """A basectx object represents the common logic for its children: |
1585 | 1586 |
1586 def commit(self): | 1587 def commit(self): |
1587 """commit context to the repo""" | 1588 """commit context to the repo""" |
1588 return self._repo.commitctx(self) | 1589 return self._repo.commitctx(self) |
1589 | 1590 |
1591 @propertycache | |
1592 def _manifest(self): | |
1593 """generate a manifest based on the return values of filectxfn""" | |
1594 | |
1595 # keep this simple for now; just worry about p1 | |
1596 pctx = self._parents[0] | |
1597 man = pctx.manifest().copy() | |
1598 | |
1599 for f, fnode in man.iteritems(): | |
1600 p1node = nullid | |
1601 p2node = nullid | |
1602 p = pctx[f].parents() | |
1603 if len(p) > 0: | |
1604 p1node = p[0].node() | |
1605 if len(p) > 1: | |
1606 p2node = p[1].node() | |
1607 man[f] = revlog.hash(self[f].data(), p1node, p2node) | |
1608 | |
1609 return man | |
1610 | |
1611 | |
1590 class memfilectx(committablefilectx): | 1612 class memfilectx(committablefilectx): |
1591 """memfilectx represents an in-memory file to commit. | 1613 """memfilectx represents an in-memory file to commit. |
1592 | 1614 |
1593 See memctx and commitablefilectx for more details. | 1615 See memctx and commitablefilectx for more details. |
1594 """ | 1616 """ |