def test_lock_set_release(self): def lock_exists(): private_dir = os.path.join(self._test_base, common.hgsvn_private_dir) return common.hgsvn_lock_file in os.listdir(private_dir) l = common.get_hgsvn_lock(self._test_base) lock_file = os.path.join(self._test_base, common.hgsvn_private_dir, common.hgsvn_lock_file) assert_true(lock_exists()) l.release() assert_false(lock_exists())
def test_locked(self): l = common.get_hgsvn_lock(self._test_base) assert_raises(common.LockHeld, common.get_hgsvn_lock, self._test_base) l.release()
def display_parser_error(parser, message): """ Display an options error, and terminate. """ print "error:", message print parser.print_help() sys.exit(1) def locked_main(real_main, *args, **kwds): """Wrapper for main() functions, that takes care of .hgsvn/lock.""" # Make sure that we work in the checkout's top-level directory (issue3). try: change_to_rootdir() except HgSVNError, err: sys.stderr.write("%s\n" % err) return 1 # We must do this before trying to take the lock file fixup_hgsvn_dir('.') try: l = get_hgsvn_lock() except LockHeld, e: print "Aborting:", e return 1 try: return real_main(*args, **kwds) finally: l.release()