X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/20bd2492d8bd211816c5120595b19a0a828b9f0c..5e0dd39c630bae5dabc96f33a16419f066d6f435:/lib/hg.py diff --git a/lib/hg.py b/lib/hg.py index 29229dd2..b94b0d64 100644 --- a/lib/hg.py +++ b/lib/hg.py @@ -7,8 +7,7 @@ import mercurial.merge, mercurial.error encoding.encoding = 'utf-8' -class RepositoryDoesNotExist(Exception): - pass + class Repository(object): """Abstrakcja repozytorium Mercurial. Działa z Mercurial w wersji 1.3.1.""" @@ -35,19 +34,19 @@ class Repository(object): return localrepo.localrepository(self.ui, path, create=1) raise RepositoryDoesNotExist("Repository %s does not exist." % path) - def file_list(self, branch='default'): + def file_list(self, branch): return self.in_branch(lambda: self._file_list(), branch) def _file_list(self): return list(self.repo[None]) - def get_file(self, path, branch='default'): + def get_file(self, path, branch): return self.in_branch(lambda: self._get_file(path), branch) def _get_file(self, path): return self.repo.wread(path) - def add_file(self, path, value, branch='default'): + def add_file(self, path, value, branch): return self.in_branch(lambda: self._add_file(path, value), branch) def _add_file(self, path, value): @@ -56,10 +55,10 @@ class Repository(object): def _commit(self, message, user=None): return self.repo.commit(text=message, user=user) - def commit(self, message, user=None, branch='default'): + def commit(self, message, branch, user=None): return self.in_branch(lambda: self._commit(message, key=key, user=user), branch) - def in_branch(self, action, bname='default'): + def in_branch(self, action, bname): wlock = self.repo.wlock() try: old = self._switch_to_branch(bname) @@ -100,7 +99,7 @@ class Repository(object): except KeyError, ke: raise RepositoryException("Can't switch to branch '%s': no such branch." % bname , ke) except util.Abort, ae: - raise repositoryException("Can't switch to branch '%s': %s" % (bname, ae.message), ae) + raise RepositoryException("Can't switch to branch '%s': %s" % (bname, ae.message), ae) finally: wlock.release() @@ -114,3 +113,6 @@ class RepositoryException(Exception): def __init__(self, msg, cause=None): Exception.__init__(self, msg) self.cause = cause + +class RepositoryDoesNotExist(RepositoryException): + pass