Ejemplo n.º 1
0
    def cleanup_history(self):
        """Remove the older revision histories for self"""
        if not self.rcs_dir:
            return

        max_days = Preference("Plugins/local_history/maxdays").get()
        older = datetime.datetime.now() - datetime.timedelta(days=max_days)
        older = older.strftime("%Y.%m.%d.%H.%M.%S")

        revisions = self.get_revisions()
        max_revisions = Preference("Plugins/local_history/maxrevisions").get()
        if revisions:
            version = max(0, revisions[0][0] - max_revisions)
            for r in revisions:
                if r[1] < older:
                    version = max(version, r[0])
                    break

            if version >= 1:
                Logger("LocalHist").log("Truncating file %s to revision %s" %
                                        (self.rcs_file, version))
                proc = Process("rcs -o:1.%s %s" % (version, self.rcs_file))
                proc.wait()
Ejemplo n.º 2
0
    def local_checkout(self, revision):
        """Do a local checkout of file at given revision in the RCS directory.
           Return the name of the checked out file"""
        if self.rcs_dir and os.path.isdir(self.rcs_dir):
            try:
                os.unlink(os.path.join(self.rcs_dir,
                                       os.path.basename(self.file)))
            except Exception:
                pass

            pwd = os.getcwd()
            os.chdir(self.rcs_dir)
            proc = Process("co -r" + revision + " " + self.rcs_file)
            os.chdir(pwd)
            if proc.wait() == 0:
                return os.path.join(self.rcs_dir, os.path.basename(self.file))
        return None