Marcin Kuzminski  committed 5222ce5

Mercurial backend requires unicode now in commit functions.
- it's better to use mercurial tolocal for compatibilty on unicode objects

  • Participants
  • Parent commits 32e3fc7

Comments (0)

Files changed (3)

File vcs/backends/hg/

 from vcs.backends.base import BaseInMemoryChangeset
 from vcs.exceptions import RepositoryError
-from ...utils.hgcompat import memfilectx, memctx, hex
+from vcs.utils.hgcompat import memfilectx, memctx, hex, tolocal
 class MercurialInMemoryChangeset(BaseInMemoryChangeset):
         from .repository import MercurialRepository
-        if not isinstance(message, str) or not isinstance(author, str):
+        if not isinstance(message, unicode) or not isinstance(author, unicode):
             raise RepositoryError('Given message and author needs to be '
-                                  'an <str> instance')
+                                  'an <unicode> instance got %r & %r instead'
+                                  % (type(message), type(author)))
         if branch is None:
             branch = MercurialRepository.DEFAULT_BRANCH_NAME
             raise RepositoryError("Given path haven't been marked as added,"
-                "changed or removed (%s)" % path)
+                                  "changed or removed (%s)" % path)
         parents = [None, None]
         for i, parent in enumerate(self.parents):
+        loc = lambda u: tolocal(u.encode('utf-8'))
         # injecting given _repo params
-        commit_ctx._text = message
-        commit_ctx._user = author
+        commit_ctx._text = loc(message)
+        commit_ctx._user = loc(author)
         commit_ctx._date = date
         # TODO: Catch exceptions!

File vcs/backends/hg/

 from vcs.utils.ordered_dict import OrderedDict
 from vcs.utils.paths import abspath
-from ...utils.hgcompat import ui, nullid, match, patch, diffopts, clone, \
+from vcs.utils.hgcompat import ui, nullid, match, patch, diffopts, clone, \
     get_contact, pull, localrepository, RepoLookupError, Abort, RepoError, hex
         :param context: How many lines before/after changed lines should be
           shown. Defaults to ``3``.
+        if hasattr(rev1, 'raw_id'):
+            rev1 = getattr(rev1, 'raw_id')
+        if hasattr(rev2, 'raw_id'):
+            rev2 = getattr(rev2, 'raw_id')
         # Check if given revisions are present at repository (may raise
         # ChangesetDoesNotExistError)
         if rev1 != self.EMPTY_CHANGESET:

File vcs/backends/hg/

 from vcs.backends.base import BaseWorkdir
 from vcs.exceptions import BranchDoesNotExistError
-from ...utils.hgcompat import hg_merge
+from vcs.utils.hgcompat import hg_merge
 class MercurialWorkdir(BaseWorkdir):