Show More
@@ -613,14 +613,33 b' class revlog(object):' | |||
|
613 | 613 | engine = util.compengines[self._compengine] |
|
614 | 614 | return engine.revlogcompressor(self._compengineopts) |
|
615 | 615 | |
|
616 |
def _indexfp(self |
|
|
616 | def _indexfp(self): | |
|
617 | 617 | """file object for the revlog's index file""" |
|
618 | args = {'mode': mode} | |
|
619 | if mode != b'r': | |
|
620 | args['checkambig'] = self._checkambig | |
|
621 | if mode == b'w': | |
|
622 | args['atomictemp'] = True | |
|
623 | return self.opener(self._indexfile, **args) | |
|
618 | return self.opener(self._indexfile, mode=b"r") | |
|
619 | ||
|
620 | def __index_write_fp(self): | |
|
621 | # You should not use this directly and use `_writing` instead | |
|
622 | try: | |
|
623 | f = self.opener( | |
|
624 | self._indexfile, mode=b"r+", checkambig=self._checkambig | |
|
625 | ) | |
|
626 | f.seek(0, os.SEEK_END) | |
|
627 | return f | |
|
628 | except IOError as inst: | |
|
629 | if inst.errno != errno.ENOENT: | |
|
630 | raise | |
|
631 | return self.opener( | |
|
632 | self._indexfile, mode=b"w+", checkambig=self._checkambig | |
|
633 | ) | |
|
634 | ||
|
635 | def __index_new_fp(self): | |
|
636 | # You should not use this unless you are upgrading from inline revlog | |
|
637 | return self.opener( | |
|
638 | self._indexfile, | |
|
639 | mode=b"w", | |
|
640 | checkambig=self._checkambig, | |
|
641 | atomictemp=True, | |
|
642 | ) | |
|
624 | 643 | |
|
625 | 644 | def _datafp(self, mode=b'r'): |
|
626 | 645 | """file object for the revlog's data file""" |
@@ -1990,14 +2009,14 b' class revlog(object):' | |||
|
1990 | 2009 | new_dfh = self._datafp(b'w+') |
|
1991 | 2010 | new_dfh.truncate(0) # drop any potentially existing data |
|
1992 | 2011 | try: |
|
1993 |
with self._indexfp( |
|
|
2012 | with self._indexfp() as read_ifh: | |
|
1994 | 2013 | for r in self: |
|
1995 | 2014 | new_dfh.write(self._getsegmentforrevs(r, r, df=read_ifh)[1]) |
|
1996 | 2015 | if troffset <= self.start(r): |
|
1997 | 2016 | trindex = r |
|
1998 | 2017 | new_dfh.flush() |
|
1999 | 2018 | |
|
2000 |
with self. |
|
|
2019 | with self.__index_new_fp() as fp: | |
|
2001 | 2020 | self._format_flags &= ~FLAG_INLINE_DATA |
|
2002 | 2021 | self._inline = False |
|
2003 | 2022 | for i in self: |
@@ -2016,7 +2035,7 b' class revlog(object):' | |||
|
2016 | 2035 | |
|
2017 | 2036 | if existing_handles: |
|
2018 | 2037 | # switched from inline to conventional reopen the index |
|
2019 |
ifh = self._indexfp( |
|
|
2038 | ifh = self.__index_write_fp() | |
|
2020 | 2039 | self._writinghandles = (ifh, new_dfh) |
|
2021 | 2040 | new_dfh = None |
|
2022 | 2041 | finally: |
@@ -2047,13 +2066,7 b' class revlog(object):' | |||
|
2047 | 2066 | transaction.add(self._datafile, dsize) |
|
2048 | 2067 | try: |
|
2049 | 2068 | isize = r * self.index.entry_size |
|
2050 | try: | |
|
2051 | ifh = self._indexfp(b"r+") | |
|
2052 | ifh.seek(0, os.SEEK_END) | |
|
2053 | except IOError as inst: | |
|
2054 | if inst.errno != errno.ENOENT: | |
|
2055 | raise | |
|
2056 | ifh = self._indexfp(b"w+") | |
|
2069 | ifh = self.__index_write_fp() | |
|
2057 | 2070 | if self._inline: |
|
2058 | 2071 | transaction.add(self._indexfile, dsize + isize) |
|
2059 | 2072 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now