mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Do not store state when syncing WPT.
This commit is contained in:
parent
28c6dec62d
commit
bc2e1e2151
4 changed files with 65 additions and 39 deletions
|
@ -683466,7 +683466,7 @@
|
||||||
"support"
|
"support"
|
||||||
],
|
],
|
||||||
"tools/wptrunner/wptrunner/update/state.py": [
|
"tools/wptrunner/wptrunner/update/state.py": [
|
||||||
"3a97618effdbf13c22ac422a6f5e4bbae65643bd",
|
"83fece632c68b62cf35ce154cbcd724e0af98d81",
|
||||||
"support"
|
"support"
|
||||||
],
|
],
|
||||||
"tools/wptrunner/wptrunner/update/sync.py": [
|
"tools/wptrunner/wptrunner/update/sync.py": [
|
||||||
|
@ -683478,7 +683478,7 @@
|
||||||
"support"
|
"support"
|
||||||
],
|
],
|
||||||
"tools/wptrunner/wptrunner/update/update.py": [
|
"tools/wptrunner/wptrunner/update/update.py": [
|
||||||
"e5678be4f5467be2c542af5160b512a574fd7a36",
|
"ceeae2a83c9613c1452f00244cd86f9a38c876ed",
|
||||||
"support"
|
"support"
|
||||||
],
|
],
|
||||||
"tools/wptrunner/wptrunner/vcs.py": [
|
"tools/wptrunner/wptrunner/vcs.py": [
|
||||||
|
|
|
@ -31,6 +31,7 @@ def set_defaults(kwargs):
|
||||||
kwargs["product"] = "servo"
|
kwargs["product"] = "servo"
|
||||||
if kwargs["config"] is None:
|
if kwargs["config"] is None:
|
||||||
kwargs["config"] = wpt_path('config.ini')
|
kwargs["config"] = wpt_path('config.ini')
|
||||||
|
kwargs["store_state"] = False
|
||||||
updatecommandline.check_args(kwargs)
|
updatecommandline.check_args(kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,7 @@ import cPickle as pickle
|
||||||
|
|
||||||
here = os.path.abspath(os.path.split(__file__)[0])
|
here = os.path.abspath(os.path.split(__file__)[0])
|
||||||
|
|
||||||
class State(object):
|
class BaseState(object):
|
||||||
filename = os.path.join(here, ".wpt-update.lock")
|
|
||||||
|
|
||||||
def __new__(cls, logger):
|
def __new__(cls, logger):
|
||||||
rv = cls.load(logger)
|
rv = cls.load(logger)
|
||||||
if rv is not None:
|
if rv is not None:
|
||||||
|
@ -18,11 +16,6 @@ class State(object):
|
||||||
def __init__(self, logger):
|
def __init__(self, logger):
|
||||||
"""Object containing state variables created when running Steps.
|
"""Object containing state variables created when running Steps.
|
||||||
|
|
||||||
On write the state is serialized to disk, such that it can be restored in
|
|
||||||
the event that the program is interrupted before all steps are complete.
|
|
||||||
Note that this only works well if the values are immutable; mutating an
|
|
||||||
existing value will not cause the data to be serialized.
|
|
||||||
|
|
||||||
Variables are set and get as attributes e.g. state_obj.spam = "eggs".
|
Variables are set and get as attributes e.g. state_obj.spam = "eggs".
|
||||||
|
|
||||||
:param parent: Parent State object or None if this is the root object.
|
:param parent: Parent State object or None if this is the root object.
|
||||||
|
@ -40,23 +33,6 @@ class State(object):
|
||||||
del rv["_logger"]
|
del rv["_logger"]
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def load(cls, logger):
|
|
||||||
"""Load saved state from a file"""
|
|
||||||
try:
|
|
||||||
if not os.path.isfile(cls.filename):
|
|
||||||
return None
|
|
||||||
with open(cls.filename) as f:
|
|
||||||
try:
|
|
||||||
rv = pickle.load(f)
|
|
||||||
logger.debug("Loading data %r" % (rv._data,))
|
|
||||||
rv._logger = logger
|
|
||||||
rv._index = 0
|
|
||||||
return rv
|
|
||||||
except EOFError:
|
|
||||||
logger.warning("Found empty state file")
|
|
||||||
except IOError:
|
|
||||||
logger.debug("IOError loading stored state")
|
|
||||||
|
|
||||||
def push(self, init_values):
|
def push(self, init_values):
|
||||||
"""Push a new clean state dictionary
|
"""Push a new clean state dictionary
|
||||||
|
@ -66,23 +42,13 @@ class State(object):
|
||||||
|
|
||||||
return StateContext(self, init_values)
|
return StateContext(self, init_values)
|
||||||
|
|
||||||
def save(self):
|
|
||||||
"""Write the state to disk"""
|
|
||||||
with open(self.filename, "w") as f:
|
|
||||||
pickle.dump(self, f, 2)
|
|
||||||
|
|
||||||
def is_empty(self):
|
def is_empty(self):
|
||||||
return len(self._data) == 1 and self._data[0] == {}
|
return len(self._data) == 1 and self._data[0] == {}
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""Remove all state and delete the stored copy."""
|
"""Remove all state and delete the stored copy."""
|
||||||
try:
|
|
||||||
os.unlink(self.filename)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
self._data = [{}]
|
self._data = [{}]
|
||||||
|
|
||||||
|
|
||||||
def __setattr__(self, key, value):
|
def __setattr__(self, key, value):
|
||||||
if key.startswith("_"):
|
if key.startswith("_"):
|
||||||
object.__setattr__(self, key, value)
|
object.__setattr__(self, key, value)
|
||||||
|
@ -109,6 +75,62 @@ class State(object):
|
||||||
def keys(self):
|
def keys(self):
|
||||||
return self._data[self._index].keys()
|
return self._data[self._index].keys()
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
class SavedState(BaseState):
|
||||||
|
"""On write the state is serialized to disk, such that it can be restored in
|
||||||
|
the event that the program is interrupted before all steps are complete.
|
||||||
|
Note that this only works well if the values are immutable; mutating an
|
||||||
|
existing value will not cause the data to be serialized."""
|
||||||
|
filename = os.path.join(here, ".wpt-update.lock")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load(cls, logger):
|
||||||
|
"""Load saved state from a file"""
|
||||||
|
try:
|
||||||
|
if not os.path.isfile(cls.filename):
|
||||||
|
return None
|
||||||
|
with open(cls.filename) as f:
|
||||||
|
try:
|
||||||
|
rv = pickle.load(f)
|
||||||
|
logger.debug("Loading data %r" % (rv._data,))
|
||||||
|
rv._logger = logger
|
||||||
|
rv._index = 0
|
||||||
|
return rv
|
||||||
|
except EOFError:
|
||||||
|
logger.warning("Found empty state file")
|
||||||
|
except IOError:
|
||||||
|
logger.debug("IOError loading stored state")
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
"""Write the state to disk"""
|
||||||
|
with open(self.filename, "w") as f:
|
||||||
|
pickle.dump(self, f)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
super(SavedState, self).clear()
|
||||||
|
try:
|
||||||
|
os.unlink(self.filename)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnsavedState(BaseState):
|
||||||
|
@classmethod
|
||||||
|
def load(cls, logger):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class StateContext(object):
|
class StateContext(object):
|
||||||
def __init__(self, state, init_values):
|
def __init__(self, state, init_values):
|
||||||
self.state = state
|
self.state = state
|
||||||
|
|
|
@ -6,7 +6,7 @@ from sync import SyncFromUpstreamRunner
|
||||||
from tree import GitTree, HgTree, NoVCSTree
|
from tree import GitTree, HgTree, NoVCSTree
|
||||||
|
|
||||||
from base import Step, StepRunner, exit_clean, exit_unclean
|
from base import Step, StepRunner, exit_clean, exit_unclean
|
||||||
from state import State
|
from state import SavedState, UnsavedState
|
||||||
|
|
||||||
def setup_paths(sync_path):
|
def setup_paths(sync_path):
|
||||||
sys.path.insert(0, os.path.abspath(sync_path))
|
sys.path.insert(0, os.path.abspath(sync_path))
|
||||||
|
@ -149,7 +149,10 @@ class WPTUpdate(object):
|
||||||
# If the sync path doesn't exist we defer this until it does
|
# If the sync path doesn't exist we defer this until it does
|
||||||
setup_paths(kwargs["sync_path"])
|
setup_paths(kwargs["sync_path"])
|
||||||
|
|
||||||
self.state = State(logger)
|
if kwargs["store_state"]:
|
||||||
|
self.state = SavedState(logger)
|
||||||
|
else:
|
||||||
|
self.state = UnsavedState(logger)
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue