Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 32355:67026d65a4fc
revlog: rename constants (API)
Feature flag constants don't need "NG" in the name because they will
presumably apply to non-"NG" version revlogs.
All feature flag constants should also share a similar naming
convention to identify them as such.
And, "RevlogNG" isn't a great internal name since it isn't obvious it
maps to version 1 revlogs. Plus, "NG" (next generation) is only a good
name as long as it is the latest version. Since we're talking about
version 2, now is as good a time as any to move on from that naming.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 17 May 2017 19:52:18 -0700 |
parents | 3caec778774b |
children | df448de7cf3b |
comparison
equal
deleted
inserted
replaced
32354:9f35c7836f60 | 32355:67026d65a4fc |
---|---|
43 # Aliased for performance. | 43 # Aliased for performance. |
44 _zlibdecompress = zlib.decompress | 44 _zlibdecompress = zlib.decompress |
45 | 45 |
46 # revlog header flags | 46 # revlog header flags |
47 REVLOGV0 = 0 | 47 REVLOGV0 = 0 |
48 REVLOGNG = 1 | 48 REVLOGV1 = 1 |
49 REVLOGNGINLINEDATA = (1 << 16) | 49 FLAG_INLINE_DATA = (1 << 16) |
50 REVLOGGENERALDELTA = (1 << 17) | 50 FLAG_GENERALDELTA = (1 << 17) |
51 REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDATA | 51 REVLOG_DEFAULT_FLAGS = FLAG_INLINE_DATA |
52 REVLOG_DEFAULT_FORMAT = REVLOGNG | 52 REVLOG_DEFAULT_FORMAT = REVLOGV1 |
53 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS | 53 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS |
54 REVLOGNG_FLAGS = REVLOGNGINLINEDATA | REVLOGGENERALDELTA | 54 REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA |
55 | 55 |
56 # revlog index flags | 56 # revlog index flags |
57 REVIDX_ISCENSORED = (1 << 15) # revision has censor metadata, must be verified | 57 REVIDX_ISCENSORED = (1 << 15) # revision has censor metadata, must be verified |
58 REVIDX_ELLIPSIS = (1 << 14) # revision hash does not match data (narrowhg) | 58 REVIDX_ELLIPSIS = (1 << 14) # revision hash does not match data (narrowhg) |
59 REVIDX_EXTSTORED = (1 << 13) # revision data is stored externally | 59 REVIDX_EXTSTORED = (1 << 13) # revision data is stored externally |
286 v = REVLOG_DEFAULT_VERSION | 286 v = REVLOG_DEFAULT_VERSION |
287 opts = getattr(opener, 'options', None) | 287 opts = getattr(opener, 'options', None) |
288 if opts is not None: | 288 if opts is not None: |
289 if 'revlogv1' in opts: | 289 if 'revlogv1' in opts: |
290 if 'generaldelta' in opts: | 290 if 'generaldelta' in opts: |
291 v |= REVLOGGENERALDELTA | 291 v |= FLAG_GENERALDELTA |
292 else: | 292 else: |
293 v = 0 | 293 v = 0 |
294 if 'chunkcachesize' in opts: | 294 if 'chunkcachesize' in opts: |
295 self._chunkcachesize = opts['chunkcachesize'] | 295 self._chunkcachesize = opts['chunkcachesize'] |
296 if 'maxchainlen' in opts: | 296 if 'maxchainlen' in opts: |
320 except IOError as inst: | 320 except IOError as inst: |
321 if inst.errno != errno.ENOENT: | 321 if inst.errno != errno.ENOENT: |
322 raise | 322 raise |
323 | 323 |
324 self.version = v | 324 self.version = v |
325 self._inline = v & REVLOGNGINLINEDATA | 325 self._inline = v & FLAG_INLINE_DATA |
326 self._generaldelta = v & REVLOGGENERALDELTA | 326 self._generaldelta = v & FLAG_GENERALDELTA |
327 flags = v & ~0xFFFF | 327 flags = v & ~0xFFFF |
328 fmt = v & 0xFFFF | 328 fmt = v & 0xFFFF |
329 if fmt == REVLOGV0 and flags: | 329 if fmt == REVLOGV0 and flags: |
330 raise RevlogError(_("index %s unknown flags %#04x for format v0") | 330 raise RevlogError(_("index %s unknown flags %#04x for format v0") |
331 % (self.indexfile, flags >> 16)) | 331 % (self.indexfile, flags >> 16)) |
332 elif fmt == REVLOGNG and flags & ~REVLOGNG_FLAGS: | 332 elif fmt == REVLOGV1 and flags & ~REVLOGV1_FLAGS: |
333 raise RevlogError(_("index %s unknown flags %#04x for revlogng") | 333 raise RevlogError(_("index %s unknown flags %#04x for revlogng") |
334 % (self.indexfile, flags >> 16)) | 334 % (self.indexfile, flags >> 16)) |
335 elif fmt > REVLOGNG: | 335 elif fmt > REVLOGV1: |
336 raise RevlogError(_("index %s unknown format %d") | 336 raise RevlogError(_("index %s unknown format %d") |
337 % (self.indexfile, fmt)) | 337 % (self.indexfile, fmt)) |
338 | 338 |
339 self.storedeltachains = True | 339 self.storedeltachains = True |
340 | 340 |
1450 finally: | 1450 finally: |
1451 df.close() | 1451 df.close() |
1452 | 1452 |
1453 fp = self.opener(self.indexfile, 'w', atomictemp=True, | 1453 fp = self.opener(self.indexfile, 'w', atomictemp=True, |
1454 checkambig=self._checkambig) | 1454 checkambig=self._checkambig) |
1455 self.version &= ~(REVLOGNGINLINEDATA) | 1455 self.version &= ~FLAG_INLINE_DATA |
1456 self._inline = False | 1456 self._inline = False |
1457 for i in self: | 1457 for i in self: |
1458 e = self._io.packentry(self.index[i], self.node, self.version, i) | 1458 e = self._io.packentry(self.index[i], self.node, self.version, i) |
1459 fp.write(e) | 1459 fp.write(e) |
1460 | 1460 |