aboutsummaryrefslogtreecommitdiffstats
path: root/cache
diff options
context:
space:
mode:
Diffstat (limited to 'cache')
-rw-r--r--cache/bug_cache.go4
-rw-r--r--cache/bug_excerpt.go2
-rw-r--r--cache/repo_cache.go2
-rw-r--r--cache/repo_cache_bug.go2
-rw-r--r--cache/repo_cache_common.go15
-rw-r--r--cache/repo_cache_test.go4
6 files changed, 18 insertions, 11 deletions
diff --git a/cache/bug_cache.go b/cache/bug_cache.go
index ca526f7b..bbe9830f 100644
--- a/cache/bug_cache.go
+++ b/cache/bug_cache.go
@@ -51,9 +51,7 @@ func (c *BugCache) ResolveOperationWithMetadata(key string, value string) (entit
// preallocate but empty
matching := make([]entity.Id, 0, 5)
- it := bug.NewOperationIterator(c.bug)
- for it.Next() {
- op := it.Value()
+ for _, op := range c.bug.Operations() {
opValue, ok := op.GetMetadata(key)
if ok && value == opValue {
matching = append(matching, op.Id())
diff --git a/cache/bug_excerpt.go b/cache/bug_excerpt.go
index 6a9e7f75..152bdacf 100644
--- a/cache/bug_excerpt.go
+++ b/cache/bug_excerpt.go
@@ -87,7 +87,7 @@ func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt {
}
switch snap.Author.(type) {
- case *identity.Identity, *IdentityCache:
+ case *identity.Identity, *identity.IdentityStub, *IdentityCache:
e.AuthorId = snap.Author.Id()
default:
panic("unhandled identity type")
diff --git a/cache/repo_cache.go b/cache/repo_cache.go
index ab3e1bcb..58022bda 100644
--- a/cache/repo_cache.go
+++ b/cache/repo_cache.go
@@ -195,7 +195,7 @@ func (c *RepoCache) buildCache() error {
c.bugExcerpts = make(map[entity.Id]*BugExcerpt)
- allBugs := bug.ReadAllLocal(c.repo)
+ allBugs := bug.ReadAll(c.repo)
// wipe the index just to be sure
err := c.repo.ClearBleveIndex("bug")
diff --git a/cache/repo_cache_bug.go b/cache/repo_cache_bug.go
index 9f011c04..c05f30cf 100644
--- a/cache/repo_cache_bug.go
+++ b/cache/repo_cache_bug.go
@@ -151,7 +151,7 @@ func (c *RepoCache) ResolveBug(id entity.Id) (*BugCache, error) {
}
c.muBug.RUnlock()
- b, err := bug.ReadLocalWithResolver(c.repo, newIdentityCacheResolver(c), id)
+ b, err := bug.ReadWithResolver(c.repo, newIdentityCacheResolver(c), id)
if err != nil {
return nil, err
}
diff --git a/cache/repo_cache_common.go b/cache/repo_cache_common.go
index 5dc19d22..e23315f9 100644
--- a/cache/repo_cache_common.go
+++ b/cache/repo_cache_common.go
@@ -95,6 +95,12 @@ func (c *RepoCache) MergeAll(remote string) <-chan entity.MergeResult {
go func() {
defer close(out)
+ author, err := c.GetUserIdentity()
+ if err != nil {
+ out <- entity.NewMergeError(err, "")
+ return
+ }
+
results := identity.MergeAll(c.repo, remote)
for result := range results {
out <- result
@@ -112,7 +118,7 @@ func (c *RepoCache) MergeAll(remote string) <-chan entity.MergeResult {
}
}
- results = bug.MergeAll(c.repo, remote)
+ results = bug.MergeAll(c.repo, remote, author)
for result := range results {
out <- result
@@ -130,11 +136,10 @@ func (c *RepoCache) MergeAll(remote string) <-chan entity.MergeResult {
}
}
- err := c.write()
-
- // No easy way out here ..
+ err = c.write()
if err != nil {
- panic(err)
+ out <- entity.NewMergeError(err, "")
+ return
}
}()
diff --git a/cache/repo_cache_test.go b/cache/repo_cache_test.go
index 9cdd584d..a85fde66 100644
--- a/cache/repo_cache_test.go
+++ b/cache/repo_cache_test.go
@@ -123,6 +123,10 @@ func TestPushPull(t *testing.T) {
require.NoError(t, err)
err = cacheA.SetUserIdentity(reneA)
require.NoError(t, err)
+ isaacB, err := cacheB.NewIdentity("Isaac Newton", "isaac@newton.uk")
+ require.NoError(t, err)
+ err = cacheB.SetUserIdentity(isaacB)
+ require.NoError(t, err)
// distribute the identity
_, err = cacheA.Push("origin")