Show More
@@ -1004,6 +1004,123 b' class ifilemutationtests(basetestcase):' | |||||
1004 | self.assertEqual(f.node(1), nodes[1]) |
|
1004 | self.assertEqual(f.node(1), nodes[1]) | |
1005 | self.assertEqual(f.node(2), nodes[2]) |
|
1005 | self.assertEqual(f.node(2), nodes[2]) | |
1006 |
|
1006 | |||
|
1007 | def testgetstrippointnoparents(self): | |||
|
1008 | # N revisions where none have parents. | |||
|
1009 | f = self._makefilefn() | |||
|
1010 | ||||
|
1011 | with self._maketransactionfn() as tr: | |||
|
1012 | for rev in range(10): | |||
|
1013 | f.add(b'%d' % rev, None, tr, rev, nullid, nullid) | |||
|
1014 | ||||
|
1015 | for rev in range(10): | |||
|
1016 | self.assertEqual(f.getstrippoint(rev), (rev, set())) | |||
|
1017 | ||||
|
1018 | def testgetstrippointlinear(self): | |||
|
1019 | # N revisions in a linear chain. | |||
|
1020 | f = self._makefilefn() | |||
|
1021 | ||||
|
1022 | with self._maketransactionfn() as tr: | |||
|
1023 | p1 = nullid | |||
|
1024 | ||||
|
1025 | for rev in range(10): | |||
|
1026 | f.add(b'%d' % rev, None, tr, rev, p1, nullid) | |||
|
1027 | ||||
|
1028 | for rev in range(10): | |||
|
1029 | self.assertEqual(f.getstrippoint(rev), (rev, set())) | |||
|
1030 | ||||
|
1031 | def testgetstrippointmultipleheads(self): | |||
|
1032 | f = self._makefilefn() | |||
|
1033 | ||||
|
1034 | with self._maketransactionfn() as tr: | |||
|
1035 | node0 = f.add(b'0', None, tr, 0, nullid, nullid) | |||
|
1036 | node1 = f.add(b'1', None, tr, 1, node0, nullid) | |||
|
1037 | f.add(b'2', None, tr, 2, node1, nullid) | |||
|
1038 | f.add(b'3', None, tr, 3, node0, nullid) | |||
|
1039 | f.add(b'4', None, tr, 4, node0, nullid) | |||
|
1040 | ||||
|
1041 | for rev in range(5): | |||
|
1042 | self.assertEqual(f.getstrippoint(rev), (rev, set())) | |||
|
1043 | ||||
|
1044 | def testgetstrippointearlierlinkrevs(self): | |||
|
1045 | f = self._makefilefn() | |||
|
1046 | ||||
|
1047 | with self._maketransactionfn() as tr: | |||
|
1048 | node0 = f.add(b'0', None, tr, 0, nullid, nullid) | |||
|
1049 | f.add(b'1', None, tr, 10, node0, nullid) | |||
|
1050 | f.add(b'2', None, tr, 5, node0, nullid) | |||
|
1051 | ||||
|
1052 | self.assertEqual(f.getstrippoint(0), (0, set())) | |||
|
1053 | self.assertEqual(f.getstrippoint(1), (1, set())) | |||
|
1054 | self.assertEqual(f.getstrippoint(2), (1, set())) | |||
|
1055 | self.assertEqual(f.getstrippoint(3), (1, set())) | |||
|
1056 | self.assertEqual(f.getstrippoint(4), (1, set())) | |||
|
1057 | self.assertEqual(f.getstrippoint(5), (1, set())) | |||
|
1058 | self.assertEqual(f.getstrippoint(6), (1, {2})) | |||
|
1059 | self.assertEqual(f.getstrippoint(7), (1, {2})) | |||
|
1060 | self.assertEqual(f.getstrippoint(8), (1, {2})) | |||
|
1061 | self.assertEqual(f.getstrippoint(9), (1, {2})) | |||
|
1062 | self.assertEqual(f.getstrippoint(10), (1, {2})) | |||
|
1063 | self.assertEqual(f.getstrippoint(11), (3, set())) | |||
|
1064 | ||||
|
1065 | def teststripempty(self): | |||
|
1066 | f = self._makefilefn() | |||
|
1067 | ||||
|
1068 | with self._maketransactionfn() as tr: | |||
|
1069 | f.strip(0, tr) | |||
|
1070 | ||||
|
1071 | self.assertEqual(len(f), 0) | |||
|
1072 | ||||
|
1073 | def teststripall(self): | |||
|
1074 | f = self._makefilefn() | |||
|
1075 | ||||
|
1076 | with self._maketransactionfn() as tr: | |||
|
1077 | p1 = nullid | |||
|
1078 | for rev in range(10): | |||
|
1079 | p1 = f.add(b'%d' % rev, None, tr, rev, p1, nullid) | |||
|
1080 | ||||
|
1081 | self.assertEqual(len(f), 10) | |||
|
1082 | ||||
|
1083 | with self._maketransactionfn() as tr: | |||
|
1084 | f.strip(0, tr) | |||
|
1085 | ||||
|
1086 | self.assertEqual(len(f), 0) | |||
|
1087 | ||||
|
1088 | def teststrippartial(self): | |||
|
1089 | f = self._makefilefn() | |||
|
1090 | ||||
|
1091 | with self._maketransactionfn() as tr: | |||
|
1092 | f.add(b'0', None, tr, 0, nullid, nullid) | |||
|
1093 | node1 = f.add(b'1', None, tr, 5, nullid, nullid) | |||
|
1094 | node2 = f.add(b'2', None, tr, 10, nullid, nullid) | |||
|
1095 | ||||
|
1096 | self.assertEqual(len(f), 3) | |||
|
1097 | ||||
|
1098 | with self._maketransactionfn() as tr: | |||
|
1099 | f.strip(11, tr) | |||
|
1100 | ||||
|
1101 | self.assertEqual(len(f), 3) | |||
|
1102 | ||||
|
1103 | with self._maketransactionfn() as tr: | |||
|
1104 | f.strip(10, tr) | |||
|
1105 | ||||
|
1106 | self.assertEqual(len(f), 2) | |||
|
1107 | ||||
|
1108 | with self.assertRaises(error.LookupError): | |||
|
1109 | f.rev(node2) | |||
|
1110 | ||||
|
1111 | with self._maketransactionfn() as tr: | |||
|
1112 | f.strip(6, tr) | |||
|
1113 | ||||
|
1114 | self.assertEqual(len(f), 2) | |||
|
1115 | ||||
|
1116 | with self._maketransactionfn() as tr: | |||
|
1117 | f.strip(3, tr) | |||
|
1118 | ||||
|
1119 | self.assertEqual(len(f), 1) | |||
|
1120 | ||||
|
1121 | with self.assertRaises(error.LookupError): | |||
|
1122 | f.rev(node1) | |||
|
1123 | ||||
1007 | def makeifileindextests(makefilefn, maketransactionfn): |
|
1124 | def makeifileindextests(makefilefn, maketransactionfn): | |
1008 | """Create a unittest.TestCase class suitable for testing file storage. |
|
1125 | """Create a unittest.TestCase class suitable for testing file storage. | |
1009 |
|
1126 |
General Comments 0
You need to be logged in to leave comments.
Login now