mercurial/appendfile.py
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
Fri, 28 Apr 2006 11:36:33 +0200
changeset 2150 f15c6394d90d
parent 2102 c62112815801
child 2165 d821918e3bee
child 2176 9b42304d9896
permissions -rw-r--r--
fix a NameError in changegroupsubset
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     1
# appendfile.py - special classes to make repo updates atomic
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     2
#
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     3
# Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     4
#
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     6
# of the GNU General Public License, incorporated herein by reference.
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     7
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     8
from demandload import *
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
     9
demandload(globals(), "cStringIO changelog errno manifest os tempfile")
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    10
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    11
# writes to metadata files are ordered.  reads: changelog, manifest,
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    12
# normal files.  writes: normal files, manifest, changelog.
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    13
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    14
# manifest contains pointers to offsets in normal files.  changelog
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    15
# contains pointers to offsets in manifest.  if reader reads old
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    16
# changelog while manifest or normal files are written, it has no
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    17
# pointers into new parts of those files that are maybe not consistent
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    18
# yet, so will not read them.
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    19
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    20
# localrepo.addchangegroup thinks it writes changelog first, then
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    21
# manifest, then normal files (this is order they are available, and
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    22
# needed for computing linkrev fields), but uses appendfile to hide
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    23
# updates from readers.  data not written to manifest or changelog
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    24
# until all normal files updated.  write manifest first, then
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    25
# changelog.
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    26
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    27
# with this write ordering, readers cannot see inconsistent view of
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    28
# repo during update.
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    29
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    30
class appendfile(object):
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    31
    '''implement enough of file protocol to append to revlog file.
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    32
    appended data is written to temp file.  reads and seeks span real
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    33
    file and temp file.  readers cannot see appended data until
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    34
    writedata called.'''
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    35
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    36
    def __init__(self, fp, tmpname):
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    37
        if tmpname:
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    38
            self.tmpname = tmpname
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    39
            self.tmpfp = open(self.tmpname, 'ab+')
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    40
        else:
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    41
            fd, self.tmpname = tempfile.mkstemp()
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    42
            self.tmpfp = os.fdopen(fd, 'ab+')
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    43
        self.realfp = fp
2010
db1eb0de286a fix appendfile problem on macos.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1999
diff changeset
    44
        self.offset = fp.tell()
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    45
        # real file is not written by anyone else. cache its size so
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    46
        # seek and read can be fast.
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    47
        self.realsize = os.fstat(fp.fileno()).st_size
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    48
2075
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    49
    def end(self):
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    50
        self.tmpfp.flush() # make sure the stat is correct
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    51
        return self.realsize + os.fstat(self.tmpfp.fileno()).st_size
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    52
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    53
    def tell(self):
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    54
        return self.offset
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    55
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    56
    def flush(self):
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    57
        self.tmpfp.flush()
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    58
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    59
    def close(self):
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    60
        self.realfp.close()
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    61
        self.tmpfp.close()
2075
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    62
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    63
    def seek(self, offset, whence=0):
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    64
        '''virtual file offset spans real file and temp file.'''
2075
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    65
        if whence == 0:
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    66
            self.offset = offset
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    67
        elif whence == 1:
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    68
            self.offset += offset
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    69
        elif whence == 2:
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    70
            self.offset = self.end() + offset
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
    71
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    72
        if self.offset < self.realsize:
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    73
            self.realfp.seek(self.offset)
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    74
        else:
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    75
            self.tmpfp.seek(self.offset - self.realsize)
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    76
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    77
    def read(self, count=-1):
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    78
        '''only trick here is reads that span real file and temp file.'''
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    79
        fp = cStringIO.StringIO()
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    80
        old_offset = self.offset
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    81
        if self.offset < self.realsize:
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    82
            s = self.realfp.read(count)
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    83
            fp.write(s)
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    84
            self.offset += len(s)
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    85
            if count > 0:
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    86
                count -= len(s)
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    87
        if count != 0:
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    88
            if old_offset != self.offset:
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
    89
                self.tmpfp.seek(self.offset - self.realsize)
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    90
            s = self.tmpfp.read(count)
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    91
            fp.write(s)
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    92
            self.offset += len(s)
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    93
        return fp.getvalue()
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    94
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    95
    def write(self, s):
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    96
        '''append to temp file.'''
2027
94d3170399e1 work around python bug on solaris 10.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2010
diff changeset
    97
        self.tmpfp.seek(0, 2)
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    98
        self.tmpfp.write(s)
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    99
        # all writes are appends, so offset must go to end of file.
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   100
        self.offset = self.realsize + self.tmpfp.tell()
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   101
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   102
class appendopener(object):
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   103
    '''special opener for files that only read or append.'''
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   104
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   105
    def __init__(self, opener):
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   106
        self.realopener = opener
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   107
        # key: file name, value: appendfile name
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   108
        self.tmpnames = {}
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   109
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   110
    def __call__(self, name, mode='r'):
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   111
        '''open file.'''
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   112
2075
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
   113
        assert mode in 'ra+'
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   114
        try:
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   115
            realfp = self.realopener(name, 'r')
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   116
        except IOError, err:
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   117
            if err.errno != errno.ENOENT: raise
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   118
            realfp = self.realopener(name, 'w+')
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   119
        tmpname = self.tmpnames.get(name)
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   120
        fp = appendfile(realfp, tmpname)
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   121
        if tmpname is None:
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   122
            self.tmpnames[name] = fp.tmpname
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   123
        return fp
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   124
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   125
    def writedata(self):
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   126
        '''copy data from temp files to real files.'''
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   127
        # write .d file before .i file.
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   128
        tmpnames = self.tmpnames.items()
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   129
        tmpnames.sort()
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   130
        for name, tmpname in tmpnames:
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   131
            fp = open(tmpname, 'rb')
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   132
            s = fp.read()
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   133
            fp.close()
2102
c62112815801 remove appendfile data as soon as not needed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2089
diff changeset
   134
            os.unlink(tmpname)
2089
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   135
            fp = self.realopener(name, 'a')
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   136
            fp.write(s)
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   137
            fp.close()
cb99c711c59f make appendfile simpler so it does not break with revlogng on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2082
diff changeset
   138
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   139
# files for changelog and manifest are in different appendopeners, so
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   140
# not mixed up together.
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   141
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   142
class appendchangelog(changelog.changelog, appendopener):
2082
856f0ba200bc Additional appendfile fixes for interleaved data/index files
mason@suse.com
parents: 2075
diff changeset
   143
    def __init__(self, opener, version):
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   144
        appendopener.__init__(self, opener)
2082
856f0ba200bc Additional appendfile fixes for interleaved data/index files
mason@suse.com
parents: 2075
diff changeset
   145
        changelog.changelog.__init__(self, self, version)
2075
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
   146
    def checkinlinesize(self, fp, tr):
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
   147
        return
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   148
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   149
class appendmanifest(manifest.manifest, appendopener):
2082
856f0ba200bc Additional appendfile fixes for interleaved data/index files
mason@suse.com
parents: 2075
diff changeset
   150
    def __init__(self, opener, version):
1999
fdb3a72ef664 forgot to add new module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   151
        appendopener.__init__(self, opener)
2082
856f0ba200bc Additional appendfile fixes for interleaved data/index files
mason@suse.com
parents: 2075
diff changeset
   152
        manifest.manifest.__init__(self, self, version)
2075
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
   153
    def checkinlinesize(self, fp, tr):
343aeefb553b Make the appendfile class inline-data index friendly
mason@suse.com
parents: 2027
diff changeset
   154
        return