This commit is contained in:
Alex Yatskov 2015-05-28 19:10:16 +09:00
parent 55d6408a17
commit a4d81518d6
3 changed files with 14 additions and 14 deletions

View File

@ -81,7 +81,7 @@ func (this *database) buildVersions(base string) ([]*version, error) {
return nil, err return nil, err
} }
var parent *version var prev *version
var vers []*version var vers []*version
for _, node := range nodes { for _, node := range nodes {
@ -94,17 +94,17 @@ func (this *database) buildVersions(base string) ([]*version, error) {
return nil, err return nil, err
} }
ver, err := newVersion(path.Join(base, node.Name()), timestamp, parent) ver, err := newVersion(path.Join(base, node.Name()), timestamp, prev)
if err != nil { if err != nil {
return nil, err return nil, err
} }
vers = append(vers, ver) vers = append(vers, ver)
parent = ver prev = ver
} }
for _, ver := range vers { for _, ver := range vers {
ver.terminus = vers[len(vers)-1] ver.last = vers[len(vers)-1]
} }
return vers, nil return vers, nil

View File

@ -37,7 +37,7 @@ type versionedNode struct {
path string path string
info os.FileInfo info os.FileInfo
parent *versionedNode parent *versionedNode
shadow *versionedNode prev *versionedNode
ver *version ver *version
} }
@ -114,11 +114,11 @@ func (this *versionedNode) rebasedPath() string {
} }
func (this *versionedNode) rebasedTermPath() string { func (this *versionedNode) rebasedTermPath() string {
if this.ver.terminus == nil { if this.ver.last == nil {
return this.rebasedPath() return this.rebasedPath()
} }
return this.ver.terminus.rebasePath(this.path) return this.ver.last.rebasePath(this.path)
} }
func (this *versionedNode) owner() (gid, uid uint32) { func (this *versionedNode) owner() (gid, uid uint32) {

View File

@ -42,14 +42,14 @@ import (
type version struct { type version struct {
base string base string
parent *version prev *version
terminus *version last *version
timestamp time.Time timestamp time.Time
meta *versionMetadata meta *versionMetadata
root *versionedDir root *versionedDir
} }
func newVersion(base string, timestamp time.Time, parent *version) (*version, error) { func newVersion(base string, timestamp time.Time, prev *version) (*version, error) {
meta, err := newVersionMetadata(filepath.Join(base, "meta.json")) meta, err := newVersionMetadata(filepath.Join(base, "meta.json"))
if err != nil { if err != nil {
return nil, err return nil, err
@ -57,7 +57,7 @@ func newVersion(base string, timestamp time.Time, parent *version) (*version, er
ver := &version{ ver := &version{
base: base, base: base,
parent: parent, prev: prev,
timestamp: timestamp, timestamp: timestamp,
meta: meta} meta: meta}
@ -66,10 +66,10 @@ func newVersion(base string, timestamp time.Time, parent *version) (*version, er
func (this *version) scanNode(node *versionedNode) (versionedNodeMap, error) { func (this *version) scanNode(node *versionedNode) (versionedNodeMap, error) {
var baseNodes versionedNodeMap var baseNodes versionedNodeMap
if this.parent != nil { if this.prev != nil {
var err error var err error
baseNodes, err = this.parent.scanNode(node) baseNodes, err = this.prev.scanNode(node)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -100,7 +100,7 @@ func (this *version) scanNode(node *versionedNode) (versionedNodeMap, error) {
} }
for ownName, ownNode := range ownNodes { for ownName, ownNode := range ownNodes {
ownNode.shadow = baseNodes[ownName] ownNode.prev = baseNodes[ownName]
baseNodes[ownName] = ownNode baseNodes[ownName] = ownNode
} }