import codecs
from mercurial import localrepo, ui, error, match, node, encoding
-
encoding.encoding = 'utf-8'
-
class RepositoryDoesNotExist(Exception):
pass
# will commit all keys
pending_files = self._pending_files
else:
- if key not in self._pending_files:
+ if keys not in self._pending_files:
# key isn't changed
return None
else:
self.repo.forget(files_to_remove)
# ---- hg commit
if files_to_commit:
+ for i, f in enumerate(files_to_commit):
+ if isinstance(f, unicode):
+ files_to_commit[i] = f.encode('utf-8')
matcher = match.match(self.repo.root, self.repo.root, files_to_commit, default='path')
rev = self.repo.commit(message, user=user, match=matcher)
commited = True
# reread keys
# self._keys = self.get_persisted_objects_keys()
# return node.hex(rev)
-
\ No newline at end of file
+
+ def in_branch(self, branch_name, action):
+ wlock = self.repo.wlock()
+ try:
+ current_branch = self.repo[None].branch()
+ self.repo.dirstate.setbranch(branch_name)
+ try:
+ # do some stuff
+ action()
+ finally:
+ self.repo.dirstate.setbranch(current_branch)
+ finally:
+ wlock.release()
+
+ def write_lock(self):
+ """Returns w write lock to the repository."""
+ return self.repo.wlock()
+
+