Commit 6a4030ba authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

HgGitRepository: taking Mercurial repo size into account

Closes #314

Previously only the Git repository was considered.

Note that this is cached in the `projects_statistics` table,
and can be invalidated by doing

```
   project.statistics.refresh!
```

This seems in turn to be triggered by `UpdateProjectStatisticsWorker`,
iself called by `ProjectCacheWorker`, from the likes of `PostReceiveWorker`
etc.

--HG--
branch : heptapod-stable
parent 79afcc1f4c6a
......@@ -204,6 +204,22 @@ def remove
FileUtils.rm_rf(@hgpath)
end
def hg_size
cmd = ["du", "-ks", @hgpath]
kilobytes, status = popen(cmd)
if status != 0
raise StandardError,
"Could not run command #{command}"
end
# rounded to 2 decimal places is what Git::Repository does
(kilobytes.to_f / 1024).round(2)
end
# Return repo size in megabytes (same as `super` as of this writing)
def size
super + hg_size
end
def hg_sha_map
@git_sha_map = nil unless @hg_sha_map
# Get the entries of the git-mapfile and store them in a git => hg Hash
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment