Changeset

6588:93423244dc5b

Merge 0.10->trunk
author Matthew Wild <mwild1@gmail.com>
date Tue, 24 Mar 2015 13:41:18 +0000
parents 6581:f2a7ad099e01 (current diff) 6587:54306208f30b (diff)
children 6603:e702ae7aa3d9
files
diffstat 4 files changed, 58 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/core/statsmanager.lua	Tue Feb 24 15:22:34 2015 +0000
+++ b/core/statsmanager.lua	Tue Mar 24 13:41:18 2015 +0000
@@ -28,6 +28,7 @@
 
 	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();
--- a/plugins/mod_http.lua	Tue Feb 24 15:22:34 2015 +0000
+++ b/plugins/mod_http.lua	Tue Mar 24 13:41:18 2015 +0000
@@ -84,7 +84,6 @@
 		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)");
--- a/prosodyctl	Tue Feb 24 15:22:34 2015 +0000
+++ b/prosodyctl	Tue Mar 24 13:41:18 2015 +0000
@@ -251,6 +251,7 @@
 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 @@
 			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 @@
 		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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/mercurial.lua	Tue Mar 24 13:41:18 2015 +0000
@@ -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;