mercurial/revlog.py
changeset 3679 2956948b81f3
parent 3633 508036290b00
child 3680 69cf255a55a1
equal deleted inserted replaced
3678:7e622c9a9707 3679:2956948b81f3
    28 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
    28 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
    29 
    29 
    30 def flagstr(flag):
    30 def flagstr(flag):
    31     if flag == "inline":
    31     if flag == "inline":
    32         return REVLOGNGINLINEDATA
    32         return REVLOGNGINLINEDATA
    33     raise RevlogError(_("unknown revlog flag %s" % flag))
    33     raise RevlogError(_("unknown revlog flag %s") % flag)
    34 
    34 
    35 def hash(text, p1, p2):
    35 def hash(text, p1, p2):
    36     """generate a hash from the given text and its parent hashes
    36     """generate a hash from the given text and its parent hashes
    37 
    37 
    38     This hash combines both the current file contents and its history
    38     This hash combines both the current file contents and its history
   353                 v = struct.unpack(versionformat, i)[0]
   353                 v = struct.unpack(versionformat, i)[0]
   354         flags = v & ~0xFFFF
   354         flags = v & ~0xFFFF
   355         fmt = v & 0xFFFF
   355         fmt = v & 0xFFFF
   356         if fmt == REVLOGV0:
   356         if fmt == REVLOGV0:
   357             if flags:
   357             if flags:
   358                 raise RevlogError(_("index %s invalid flags %x for format v0" %
   358                 raise RevlogError(_("index %s invalid flags %x for format v0") %
   359                                    (self.indexfile, flags)))
   359                                    (self.indexfile, flags))
   360         elif fmt == REVLOGNG:
   360         elif fmt == REVLOGNG:
   361             if flags & ~REVLOGNGINLINEDATA:
   361             if flags & ~REVLOGNGINLINEDATA:
   362                 raise RevlogError(_("index %s invalid flags %x for revlogng" %
   362                 raise RevlogError(_("index %s invalid flags %x for revlogng") %
   363                                    (self.indexfile, flags)))
   363                                    (self.indexfile, flags))
   364         else:
   364         else:
   365             raise RevlogError(_("index %s invalid format %d" %
   365             raise RevlogError(_("index %s invalid format %d") %
   366                                (self.indexfile, fmt)))
   366                                (self.indexfile, fmt))
   367         self.version = v
   367         self.version = v
   368         if v == REVLOGV0:
   368         if v == REVLOGV0:
   369             self.indexformat = indexformatv0
   369             self.indexformat = indexformatv0
   370             shaoffset = v0shaoffset
   370             shaoffset = v0shaoffset
   371         else:
   371         else:
   929         size = fp.tell()
   929         size = fp.tell()
   930         if size < 131072:
   930         if size < 131072:
   931             return
   931             return
   932         trinfo = tr.find(self.indexfile)
   932         trinfo = tr.find(self.indexfile)
   933         if trinfo == None:
   933         if trinfo == None:
   934             raise RevlogError(_("%s not found in the transaction"  %
   934             raise RevlogError(_("%s not found in the transaction")  %
   935                               self.indexfile))
   935                               self.indexfile)
   936 
   936 
   937         trindex = trinfo[2]
   937         trindex = trinfo[2]
   938         dataoff = self.start(trindex)
   938         dataoff = self.start(trindex)
   939 
   939 
   940         tr.add(self.datafile, dataoff)
   940         tr.add(self.datafile, dataoff)