Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/state.py
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-12-28 16:21:36 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-28 16:21:36 (GMT)
commit542477741abe0135c652a78911a0eb9aec9b1a19 (patch)
treefc47abcaeadd22293b8a4782a798d12cc8185727 /devbot/state.py
parent23e0efc9099005c2b789c84a4578624ba2033de3 (diff)
Change how we decide if system check is required
Using mtime will work even if you make local changes and it's less code.
Diffstat (limited to 'devbot/state.py')
-rw-r--r--devbot/state.py54
1 files changed, 28 insertions, 26 deletions
diff --git a/devbot/state.py b/devbot/state.py
index 4e7e12a..1a6e5b0 100644
--- a/devbot/state.py
+++ b/devbot/state.py
@@ -3,7 +3,6 @@ import os
import json
from devbot import config
-from devbot import git
_BUILT_MODULES = "builtmodules"
_FULL_BUILD = "fullbuild"
@@ -12,7 +11,10 @@ _SYSTEM_CHECK = "syscheck"
def built_module_touch(module):
built_modules = _load_state(_BUILT_MODULES, {})
- built_modules[module.name] = {"source_hash": _compute_source_hash(module)}
+
+ source_hash = _compute_mtime_hash(module.get_source_dir())
+ built_modules[module.name] = {"source_hash": source_hash}
+
_save_state(_BUILT_MODULES, built_modules)
@@ -21,22 +23,32 @@ def built_module_is_unchanged(module):
if module.name not in built_modules:
return False
- source_hash = built_modules[module.name].get("source_hash", None)
+ built_module = built_modules[module.name]
+ if "source_hash" not in built_module:
+ return False
+
+ old_source_hash = built_module["source_hash"]
+ new_source_hash = _compute_mtime_hash(module.get_source_dir())
- return source_hash == _compute_source_hash(module)
+ return old_source_hash == new_source_hash
def system_check_is_unchanged():
system_check = _load_state(_SYSTEM_CHECK)
- if not system_check:
+ if not system_check or not "config_hash" in system_check:
return False
- return system_check["commit"] == _get_root_commit_id()
+ config_hash = _compute_mtime_hash(config.config_dir)
+
+ return system_check["config_hash"] == config_hash
def system_check_touch():
system_check = _load_state(_SYSTEM_CHECK, {})
- system_check["commit"] = _get_root_commit_id()
+
+ config_hash = _compute_mtime_hash(config.config_dir)
+ system_check["config_hash"] = config_hash
+
_save_state(_SYSTEM_CHECK, system_check)
@@ -61,11 +73,11 @@ def clean(build_only=False):
if not build_only:
names.append(_SYSTEM_CHECK)
- try:
- for name in names:
+ for name in names:
+ try:
os.unlink(_get_state_path(name))
- except OSError:
- pass
+ except OSError:
+ pass
def _get_state_path(name):
@@ -90,26 +102,16 @@ def _save_state(name, state):
f.write('\n')
-def _compute_source_hash(module):
- # For some reason if source_dir is unicode
- # we get a 10x slow down for some modules
- source_dir = str(module.get_source_dir())
+def _compute_mtime_hash(path):
+ # For some reason if path is unicode we
+ # get a 10x slow down for some directories
+ path = str(path)
data = ""
- for root, dirs, files in os.walk(source_dir):
+ for root, dirs, files in os.walk(path):
for name in files:
path = os.path.join(root, name)
mtime = os.lstat(path).st_mtime
data = "%s%s %s\n" % (data, mtime, path)
return hashlib.sha256(data).hexdigest()
-
-
-def _get_root_commit_id():
- git_module = git.get_root_module()
- if git_module:
- commit_id = git_module.get_commit_id()
- else:
- commit_id = "snapshot"
-
- return commit_id