diff --git a/svn/common.py b/svn/common.py index a53e2f2..6b9d8ab 100644 --- a/svn/common.py +++ b/svn/common.py @@ -68,7 +68,7 @@ def info(self, rel_path=None, revision=None): full_url_or_path = self.__url_or_path if rel_path is not None: - full_url_or_path += '/' + rel_path + full_url_or_path = self._pathjoin(full_url_or_path, rel_path) cmd += ['--xml', full_url_or_path] result = self.run_command( @@ -144,7 +144,7 @@ def properties(self, rel_path=None): full_url_or_path = self.__url_or_path if rel_path is not None: - full_url_or_path += '/' + rel_path + full_url_or_path = self._pathjoin(full_url_or_path, rel_path) result = self.run_command( 'proplist', @@ -176,7 +176,7 @@ def cat(self, rel_filepath, revision=None): cmd = [] if revision is not None: cmd += ['-r', str(revision)] - cmd += [self.__url_or_path + '/' + rel_filepath] + cmd += [self._pathjoin(self.__url_or_path, rel_filepath)] return self.run_command('cat', cmd, return_binary=True) def log_default(self, timestamp_from_dt=None, timestamp_to_dt=None, @@ -189,7 +189,7 @@ def log_default(self, timestamp_from_dt=None, timestamp_to_dt=None, full_url_or_path = self.__url_or_path if rel_filepath is not None: - full_url_or_path += '/' + rel_filepath + self._pathjoin(full_url_or_path, rel_filepath) timestamp_from_phrase = ('{' + timestamp_from_dt.isoformat() + '}') \ if timestamp_from_dt \ @@ -288,7 +288,7 @@ def export(self, to_path, revision=None, force=False): def list(self, extended=False, rel_path=None): full_url_or_path = self.__url_or_path if rel_path is not None: - full_url_or_path += '/' + rel_path + full_url_or_path = self._pathjoin(full_url_or_path, rel_path) if extended is False: for line in self.run_command( @@ -347,6 +347,9 @@ def list(self, extended=False, rel_path=None): yield entry + def _pathjoin(self, *args): + return os.path.join(*args) + def list_recursive(self, rel_path=None, yield_dirs=False, path_filter_cb=None): q = [rel_path] @@ -357,8 +360,8 @@ def list_recursive(self, rel_path=None, yield_dirs=False, for entry in self.list(extended=True, rel_path=current_rel_path): if entry['is_directory'] is True: if current_rel_path is not None: - next_rel_path = \ - os.path.join(current_rel_path, entry['name']) + next_rel_path = self._pathjoin( + current_rel_path, entry['name']) else: next_rel_path = entry['name'] @@ -385,7 +388,7 @@ def diff_summary(self, old, new, rel_path=None): full_url_or_path = self.__url_or_path if rel_path is not None: - full_url_or_path += '/' + rel_path + full_url_or_path = self._pathjoin(full_url_or_path, rel_path) arguments = [ '--old', '{0}@{1}'.format(full_url_or_path, old), @@ -418,7 +421,7 @@ def diff(self, old, new, rel_path=None): full_url_or_path = self.__url_or_path if rel_path is not None: - full_url_or_path += '/' + rel_path + full_url_or_path = self._pathjoin(full_url_or_path, rel_path) arguments = [ '--old', '{0}@{1}'.format(full_url_or_path, old), diff --git a/svn/remote.py b/svn/remote.py index c55bf96..37d5ade 100644 --- a/svn/remote.py +++ b/svn/remote.py @@ -1,3 +1,5 @@ +import posixpath + import svn.constants import svn.common @@ -27,7 +29,7 @@ def remove(self, rel_path, message, do_force=False): if do_force is True: args.append('--force') - url = '{}/{}'.format(self.url, rel_path) + url = self._pathjoin(self.url, rel_path) args += [ url @@ -37,5 +39,8 @@ def remove(self, rel_path, message, do_force=False): 'rm', args) + def _pathjoin(self, *args): + return posixpath.join(*args) + def __repr__(self): return '' % self.url