annotate piecrust/admin/scm/base.py @ 1165:a928ee22c20a

cm: Upgrade Jinja2 version.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 04 Oct 2019 09:00:57 -0700
parents 5e91bc0e3b4d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3 class RepoStatus(object):
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 def __init__(self):
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 self.new_files = []
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6 self.edited_files = []
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 class SourceControl(object):
598
3cec8634209a admin: Ability to configure SCM stuff per site.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
10 def __init__(self, root_dir, cfg):
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11 self.root_dir = root_dir
598
3cec8634209a admin: Ability to configure SCM stuff per site.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
12 self.config = cfg
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
14 def getStatus(self):
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15 raise NotImplementedError()
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16
598
3cec8634209a admin: Ability to configure SCM stuff per site.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
17 def commit(self, paths, message, *, author=None):
659
a77b4656c602 internal: Move some basic FoodTruck SCM code to the base.
Ludovic Chabant <ludovic@chabant.com>
parents: 598
diff changeset
18 if not message:
a77b4656c602 internal: Move some basic FoodTruck SCM code to the base.
Ludovic Chabant <ludovic@chabant.com>
parents: 598
diff changeset
19 raise ValueError("No message specified for committing changes.")
598
3cec8634209a admin: Ability to configure SCM stuff per site.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
20 author = author or self.config.get('author')
3cec8634209a admin: Ability to configure SCM stuff per site.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
21 self._doCommit(paths, message, author)
3cec8634209a admin: Ability to configure SCM stuff per site.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
22
3cec8634209a admin: Ability to configure SCM stuff per site.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
23 def _doCommit(self, paths, message, author):
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 raise NotImplementedError()
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25
659
a77b4656c602 internal: Move some basic FoodTruck SCM code to the base.
Ludovic Chabant <ludovic@chabant.com>
parents: 598
diff changeset
26
a77b4656c602 internal: Move some basic FoodTruck SCM code to the base.
Ludovic Chabant <ludovic@chabant.com>
parents: 598
diff changeset
27 def _s(strs):
a77b4656c602 internal: Move some basic FoodTruck SCM code to the base.
Ludovic Chabant <ludovic@chabant.com>
parents: 598
diff changeset
28 """ Convert a byte array to string using UTF8 encoding. """
a77b4656c602 internal: Move some basic FoodTruck SCM code to the base.
Ludovic Chabant <ludovic@chabant.com>
parents: 598
diff changeset
29 if strs is None:
a77b4656c602 internal: Move some basic FoodTruck SCM code to the base.
Ludovic Chabant <ludovic@chabant.com>
parents: 598
diff changeset
30 return None
a77b4656c602 internal: Move some basic FoodTruck SCM code to the base.
Ludovic Chabant <ludovic@chabant.com>
parents: 598
diff changeset
31 assert isinstance(strs, bytes)
a77b4656c602 internal: Move some basic FoodTruck SCM code to the base.
Ludovic Chabant <ludovic@chabant.com>
parents: 598
diff changeset
32 return strs.decode('utf8')
a77b4656c602 internal: Move some basic FoodTruck SCM code to the base.
Ludovic Chabant <ludovic@chabant.com>
parents: 598
diff changeset
33