Mercurial > public > mercurial-scm > hg
comparison mercurial/testing/storage.py @ 40047:8e398628a3f2
repository: define and use revision flag constants
Revlogs have a per-revision 2 byte field holding integer flags that
define how revision data should be interpreted. For historical reasons,
these integer values are sent verbatim on the wire protocol as part of
changegroup data.
From a semantic standpoint, the flags that go out over the wire are
different from the flags stored internally by revlogs. Failure to
establish this semantic distinction creates unwanted strong coupling
between revlog's internals and the wire protocol.
This commit establishes new constants on the repository module that
define the revision flags used by the wire protocol (and by some
internal storage APIs, sadly). The changegroups internals documentation
has been updated to document them explicitly. Various references
throughout the repo now use the repository constants instead of the
revlog constants. This is done to make it clear that we're operating
on generic revision data and this isn't tied to revlogs.
Differential Revision: https://phab.mercurial-scm.org/D4860
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 03 Oct 2018 12:57:01 -0700 |
parents | ad8389ecd3f5 |
children | 8e136940c0e6 |
comparison
equal
deleted
inserted
replaced
40046:50700a025953 | 40047:8e398628a3f2 |
---|---|
15 nullrev, | 15 nullrev, |
16 ) | 16 ) |
17 from .. import ( | 17 from .. import ( |
18 error, | 18 error, |
19 mdiff, | 19 mdiff, |
20 revlog, | 20 repository, |
21 ) | 21 ) |
22 from ..utils import ( | 22 from ..utils import ( |
23 storageutil, | 23 storageutil, |
24 ) | 24 ) |
25 | 25 |
872 # different due to presence of censor metadata. But we can't | 872 # different due to presence of censor metadata. But we can't |
873 # do this with addrevision(). | 873 # do this with addrevision(). |
874 with self._maketransactionfn() as tr: | 874 with self._maketransactionfn() as tr: |
875 node0 = f.add(b'foo', None, tr, 0, nullid, nullid) | 875 node0 = f.add(b'foo', None, tr, 0, nullid, nullid) |
876 f.addrevision(stored1, tr, 1, node0, nullid, | 876 f.addrevision(stored1, tr, 1, node0, nullid, |
877 flags=revlog.REVIDX_ISCENSORED) | 877 flags=repository.REVISION_FLAG_CENSORED) |
878 | 878 |
879 self.assertTrue(f.iscensored(1)) | 879 self.assertTrue(f.iscensored(1)) |
880 | 880 |
881 self.assertEqual(f.revision(1), stored1) | 881 self.assertEqual(f.revision(1), stored1) |
882 self.assertEqual(f.revision(1, raw=True), stored1) | 882 self.assertEqual(f.revision(1, raw=True), stored1) |
912 | 912 |
913 def testaddrevisionunknownflag(self): | 913 def testaddrevisionunknownflag(self): |
914 f = self._makefilefn() | 914 f = self._makefilefn() |
915 with self._maketransactionfn() as tr: | 915 with self._maketransactionfn() as tr: |
916 for i in range(15, 0, -1): | 916 for i in range(15, 0, -1): |
917 if (1 << i) & ~revlog.REVIDX_KNOWN_FLAGS: | 917 if (1 << i) & ~repository.REVISION_FLAGS_KNOWN: |
918 flags = 1 << i | 918 flags = 1 << i |
919 break | 919 break |
920 | 920 |
921 with self.assertRaises(error.StorageError): | 921 with self.assertRaises(error.StorageError): |
922 f.addrevision(b'foo', tr, 0, nullid, nullid, flags=flags) | 922 f.addrevision(b'foo', tr, 0, nullid, nullid, flags=flags) |