diff options
author | Matthew Wild <mwild1@gmail.com> | 2015-03-24 13:41:18 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2015-03-24 13:41:18 +0000 |
commit | 0cbc9ecbecd3caf2bab74dd77abab53ca77691f6 (patch) | |
tree | e4fca8b30e86975bf10ef581f281c91603e7eed8 | |
parent | c166ec17c2c8bf911877b5810de2555a50afe3ef (diff) | |
parent | 45e1b4d1da5e5c9825e23368d8de92c4c5c390de (diff) | |
download | prosody-0cbc9ecbecd3caf2bab74dd77abab53ca77691f6.tar.gz prosody-0cbc9ecbecd3caf2bab74dd77abab53ca77691f6.zip |
Merge 0.10->trunk
-rw-r--r-- | core/statsmanager.lua | 1 | ||||
-rw-r--r-- | plugins/mod_http.lua | 1 | ||||
-rwxr-xr-x | prosodyctl | 28 | ||||
-rw-r--r-- | util/mercurial.lua | 34 |
4 files changed, 58 insertions, 6 deletions
diff --git a/core/statsmanager.lua b/core/statsmanager.lua index cddaba06..d6cbd2bc 100644 --- a/core/statsmanager.lua +++ b/core/statsmanager.lua @@ -28,6 +28,7 @@ if stats_interval then function collect() local mark_collection_done = mark_collection_start(); + fire_event("stats-update"); changed_stats, stats_extra = {}, {}; for stat_name, getter in pairs(stats.get_stats()) do local type, value, extra = getter(); diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua index 76ee151b..8bda1cac 100644 --- a/plugins/mod_http.lua +++ b/plugins/mod_http.lua @@ -84,7 +84,6 @@ function module.add_host(module) local app_name = event.item.name; local default_app_path = event.item.default_path or "/"..app_name; local app_path = get_base_path(module, app_name, default_app_path); - module:log("debug", "Serving '%s' at %s", app_name, module:http_url(app_name, app_path)); if not app_name then -- TODO: Link to docs module:log("error", "HTTP app has no 'name', add one or use module:provides('http', app)"); @@ -251,6 +251,7 @@ require "socket" function read_version() -- Try to determine version local version_file = io.open((CFG_SOURCEDIR or ".").."/prosody.version"); + prosody.version = "unknown"; if version_file then prosody.version = version_file:read("*a"):gsub("%s*$", ""); version_file:close(); @@ -258,7 +259,9 @@ function read_version() prosody.version = "hg:"..prosody.version; end else - prosody.version = "unknown"; + local hg = require"util.mercurial"; + local hgid = hg.check_id(CFG_SOURCEDIR or "."); + if hgid then prosody.version = "hg:" .. hgid; end end end @@ -528,16 +531,31 @@ function commands.about(arg) return 1; end + local pwd = "."; + local lfs = require "lfs"; local array = require "util.array"; local keys = require "util.iterators".keys; + local hg = require"util.mercurial"; + local relpath = config.resolve_relative_path; print("Prosody "..(prosody.version or "(unknown version)")); print(""); print("# Prosody directories"); - print("Data directory: ", CFG_DATADIR or "./"); - print("Plugin directory:", CFG_PLUGINDIR or "./"); - print("Config directory:", CFG_CONFIGDIR or "./"); - print("Source directory:", CFG_SOURCEDIR or "./"); + print("Data directory: "..relpath(pwd, data_path)); + print("Config directory: "..relpath(pwd, CFG_CONFIGDIR or ".")); + print("Source directory: "..relpath(pwd, CFG_SOURCEDIR or ".")); + print("Plugin directories:") + print(" "..(prosody.paths.plugins:gsub("([^;]+);?", function(path) + local opath = path; + path = config.resolve_relative_path(pwd, path); + local hgid, hgrepo = hg.check_id(path); + if not hgid and hgrepo then + return path.." - "..hgrepo .."!\n "; + end + hgrepo = hgrepo == "010452cfaf53" and "prosody-modules"; + return path..(hgid and " - "..(hgrepo or "HG").." rev: "..hgid or "") + .."\n "; + end))); print(""); print("# Lua environment"); print("Lua version: ", _G._VERSION); diff --git a/util/mercurial.lua b/util/mercurial.lua new file mode 100644 index 00000000..3f75c4c1 --- /dev/null +++ b/util/mercurial.lua @@ -0,0 +1,34 @@ + +local lfs = require"lfs"; + +local hg = { }; + +function hg.check_id(path) + if lfs.attributes(path, 'mode') ~= "directory" then + return nil, "not a directory"; + end + local hg_dirstate = io.open(path.."/.hg/dirstate"); + local hgid, hgrepo + if hg_dirstate then + hgid = ("%02x%02x%02x%02x%02x%02x"):format(hg_dirstate:read(6):byte(1, 6)); + hg_dirstate:close(); + local hg_changelog = io.open(path.."/.hg/store/00changelog.i"); + if hg_changelog then + hg_changelog:seek("set", 0x20); + hgrepo = ("%02x%02x%02x%02x%02x%02x"):format(hg_changelog:read(6):byte(1, 6)); + hg_changelog:close(); + end + else + local hg_archival,e = io.open(path.."/.hg_archival.txt"); + if hg_archival then + local repo = hg_archival:read("*l"); + local node = hg_archival:read("*l"); + hg_archival:close() + hgid = node and node:match("^node: (%x%x%x%x%x%x%x%x%x%x%x%x)") + hgrepo = repo and repo:match("^repo: (%x%x%x%x%x%x%x%x%x%x%x%x)") + end + end + return hgid, hgrepo; +end + +return hg; |