Skip to content

Commit

Permalink
Fix hgCat emitting an event that all files changed and only emit an e…
Browse files Browse the repository at this point in the history
…vent for a single file. This fixes tests for showing tags in the short-head.
  • Loading branch information
Goodwine committed Mar 25, 2017
1 parent 5c36609 commit 105366b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions lib/hg-repository.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,12 @@ class HgRepository
getCachedHgFileContent: (path) =>
slashedPath = @slashPath(path)

@repo.getHgCatAsync(path).then (contents) =>
statusesDidChange = @cachedHgFileContent[slashedPath] != contents
@cachedHgFileContent[slashedPath] = contents
if statusesDidChange then @emitter.emit 'did-change-statuses'

if (!@cachedHgFileContent[slashedPath])
return null
@repo.getHgCatAsync(path).then (contents) =>
contentsChanged = @cachedHgFileContent[slashedPath] != contents
@cachedHgFileContent[slashedPath] = contents
@getPathStatus path if contentsChanged

return @cachedHgFileContent[slashedPath]

# Public: Retrieves the number of lines added and removed to a path.
Expand Down
8 changes: 4 additions & 4 deletions test/simple_repo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe 'In a repo with some ignored files', ->
deleted: 0
assert.deepEqual(repo.getDiffStats(modifiedFilePath), expected)

repo.onDidChangeStatuses () ->
repo.onDidChangeStatus ->
expected =
added: 2
deleted: 0
Expand Down Expand Up @@ -162,12 +162,12 @@ describe 'In a repo with a custom revision diff provider', ->
deleted: 0
assert.deepEqual(repo.getDiffStats(modifiedFilePath), expected)

repo.onDidChangeStatuses () ->
repo.onDidChangeStatus ->
expected =
added: 9
deleted: 0
assert.deepEqual(repo.getDiffStats(modifiedFilePath), expected)
done()

after ->
testRepo.destroy()
after ->
testRepo.destroy()

0 comments on commit 105366b

Please sign in to comment.