##// END OF EJS Templates
sidedatacopies: write copies information in sidedata when applicable...
marmoute -
r43412:beed7ce6 default
parent child Browse files
Show More
@@ -27,6 +27,8 b' from .utils import ('
27 27 stringutil,
28 28 )
29 29
30 from .revlogutils import sidedata as sidedatamod
31
30 32 _defaultextra = {b'branch': b'default'}
31 33
32 34
@@ -676,6 +678,7 b' class changelog(revlog.revlog):'
676 678 _(b'the name \'%s\' is reserved') % branch
677 679 )
678 680 sortedfiles = sorted(files)
681 sidedata = None
679 682 if extra is not None:
680 683 for name in (
681 684 b'p1copies',
@@ -704,13 +707,25 b' class changelog(revlog.revlog):'
704 707 extra[b'filesadded'] = filesadded
705 708 if filesremoved is not None:
706 709 extra[b'filesremoved'] = filesremoved
710 elif self._copiesstorage == b'changeset-sidedata':
711 sidedata = {}
712 if p1copies is not None:
713 sidedata[sidedatamod.SD_P1COPIES] = p1copies
714 if p2copies is not None:
715 sidedata[sidedatamod.SD_P2COPIES] = p2copies
716 if filesadded is not None:
717 sidedata[sidedatamod.SD_FILESADDED] = filesadded
718 if filesremoved is not None:
719 sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved
707 720
708 721 if extra:
709 722 extra = encodeextra(extra)
710 723 parseddate = b"%s %s" % (parseddate, extra)
711 724 l = [hex(manifest), user, parseddate] + sortedfiles + [b"", desc]
712 725 text = b"\n".join(l)
713 return self.addrevision(text, transaction, len(self), p1, p2)
726 return self.addrevision(
727 text, transaction, len(self), p1, p2, sidedata=sidedata
728 )
714 729
715 730 def branchinfo(self, rev):
716 731 """return the branch name and open/close state of a revision
@@ -1547,6 +1547,10 b' class ilocalrepositorymain(interfaceutil'
1547 1547
1548 1548 names = interfaceutil.Attribute("""A ``namespaces`` instance.""")
1549 1549
1550 filecopiesmode = interfaceutil.Attribute(
1551 """The way files copies should be dealt with in this repo."""
1552 )
1553
1550 1554 def close():
1551 1555 """Close the handle on this repository."""
1552 1556
@@ -825,10 +825,13 b' def resolvestorevfsoptions(ui, requireme'
825 825 else: # explicitly mark repo as using revlogv0
826 826 options[b'revlogv0'] = True
827 827
828 writecopiesto = ui.config(b'experimental', b'copies.write-to')
829 copiesextramode = (b'changeset-only', b'compatibility')
830 if writecopiesto in copiesextramode:
831 options[b'copies-storage'] = b'extra'
828 if COPIESSDC_REQUIREMENT in requirements:
829 options[b'copies-storage'] = b'changeset-sidedata'
830 else:
831 writecopiesto = ui.config(b'experimental', b'copies.write-to')
832 copiesextramode = (b'changeset-only', b'compatibility')
833 if writecopiesto in copiesextramode:
834 options[b'copies-storage'] = b'extra'
832 835
833 836 return options
834 837
@@ -1182,6 +1185,10 b' class localrepository(object):'
1182 1185
1183 1186 self._extrafilterid = repoview.extrafilter(ui)
1184 1187
1188 self.filecopiesmode = None
1189 if COPIESSDC_REQUIREMENT in self.requirements:
1190 self.filecopiesmode = b'changeset-sidedata'
1191
1185 1192 def _getvfsward(self, origfunc):
1186 1193 """build a ward for self.vfs"""
1187 1194 rref = weakref.ref(self)
@@ -2949,12 +2956,17 b' class localrepository(object):'
2949 2956 p1, p2 = ctx.p1(), ctx.p2()
2950 2957 user = ctx.user()
2951 2958
2952 writecopiesto = self.ui.config(b'experimental', b'copies.write-to')
2953 writefilecopymeta = writecopiesto != b'changeset-only'
2954 writechangesetcopy = writecopiesto in (
2955 b'changeset-only',
2956 b'compatibility',
2957 )
2959 if self.filecopiesmode == b'changeset-sidedata':
2960 writechangesetcopy = True
2961 writefilecopymeta = True
2962 writecopiesto = None
2963 else:
2964 writecopiesto = self.ui.config(b'experimental', b'copies.write-to')
2965 writefilecopymeta = writecopiesto != b'changeset-only'
2966 writechangesetcopy = writecopiesto in (
2967 b'changeset-only',
2968 b'compatibility',
2969 )
2958 2970 p1copies, p2copies = None, None
2959 2971 if writechangesetcopy:
2960 2972 p1copies = ctx.p1copies()
@@ -48,6 +48,12 b' SD_TEST5 = 5'
48 48 SD_TEST6 = 6
49 49 SD_TEST7 = 7
50 50
51 # key to store copies related information
52 SD_P1COPIES = 8
53 SD_P2COPIES = 9
54 SD_FILESADDED = 10
55 SD_FILESREMOVED = 11
56
51 57 # internal format constant
52 58 SIDEDATA_HEADER = struct.Struct(r'>H')
53 59 SIDEDATA_ENTRY = struct.Struct(r'>HL20s')
@@ -75,7 +75,17 b' Check that copies are recorded correctly'
75 75 p1copies: 0\x00a (esc)
76 76 1\x00a (esc)
77 77 2\x00a (esc)
78
78 #else
79 $ hg debugsidedata -c -v -- -1
80 4 sidedata entries
81 entry-0010 size 11
82 '0\x00a\n1\x00a\n2\x00a'
83 entry-0011 size 0
84 ''
85 entry-0012 size 5
86 '0\n1\n2'
87 entry-0013 size 0
88 ''
79 89 #endif
80 90
81 91 $ hg showcopies
@@ -107,6 +117,17 b' Check that renames are recorded correctl'
107 117
108 118 p1copies: 1\x00b (esc)
109 119
120 #else
121 $ hg debugsidedata -c -v -- -1
122 4 sidedata entries
123 entry-0010 size 3
124 '1\x00b'
125 entry-0011 size 0
126 ''
127 entry-0012 size 1
128 '1'
129 entry-0013 size 1
130 '0'
110 131 #endif
111 132
112 133 $ hg showcopies
@@ -145,6 +166,17 b' even though there is no filelog entry.'
145 166
146 167 p1copies: 0\x00b2 (esc)
147 168
169 #else
170 $ hg debugsidedata -c -v -- -1
171 4 sidedata entries
172 entry-0010 size 4
173 '0\x00b2'
174 entry-0011 size 0
175 ''
176 entry-0012 size 0
177 ''
178 entry-0013 size 0
179 ''
148 180 #endif
149 181
150 182 $ hg showcopies
@@ -197,6 +229,17 b" File 'f' exists only in p1, so 'i' shoul"
197 229 2\x00f (esc)
198 230 p2copies: 1\x00d (esc)
199 231
232 #else
233 $ hg debugsidedata -c -v -- -1
234 4 sidedata entries
235 entry-0010 size 7
236 '0\x00a\n2\x00f'
237 entry-0011 size 3
238 '1\x00d'
239 entry-0012 size 5
240 '0\n1\n2'
241 entry-0013 size 0
242 ''
200 243 #endif
201 244
202 245 $ hg showcopies
@@ -218,6 +261,16 b' Test writing to both changeset and filel'
218 261 p2copies:
219 262 #else
220 263 $ hg ci -m 'copy a to j'
264 $ hg debugsidedata -c -v -- -1
265 4 sidedata entries
266 entry-0010 size 3
267 '0\x00a'
268 entry-0011 size 0
269 ''
270 entry-0012 size 1
271 '0'
272 entry-0013 size 0
273 ''
221 274 #endif
222 275 $ hg debugdata j 0
223 276 \x01 (esc)
@@ -243,6 +296,16 b' copy information on to the filelog'
243 296 #else
244 297 $ hg ci --amend -m 'copy a to j, v2'
245 298 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
299 $ hg debugsidedata -c -v -- -1
300 4 sidedata entries
301 entry-0010 size 3
302 '0\x00a'
303 entry-0011 size 0
304 ''
305 entry-0012 size 1
306 '0'
307 entry-0013 size 0
308 ''
246 309 #endif
247 310 $ hg showcopies --config experimental.copies.read-from=filelog-only
248 311 a -> j
@@ -260,6 +323,16 b" won't have to fall back to reading from "
260 323 p2copies:
261 324 #else
262 325 $ hg ci -m 'modify j'
326 $ hg debugsidedata -c -v -- -1
327 4 sidedata entries
328 entry-0010 size 0
329 ''
330 entry-0011 size 0
331 ''
332 entry-0012 size 0
333 ''
334 entry-0013 size 0
335 ''
263 336 #endif
264 337
265 338 Test writing only to filelog
@@ -273,6 +346,16 b' Test writing only to filelog'
273 346
274 347 #else
275 348 $ hg ci -m 'copy a to k'
349 $ hg debugsidedata -c -v -- -1
350 4 sidedata entries
351 entry-0010 size 3
352 '0\x00a'
353 entry-0011 size 0
354 ''
355 entry-0012 size 1
356 '0'
357 entry-0013 size 0
358 ''
276 359 #endif
277 360
278 361 $ hg debugdata k 0
General Comments 0
You need to be logged in to leave comments. Login now