mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1392886 - Use abstract base class for Repository; r=mshal
This makes the interface more formalized. MozReview-Commit-ID: JOjgJjR5MZk --HG-- extra : rebase_source : 20d015dbd6861ea0738828cf6da89723e2afb4e8
This commit is contained in:
parent
7d502f2abb
commit
f9bdc9486a
@ -4,6 +4,7 @@
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import abc
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
@ -11,6 +12,7 @@ import which
|
||||
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
|
||||
def get_tool_path(tool):
|
||||
"""Obtain the path of `tool`."""
|
||||
if os.path.isabs(tool) and os.path.exists(tool):
|
||||
@ -33,7 +35,10 @@ def get_tool_path(tool):
|
||||
'|mach bootstrap| to ensure your environment is up to '
|
||||
'date.' % tool)
|
||||
|
||||
|
||||
class Repository(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
'''A class wrapping utility methods around version control repositories.'''
|
||||
def __init__(self, path, tool):
|
||||
self.path = os.path.abspath(path)
|
||||
@ -59,29 +64,29 @@ class Repository(object):
|
||||
self.version = LooseVersion(match.group(1))
|
||||
return self.version
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_modified_files(self):
|
||||
'''Return a list of files that are modified in this repository's
|
||||
working copy.'''
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_added_files(self):
|
||||
'''Return a list of files that are added in this repository's
|
||||
working copy.'''
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def add_remove_files(self, path):
|
||||
'''Add and remove files under `path` in this repository's working copy.
|
||||
'''
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def forget_add_remove_files(self, path):
|
||||
'''Undo the effects of a previous add_remove_files call for `path`.
|
||||
'''
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_files_in_working_directory(self):
|
||||
"""Obtain a list of managed files in the working directory."""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class HgRepository(Repository):
|
||||
|
Loading…
Reference in New Issue
Block a user