3 """Backends for version control systems."""
5 from . import utils as _utils
8 class VCSBackend (object):
11 def __init__(self, author_hacks=None, year_hacks=None, aliases=None):
12 if author_hacks is None:
14 self._author_hacks = author_hacks
15 if year_hacks is None:
17 self._year_hacks = year_hacks
20 self._aliases = aliases
22 def _years(self, filename=None):
23 raise NotImplementedError()
25 def original_year(self, filename=None):
26 years = self._years(filename=filename)
28 years.update(self._year_hacks.values())
29 elif _utils.splitpath(filename) in self._year_hacks:
30 years.update(year_hacks[_utils.splitpath(filename)])
34 def _authors(self, filename=None):
35 raise NotImplementedError()
37 def authors(self, filename=None, with_emails=True):
38 authors = self._authors(filename=filename)
40 for path,authors in self._author_hacks.items():
41 authors.update(authors)
42 elif _utils.splitpath(filename) in self._author_hacks:
43 authors.update(self._author_hacks[_utils.splitpath(filename)])
44 return _utils.replace_aliases(
45 authors, with_email=False, aliases=self._aliases)
47 def is_versioned(self, filename=None):
48 raise NotImplementedError()