Beispiel #1
0
 def commit(self, msg):
     commit = Commit(self.repository)
     commit.parent = self.parent
     commit.changelog = self.changelog
     commit.schema = self.schema
     commit.msg = msg
     commit.commit_id = hashlib.sha1(json.dumps(commit.toDict())).hexdigest()
     commit.checkedout = True
     self.repository.commits[commit.commit_id] = commit.toDict()
     self.repository.checkouts[commit.commit_id] = commit
     self.repository.branches[self.name] = commit.commit_id
     self.parent = commit
     self.reset()
Beispiel #2
0
 def commit(self, branch_name, changes, msg):
     """Commit the given changes to the given branch_name"""
     old_commit = self.checkout_branch(branch_name)
     for change in changes:
         old_commit.schema.verify(change)
     
     new_commit = Commit()
     new_commit.msg = msg
     new_commit.parent = old_commit
     new_commit.schema = copy.deepcopy(old_commit.schema)
     for change in changes:
         change = new_commit.schema.make_change_reversible(change)
         change_id = hashlib.sha1(json.dumps(change)).hexdigest()
         self.changes[change_id] = change
         new_commit.schema.add(change)
         new_commit.changelog.append(change_id)
         
     new_commit_dict = new_commit.to_dict()
     new_commit_id = hashlib.sha1(json.dumps(new_commit_dict)).hexdigest()
     self.commits[new_commit_id] = new_commit_dict
     self.branches[branch_name] = new_commit_id
Beispiel #3
0
 def checkout_commit(self, commit_id):
     commit = Commit()
     
     try:
         commit_dict = self.commits[commit_id]
     except KeyError:
         raise CommitNotFound("Could not find the commit %s" % commit_id)
     
     commit.commit_id = commit_id
     commit.msg = commit_dict['msg']
     commit.changelog = commit_dict['changelog']
     
     if 'parent' in commit_dict:
         commit.parent = self.checkout_commit(commit_dict['parent'])
         commit.schema = copy.deepcopy(commit.parent.schema)
     else:
         commit.parent = None
         commit.schema = Schema()
     
     for change_id in commit.changelog:
         change = self.changes[change_id]
         commit.schema.add(change)
     
     return commit