X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/18691ef568f3b013ed5d71fa0d998cfc6842071f..e4722e5fe52bb4682bee8878bc24dcaaf557b591:/lib/hg.py?ds=inline diff --git a/lib/hg.py b/lib/hg.py index e785b375..2b885b3c 100644 --- a/lib/hg.py +++ b/lib/hg.py @@ -108,4 +108,22 @@ class Repository(object): # reread keys # self._keys = self.get_persisted_objects_keys() # return node.hex(rev) + + 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() +