Mercurial > piecrust2
comparison foodtruck/scm/mercurial.py @ 659:a77b4656c602
internal: Move some basic FoodTruck SCM code to the base.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 27 Feb 2016 22:00:35 -0800 |
parents | a1697b1066bc |
children |
comparison
equal
deleted
inserted
replaced
658:a920b2ab1f31 | 659:a77b4656c602 |
---|---|
1 import os | 1 import os |
2 import logging | 2 import logging |
3 import tempfile | 3 import tempfile |
4 import subprocess | 4 import subprocess |
5 from .base import SourceControl, RepoStatus | 5 from .base import SourceControl, RepoStatus, _s |
6 | 6 |
7 | 7 |
8 logger = logging.getLogger(__name__) | 8 logger = logging.getLogger(__name__) |
9 | |
10 | |
11 def _s(strs): | |
12 """ Convert a byte array to string using UTF8 encoding. """ | |
13 if strs is None: | |
14 return None | |
15 assert isinstance(strs, bytes) | |
16 return strs.decode('utf8') | |
17 | 9 |
18 | 10 |
19 class MercurialSourceControl(SourceControl): | 11 class MercurialSourceControl(SourceControl): |
20 def __init__(self, root_dir, cfg): | 12 def __init__(self, root_dir, cfg): |
21 super(MercurialSourceControl, self).__init__(root_dir, cfg) | 13 super(MercurialSourceControl, self).__init__(root_dir, cfg) |
32 elif line[0] == 'M': | 24 elif line[0] == 'M': |
33 res.edited_files.append(line[2:]) | 25 res.edited_files.append(line[2:]) |
34 return res | 26 return res |
35 | 27 |
36 def _doCommit(self, paths, message, author): | 28 def _doCommit(self, paths, message, author): |
37 if not message: | |
38 raise ValueError("No commit message specified.") | |
39 | |
40 # Check if any of those paths needs to be added. | 29 # Check if any of those paths needs to be added. |
41 st_out = self._run('status', *paths) | 30 st_out = self._run('status', *paths) |
42 add_paths = [] | 31 add_paths = [] |
43 for line in st_out.splitlines(): | 32 for line in st_out.splitlines(): |
44 if line[0] == '?': | 33 if line[0] == '?': |