/usr/share/pyshared/bzrlib/plugins/gtk/lock.py is in bzr-gtk 0.103.0+bzr792-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | from gi.repository import Gtk
RESPONSE_BREAK = 0
RESPONSE_CANCEL = Gtk.ResponseType.CANCEL
READ = "read"
WRITE = "write"
def acquire(branch, lock_type):
if branch.get_physical_lock_status():
dialog = LockDialog(branch)
response = dialog.run()
dialog.destroy()
if response == RESPONSE_BREAK:
branch.break_lock()
else:
return False
if lock_type == READ:
branch.lock_read()
elif lock_type == WRITE:
branch.lock_write()
return True
def release(branch):
if branch.get_physical_lock_status():
dialog = LockDialog(branch)
response = dialog.run()
dialog.destroy()
if response == RESPONSE_BREAK:
branch.break_lock()
elif response == RESPONSE_CANCEL:
return False
branch.unlock()
return True
class LockDialog(Gtk.Dialog):
def __init__(self, branch):
super(LockDialog, self).__init__()
self.branch = branch
self.set_title('Lock Not Held')
self.get_content_area().add(
Gtk.Label(label=(
'This operation cannot be completed as '
'another application has locked the branch.')))
self.add_button('Break Lock', RESPONSE_BREAK)
self.add_button(Gtk.STOCK_CANCEL, RESPONSE_CANCEL)
self.get_content_area().show_all()
|