From c94e18af76ba34ec6d4b3bcedb44c486e101f2b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Fri, 4 Sep 2009 16:47:48 +0200 Subject: [PATCH 1/1] Fixed mercurial paths encoding. --- apps/explorer/views.py | 2 +- lib/hg.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/explorer/views.py b/apps/explorer/views.py index cb6988ae..7d186887 100644 --- a/apps/explorer/views.py +++ b/apps/explorer/views.py @@ -71,7 +71,7 @@ def file_upload(request, repo): def upload_action(): print 'Adding file: %s' % f.name - repo._add_file(f.name, decoded) + repo._add_file(f.name, decoded.encode('utf-8') ) repo._commit( message="File %s uploaded from platform by %s" %\ (f.name, request.user.username), \ diff --git a/lib/hg.py b/lib/hg.py index 6dd6e0cb..18a8d18a 100644 --- a/lib/hg.py +++ b/lib/hg.py @@ -7,7 +7,8 @@ import mercurial.merge, mercurial.error encoding.encoding = 'utf-8' - +def clearpath(path): + return unicode(path).encode("utf-8") class Repository(object): """Abstrakcja repozytorium Mercurial. Działa z Mercurial w wersji 1.3.1.""" @@ -44,6 +45,8 @@ class Repository(object): return self.in_branch(lambda: self._get_file(path), branch) def _get_file(self, path): + path = clearpath(path) + if not self._file_exists(path): raise RepositoryException("File not availble in this branch.") @@ -53,18 +56,21 @@ class Repository(object): return self.in_branch(lambda: self._file_exists(path), branch) def _file_exists(self, path): + path = clearpath(path) return self.repo.dirstate[path] != "?" def write_file(self, path, value, branch): return self.in_branch(lambda: self._write_file(path, value), branch) - def _write_file(self, path, value): + def _write_file(self, path, value): + path = clearpath(path) return self.repo.wwrite(path, value, []) def add_file(self, path, value, branch): return self.in_branch(lambda: self._add_file(path, value), branch) def _add_file(self, path, value): + path = clearpath(path) self._write_file(path, value) return self.repo.add( [path] ) -- 2.20.1