forked from oyeb/pitstops
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfsystem.py
More file actions
31 lines (25 loc) · 1.16 KB
/
fsystem.py
File metadata and controls
31 lines (25 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os, sys, pickle, commit, branch
class DataStore:
def __init__(self, base):
# base == absolute path to project dir
self.base_dir = os.path.join(base, '.ps')
self.project_dir = base
self.branches_dir = os.path.join(self.base_dir, 'branches')
self.commit_updated = False
self.load_branches()
def get_commits_by_branch(self, branch):
ct_file_path = os.path.join(self.branches_dir, '%s-cm.pkl'%branch)
return commit.load(ct_file_path)
def load_commits_in_all(self):
self.commit_tree = {}
# this is the master commit tree for the repo. No other tree is "stored".
for branch in self.branches:
self.commit_tree.update(self.get_commits_by_branch(branch))
else:
raise RuntimeError("First load all branches, use `Repository.load_branches()`")
def load_branches():
branch_names = os.listdir(self.branches_dir)
self.branches = {}
for branch in branch_names:
info_path = os.path.join(self.branches_dir, os.path.join(branch, '%s-info.pkl'%branch))
self.branches[branch] = branch.BranchInfo.load(info_path)