# HG changeset patch # User Ludovic Chabant # Date 1456639235 28800 # Node ID a77b4656c602223200085f60a53b964bf933a6b0 # Parent a920b2ab1f316d675fd2802ecdc9769979ac44bd internal: Move some basic FoodTruck SCM code to the base. diff -r a920b2ab1f31 -r a77b4656c602 foodtruck/scm/base.py --- a/foodtruck/scm/base.py Thu Feb 25 23:26:36 2016 -0800 +++ b/foodtruck/scm/base.py Sat Feb 27 22:00:35 2016 -0800 @@ -15,9 +15,19 @@ raise NotImplementedError() def commit(self, paths, message, *, author=None): + if not message: + raise ValueError("No message specified for committing changes.") author = author or self.config.get('author') self._doCommit(paths, message, author) def _doCommit(self, paths, message, author): raise NotImplementedError() + +def _s(strs): + """ Convert a byte array to string using UTF8 encoding. """ + if strs is None: + return None + assert isinstance(strs, bytes) + return strs.decode('utf8') + diff -r a920b2ab1f31 -r a77b4656c602 foodtruck/scm/mercurial.py --- a/foodtruck/scm/mercurial.py Thu Feb 25 23:26:36 2016 -0800 +++ b/foodtruck/scm/mercurial.py Sat Feb 27 22:00:35 2016 -0800 @@ -2,20 +2,12 @@ import logging import tempfile import subprocess -from .base import SourceControl, RepoStatus +from .base import SourceControl, RepoStatus, _s logger = logging.getLogger(__name__) -def _s(strs): - """ Convert a byte array to string using UTF8 encoding. """ - if strs is None: - return None - assert isinstance(strs, bytes) - return strs.decode('utf8') - - class MercurialSourceControl(SourceControl): def __init__(self, root_dir, cfg): super(MercurialSourceControl, self).__init__(root_dir, cfg) @@ -34,9 +26,6 @@ return res def _doCommit(self, paths, message, author): - if not message: - raise ValueError("No commit message specified.") - # Check if any of those paths needs to be added. st_out = self._run('status', *paths) add_paths = []