Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Path Joins for Windows #180

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions svn/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand All @@ -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 \
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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]
Expand All @@ -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']

Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
7 changes: 6 additions & 1 deletion svn/remote.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import posixpath

import svn.constants
import svn.common

Expand Down Expand Up @@ -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
Expand All @@ -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 '<SVN(REMOTE) %s>' % self.url