Stephane Barbarie | 4a2564d | 2018-07-26 11:02:58 -0400 | [diff] [blame] | 1 | package model |
| 2 | |
| 3 | // TODO: implement weak references or something equivalent |
| 4 | // TODO: missing proper logging |
| 5 | |
| 6 | type Branch struct { |
| 7 | node *Node |
| 8 | Txid string |
| 9 | origin *Revision |
| 10 | revisions map[string]*Revision |
| 11 | Latest *Revision |
| 12 | } |
| 13 | |
| 14 | func 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 |
| 26 | func (cb *Branch) get(hash string) *Revision { |
| 27 | return cb.revisions[hash] |
| 28 | } |
| 29 | func (cb *Branch) GetLatest() *Revision { |
| 30 | return cb.Latest |
| 31 | } |
| 32 | func (cb *Branch) GetOrigin() *Revision { |
| 33 | return cb.origin |
| 34 | } |