Exemplo n.º 1
0
    def _insert_snapshot(self, obj_hash, message='', user='', branch=None):
        """Updates snapshots database with snapshot data"""
        if branch is None:
            branch = self.current_branch()
        data = {
            'hash': obj_hash,
            'branch': branch,
            'message': message,
            'user': user,
        }

        ssdb.execute(self.FILES['snapshots'], ssdb.INSERT, data, commit=True)
Exemplo n.º 2
0
    def create_repo(self):
        """Create a new repository directory in the root location"""
        # Create all directories
        for rel_dir in self.DIRS.values():
            os.makedirs(self._join_root(rel_dir), exist_ok=True)

        # Make the new version control folder hidden
        ctypes.windll.kernel32.SetFileAttributesW(
            self._join_root(self.REPO_DIR), 0x02
        )

        # Create HEAD file and set branch to the default name
        self._set_branch(self.DEFAULT_BRANCH)

        # Create objhashcache file and set as empty
        self._save_objhashcache()

        # Create the snapshots database
        ssdb.execute(self.FILES['snapshots'], ssdb.CREATE)
Exemplo n.º 3
0
 def list_snapshots(self):
     """Return a list of sqlite.Row objects for each snapshot"""
     return ssdb.execute(
         self.FILES['snapshots'], ssdb.SELECT,
         row_factory=ssdb.Row, cursor='fetchall'
     )