Skip to content

Commit cabc5bd

Browse files
authored
refactor(BaseRepo): Remove __slots__ and __dict__ magic (#268)
Passing 'remotes' into a repo object could override the new GitRepo.remotes method.
2 parents b7ae236 + 80c28d6 commit cabc5bd

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ Generally speaking, refactor / magic is in the process of being stripped
1010
out in the next few releases. The API is subject to change significantly
1111
in pre-1.0 builds.
1212

13+
- :class:`libvcs.base.BaseRepo`:
14+
15+
- no longer sets ``**kwargs`` to dictionary on the object
16+
- remove ``__slot__`` and rename ``name`` attribute to ``repo_name``
17+
1318
libvcs 0.4.3 (2020-08-01)
1419
-------------------------
1520
- [bug] :func:`libvcs.git.extract_status()` Fix issue capturing branch names

libvcs/base.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ class BaseRepo(RepoLoggingAdapter, object):
3131
#: vcs app name, e.g. 'git'
3232
bin_name = ''
3333

34-
__slots__ = ['name']
35-
3634
def __init__(self, url, repo_dir, progress_callback=None, *args, **kwargs):
3735
"""
3836
:param callback: Retrieve live progress from ``sys.stderr`` (useful for
@@ -44,11 +42,10 @@ def progress_cb(output, timestamp):
4442
create_repo(..., progress_callback=progress_cb)
4543
:type callback: func
4644
"""
47-
self.__dict__.update(kwargs)
4845
self.progress_callback = progress_callback
4946
self.url = url
5047
self.parent_dir = os.path.dirname(repo_dir)
51-
self.name = os.path.basename(os.path.normpath(repo_dir))
48+
self.repo_name = os.path.basename(os.path.normpath(repo_dir))
5249
self.path = repo_dir
5350

5451
# Register more schemes with urlparse for various version control
@@ -118,7 +115,8 @@ def check_destination(self, *args, **kwargs):
118115

119116
if not os.path.exists(self.path):
120117
self.debug(
121-
'Repo directory for %s does not exist @ %s' % (self.name, self.path)
118+
'Repo directory for %s does not exist @ %s'
119+
% (self.repo_name, self.path)
122120
)
123121
mkdir_p(self.path)
124122

@@ -142,4 +140,4 @@ def get_url_and_revision_from_pip_url(cls, pip_url):
142140
return url, rev
143141

144142
def __repr__(self):
145-
return "<{} {}>".format(self.__class__.__name__, self.name)
143+
return "<{} {}>".format(self.__class__.__name__, self.repo_name)

libvcs/svn.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def __init__(self, url, **kwargs):
5151
"""
5252
if 'svn_trust_cert' not in kwargs:
5353
self.svn_trust_cert = False
54+
55+
self.rev = kwargs.get('rev')
5456
BaseRepo.__init__(self, url, **kwargs)
5557

5658
def _user_pw_args(self):

libvcs/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ class RepoLoggingAdapter(logging.LoggerAdapter):
8989
9090
Any class that subclasses this will have its class attributes for:
9191
92-
- :attr:`~.bin_name` -> ``repo_vcs``
93-
- :attr:`~.name` -> ``repo_name``
92+
- :attr:`~.bin_name` -> ``repo_vcs``
93+
- :attr:`~.repo_name` -> ``repo_name``
9494
9595
Added to a dictionary of context information in :py:meth:`
9696
logging.LoggerAdapter.process()` to be made use of when the user of this
@@ -106,7 +106,7 @@ def process(self, msg, kwargs):
106106
"""Add additional context information for loggers."""
107107
prefixed_dict = {}
108108
prefixed_dict['repo_vcs'] = self.bin_name
109-
prefixed_dict['repo_name'] = self.name
109+
prefixed_dict['repo_name'] = self.repo_name
110110

111111
kwargs["extra"] = prefixed_dict
112112

tests/test_hg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_repo_mercurial(tmpdir, parentdir, hg_remote):
4040
}
4141
)
4242

43-
run(['hg', 'init', mercurial_repo.name], cwd=str(tmpdir))
43+
run(['hg', 'init', mercurial_repo.repo_name], cwd=str(tmpdir))
4444

4545
mercurial_repo.update_repo()
4646

0 commit comments

Comments
 (0)