Logo Search packages:      
Sourcecode: tailor version File versions  Download package

def vcpx::statefile::StateFile::finalize (   self  ) 

If there is a journal file, adjust the archive accordingly,
dropping already applied changesets.

Definition at line 166 of file statefile.py.

00166                       :
        """
        If there is a journal file, adjust the archive accordingly,
        dropping already applied changesets.
        """

        from os.path import exists
        from os import unlink, rename

        previous = signal(SIGINT, SIG_IGN)
        try:
            if self.archive is not None:
                self.archive.close()
                self.archive = None

            if exists(self.filename + '.journal'):
                self.log.debug('Adjusting the state accordingly to journal')
                # Load last applied changeset from the journal
                journal = open(self.filename + '.journal')
                last_applied = load(journal)
                journal.close()

                # If there is an actual archive (ie, this is not
                # bootstrap time) load the changesets from there,
                # skipping the changesets until the last_applied one,
                # then transfer the remaining to the new archive.
                if exists(self.filename):
                    old = open(self.filename)
                    load(old) # last applied
                    load(old) # dummy queuelen
                    try:
                        cs = load(old)
                        # Skip already applied changesets
                        while cs <> last_applied:
                            cs = load(old)
                    except EOFError:
                        cs = None
                    sf = open(self.filename + '.new', 'w')
                    dump(last_applied, sf)
                    dump(None, sf)
                    if cs is not None:
                        count = 0
                        while True:
                            try:
                                cs = load(old)
                            except EOFError:
                                break
                            dump(cs, sf)
                            count += 1
                        self.log.info('%d pending changesets in state file',
                                       count)
                    sf.close()
                    old.close()

                    oldname = self.filename + '.old'
                    if exists(oldname):
                        unlink(oldname)
                    rename(self.filename, oldname)
                    rename(sf.name, self.filename)
                else:
                    sf = open(self.filename, 'w')
                    dump(last_applied, sf)
                    dump(None, sf)
                    sf.close()

                unlink(journal.name)
        finally:
            signal(SIGINT, previous)

    def lastAppliedChangeset(self):


Generated by  Doxygen 1.6.0   Back to index