From 6cda763ebdfcda6d5919a9740f064d2a7e7b3db5 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 27 Jan 2014 09:53:16 -0800 Subject: [PATCH] vcs.bazaar: Remove Bazaar support As of 2013-05-19, Bazaar had no Python 3 compatibility, and no likelyhood of adding it in the near future [1]. This module could be ported to use the command line client (like Git), but I also haven't seen a Bazaar repository in a while ;). [1]: https://answers.launchpad.net/bzr/+question/229048#comment-0 --- update_copyright/project.py | 8 --- update_copyright/vcs/bazaar.py | 91 ---------------------------------- 2 files changed, 99 deletions(-) delete mode 100644 update_copyright/vcs/bazaar.py diff --git a/update_copyright/project.py b/update_copyright/project.py index 03296b9..34a63a5 100644 --- a/update_copyright/project.py +++ b/update_copyright/project.py @@ -26,10 +26,6 @@ import time as _time from . import LOG as _LOG from . import utils as _utils from .vcs.git import GitBackend as _GitBackend -try: - from .vcs.bazaar import BazaarBackend as _BazaarBackend -except ImportError as _bazaar_import_error: - _BazaarBackend = None try: from .vcs.mercurial import MercurialBackend as _MercurialBackend except ImportError as _mercurial_import_error: @@ -88,10 +84,6 @@ class Project (object): } if vcs == 'Git': self._vcs = _GitBackend(**kwargs) - elif vcs == 'Bazaar': - if _BazaarBackend is None: - raise _bazaar_import_error - self._vcs = _BazaarBackend(**kwargs) elif vcs == 'Mercurial': if _MercurialBackend is None: raise _mercurial_import_error diff --git a/update_copyright/vcs/bazaar.py b/update_copyright/vcs/bazaar.py deleted file mode 100644 index 6754cf5..0000000 --- a/update_copyright/vcs/bazaar.py +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright (C) 2012-2013 W. Trevor King -# -# This file is part of update-copyright. -# -# update-copyright is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) any -# later version. -# -# update-copyright is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# update-copyright. If not, see . - -import io as _io -import os as _os - -import bzrlib as _bzrlib -import bzrlib.builtins as _bzrlib_builtins -import bzrlib.log as _bzrlib_log - -from . import VCSBackend as _VCSBackend - - -class _LogFormatter (_bzrlib_log.LogFormatter): - supports_merge_revisions = True - preferred_levels = 0 - supports_deta = False - supports_tags = False - supports_diff = False - - def log_revision(self, revision): - raise NotImplementedError - - -class _YearLogFormatter (_LogFormatter): - def log_revision(self, revision): - self.to_file.write( - time.strftime('%Y', time.gmtime(revision.rev.timestamp)) - +'\n') - - -class _AuthorLogFormatter (_LogFormatter): - def log_revision(self, revision): - authors = revision.rev.get_apparent_authors() - self.to_file.write('\n'.join(authors)+'\n') - - -class BazaarBackend (_VCSBackend): - name = 'Bazaar' - - def __init__(self, **kwargs): - super(BazaarBackend, self).__init__(**kwargs) - self._version = _bzrlib.__version__ - - def _bzr_cmd(self, cmd, **kwargs): - cwd = _os.getcwd() - _os.chdir(self._root) - try: - cmd.run(**kwargs) - finally: - _os.chdir(cwd) - - def _years(self, filename=None): - cmd = _bzrlib_builtins.cmd_log() - cmd.outf = _io.StringIO() - kwargs = {'log_format':_YearLogFormatter, 'levels':0} - if filename is not None: - kwargs['file_list'] = [filename] - self._bzr_cmd(cmd=cmd, **kwargs) - years = set(int(year) for year in cmd.outf.getvalue().splitlines()) - return years - - def _authors(self, filename=None): - cmd = _bzrlib_builtins.cmd_log() - cmd.outf = _io.StringIO() - kwargs = {'log_format':_AuthorLogFormatter, 'levels':0} - if filename is not None: - kwargs['file_list'] = [filename] - self._bzr_cmd(cmd=cmd, **kwargs) - authors = set(cmd.outf.getvalue().splitlines()) - return authors - - def is_versioned(self, filename): - cmd = _bzrlib_builtins.cmd_log() - cmd.outf = _io.StringIO() - self._bzr_cmd(cmd=cmd, file_list=[filename]) - return True -- 2.26.2