blob: 8a371570021130e6674470def8e311b344acf1ec [file] [log] [blame]
Stephane Barbarie4a2564d2018-07-26 11:02:58 -04001package model
2
3// TODO: implement weak references or something equivalent
4// TODO: missing proper logging
5
6type Branch struct {
7 node *Node
8 Txid string
9 origin *Revision
10 revisions map[string]*Revision
11 Latest *Revision
12}
13
14func NewBranch(node *Node, txid string, origin *Revision, autoPrune bool) *Branch {
15 cb := &Branch{}
16 cb.node = node
17 cb.Txid = txid
18 cb.origin = origin
19 cb.revisions = make(map[string]*Revision)
20 cb.Latest = origin
21
22 return cb
23}
24
25// TODO: Check if the following are required
26func (cb *Branch) get(hash string) *Revision {
27 return cb.revisions[hash]
28}
29func (cb *Branch) GetLatest() *Revision {
30 return cb.Latest
31}
32func (cb *Branch) GetOrigin() *Revision {
33 return cb.origin
34}