-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/lock.pyc

ó
ÑwPc	@@skdZddlmZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZddl
mZddlmZdefd„ƒYZd	efd
„ƒYZdefd„ƒYZd
efd„ƒYZd„ZyddlZeZWnek
r$eZnXeZeZejdkr»ddlZy.ddl Z ddl!Z!ddl"Z"eZWnek
rnXyddl#Z#eZWq»ek
r·q»Xndefd„ƒYZ$gZ%erNde$fd„ƒYZ&de&fd„ƒYZ'de&fd„ƒYZ(de$fd„ƒYZ)e%j*de'e(fƒnerßejdkrßej+j,r{e j-Z.n	e j/Z.de$fd„ƒYZ0de0fd„ƒYZ1d e0fd!„ƒYZ2e%j*d"e2e1fƒnerdd#l3m4Z4m5Z5m6Z6e#j7Z8e#j9Z:ej+j,r.d$Z;e6Z<nd%Z;d&e5fd'„ƒYZ<e#j=e:e<e4e4e8e4e4e:ƒe;e#j>j?fƒZ@d(ZAd)ZBd*ZCd+ZDd,ZEd-ZFd.ZGd/ZHd0e$fd1„ƒYZId2eIfd3„ƒYZJd4eIfd5„ƒYZKe%j*d6eKeJfƒneLe%ƒdkr,eMd7ƒ‚ne%d\ZNZOZPd8efd9„ƒYZQejRd:„ƒZSdS(;sÎLocking using OS file locks or file existence.

Note: This method of locking is generally deprecated in favour of LockDir, but
is used to lock local WorkingTrees, and by some old formats.  It's accessed
through Transport.lock_read(), etc.

This module causes two methods, lock() and unlock() to be defined in
any way that works on the current platform.

It is not specified whether these locks are reentrant (i.e. can be
taken repeatedly by a single process) or whether they exclude
different threads in a single process.  That reentrancy is provided by
LockableFiles.

This defines two classes: ReadLock and WriteLock, which can be
implemented in different ways on different platforms.  Both have an
unlock() method.
i(tabsolute_importN(tdebugterrorstosutilsttrace(tHooks(tgettextt	LockHookscB@seZd„ZRS(cC@sPtj|ddƒ|jdddƒ|jddd
ƒ|jd	d
dƒdS(Nsbzrlib.locks
Lock.hookst
lock_acquiredsFCalled with a bzrlib.lock.LockResult when a physical lock is acquired.iit
lock_releasedsFCalled with a bzrlib.lock.LockResult when a physical lock is released.tlock_brokensDCalled with a bzrlib.lock.LockResult when a physical lock is broken.i(ii(ii(ii(Rt__init__tadd_hook(tself((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR7s			(t__name__t
__module__R(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR5stLockcB@seZdZeƒZRS(sUBase class for locks.

    :cvar hooks: Hook dictionary for operations on locks.
    (RRt__doc__Rthooks(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRDst
LockResultcB@s,eZdZdd„Zd„Zd„ZRS(s2Result of an operation on a lock; passed to a hookcC@s||_||_dS(sCCreate a lock result for lock with optional details about the lock.N(tlock_urltdetails(R
RR((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRPs	cC@s"|j|jko!|j|jkS(N(RR(R
tother((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyt__eq__UscC@sd|jj|j|jfS(Ns
%s(%s, %s)(t	__class__RRR(R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyt__repr__XsN(RRRtNoneRRR(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRMs	tLogicalLockResultcB@s eZdZd„Zd„ZRS(s†The result of a lock_read/lock_write/lock_tree_write call on lockables.

    :ivar unlock: A callable which will unlock the lock.
    cC@s
||_dS(N(tunlock(R
R((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRcscC@sd|jS(NsLogicalLockResult(%s)(R(R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRfs(RRRRR(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR]s	cC@s?dtjkr,tjd|fddƒntj|ƒ‚dS(s§An attempt to unlock failed because the object was not locked.

    This provides a policy point from which we can generate either a warning 
    or an exception.
    Rs%r is already unlockedt
stackleveliN(Rtdebug_flagstwarningstwarnRtLockNotHeld(t
locked_object((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pytcant_unlock_not_heldks

twin32t_OSLockcB@s,eZd„Zd„Zd„Zd„ZRS(cC@sd|_d|_dS(N(Rtftfilename(R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR•s	cC@sÉtj|ƒ|_y t|j|ƒ|_|jSWntk
rÄ}|jtjtjfkr}t	j
|jt|ƒƒ‚n|jtjkr•‚nt
jd|jƒt|jdƒ|_|jSXdS(Ns trying to create missing lock %rswb+(RtrealpathR'topenR&tIOErrorterrnotEACCEStEPERMRt
LockFailedtstrtENOENTRtmutter(R
R'tfilemodete((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyt_open™scC@s&|jr"|jjƒd|_ndS(s#Clear the self.f attribute cleanly.N(R&tcloseR(R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyt_clear_fªs	
cC@s
tƒ‚dS(N(tNotImplementedError(R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR°s(RRRR4R6R(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR%“s			t_fcntl_FileLockcB@seZd„ZRS(cC@s$tj|jtjƒ|jƒdS(N(tfcntltlockfR&tLOCK_UNR6(R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyt_unlock»s(RRR<(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR8¹st_fcntl_WriteLockcB@s#eZeƒZd„Zd„ZRS(cC@sNtt|ƒjƒtj|ƒ|_|jtjkrV|jƒtj	|jƒ‚n|jt
jkr°dtjkr–|jƒtj	|jƒ‚q°t
jd|jfƒn|j|jdƒtjj|jƒy!tj|jtjtjBƒWnPtk
rI}|jtjtjfkr1|jƒntj	|j|ƒ‚nXdS(Ntstrict_lockss,Write lock taken w/ an open read lock on: %ssrb+(tsuperR=RRR(R't_open_locksR6RtLockContentiont_fcntl_ReadLockRRRR1R4taddR9R:R&tLOCK_EXtLOCK_NBR*R+tEAGAINR,R(R
R'R3((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRÄs&

	!
cC@s!tjj|jƒ|jƒdS(N(R=R@tremoveR'R<(R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRäs(RRtsetR@RR(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR=Às		 RBcB@s)eZiZd„Zd„Zd„ZRS(cC@stt|ƒjƒtj|ƒ|_|jtjkrudtj	kr[t
j|jƒ‚qutj
d|jfƒntjj|jdƒtj|jcd7<|j|dƒy!tj|jtjtjBƒWn(tk
rü}t
j|j|ƒ‚nXdS(NR>s,Read lock taken w/ an open write lock on: %siitrb(R?RBRRR(R'R=R@RRRRARR1t
setdefaultR4R9R:R&tLOCK_SHRER*(R
R'R3((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRís	!cC@sNtj|j}|dkr,tj|j=n|dtj|j<|jƒdS(Ni(RBR@R'R<(R
tcount((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRs
cC@sc|jtjkr+td|jfƒ‚nyt|ƒ}Wntjk
rXt|fSXt|fS(s[Try to grab a write lock on the file.

            On platforms that support it, this will upgrade to a write lock
            without unlocking the file.
            Otherwise, this will release the read lock, and try to acquire a
            write lock.

            :return: A token which can be used to switch back to a read lock.
            sfile already locked: %r(	R'R=R@tAssertionErrort_fcntl_TemporaryWriteLockRt	LockErrortFalsetTrue(R
twlock((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyttemporary_write_locks
(RRR@RRRS(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRBés		RNcB@s eZdZd„Zd„ZRS(s„A token used when grabbing a temporary_write_lock.

        Call restore_read_lock() when you are done with the write lock.
        cC@sUtt|ƒjƒ||_|j|_tj|j}|dkrYtj|jƒ‚n|jt	jkr„t
d|jfƒ‚nyt|jdƒ}WnOtk
rë}|j
t
jt
jfkråtj|jt|ƒƒ‚n‚nXytj|tjtjBƒWn(tk
r4}tj|j|ƒ‚nXt	jj|jƒ||_dS(Nisfile already locked: %rsrb+(R?RNRt
_read_lockR'RBR@RRAR=RMR)R*R+R,R-R.R/R9R:RDRERCR&(R
t	read_lockRLtnew_fR3((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR's*	cC@sItj|jtjƒ|jƒtjj|jƒ|j	}d|_	|S(sRestore the original ReadLock.N(R9R:R&R;R6R=R@RGR'RTR(R
RU((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pytrestore_read_lockKs
		(RRRRRW(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRN!s	$R9t_w32c_FileLockcB@seZd„Zd„ZRS(cC@sàtj|ƒ|_y+t|||dtjtjdƒ|_Wnot	j
k
r®}|jdtj
kr}tj||ƒ‚n|jdtjkr¨tj||ƒ‚n‚nXtj|j|ƒ}tj||ƒ|_|jS(Ni(RR(R'twin32file_CreateFileRt	win32filetOPEN_ALWAYStFILE_ATTRIBUTE_NORMALt_handlet
pywintypesterrortargstwinerrortERROR_ACCESS_DENIEDRR.tERROR_SHARING_VIOLATIONRAt_open_osfhandletostfdopenR&(R
R'taccesstsharetcflagstpymodeR3tfd((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR4es	cC@s|jƒd|_dS(N(R6RR](R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRus
(RRR4R(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRXcs	t_w32c_ReadLockcB@seZd„Zd„ZRS(cC@s9tt|ƒjƒ|j|tjtjtjdƒdS(NRI(	R?RlRR4RZtGENERIC_READtFILE_SHARE_READRetO_RDONLY(R
R'((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR{scC@sN|jƒyt|jƒ}Wn$tjk
rCtt|jƒfSXt|fS(s[Try to grab a write lock on the file.

            On platforms that support it, this will upgrade to a write lock
            without unlocking the file.
            Otherwise, this will release the read lock, and try to acquire a
            write lock.

            :return: A token which can be used to switch back to a read lock.
            (Rt_w32c_WriteLockR'RRORPRlRQ(R
RR((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRS€s
(RRRRS(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRlzs	RpcB@seZd„Zd„ZRS(cC@s=tt|ƒjƒ|j|tjtjBdtjdƒdS(Nisrb+(	R?RpRR4RZRmt
GENERIC_WRITERetO_RDWR(R
R'((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR•s	cC@s|jƒt|jƒS(sRestore the original ReadLock.(RRlR'(R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRW›s
(RRRRW(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRp”s	tpywin32(tDWORDtLPCSTRtLPCWSTRtCreateFileWtCreateFileAtLPTSTRcB@seZd„ZRS(cC@stj||jdƒƒS(Ntmbcs(Rut__new__tencode(tclstobj((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR{°s(RRR{(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRy¯siÿÿÿÿI€i@iii€ii t_ctypes_FileLockcB@seZd„Zd„ZRS(c	C@sÕtj|ƒ|_t|||dttdƒ}|tdfkr§tj	ƒ}|j
dtkrvtj
||ƒ‚n|j
dtkržtj||ƒ‚n|‚ntj||ƒ}tj||ƒ|_|jS(Ni(RR(R't_CreateFileRR[R\tINVALID_HANDLE_VALUEtctypestWinErrorR`RbRR.RcRAtmsvcrttopen_osfhandleReRfR&(	R
R'RgRhRiRjthandleR3Rk((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR4Ìs	cC@s|jƒdS(N(R6(R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRÛs(RRR4R(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRÊs	t_ctypes_ReadLockcB@seZd„Zd„ZRS(cC@s3tt|ƒjƒ|j|tttjdƒdS(NRI(R?R‡RR4RmRnReRo(R
R'((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRàscC@sN|jƒyt|jƒ}Wn$tjk
rCtt|jƒfSXt|fS(s[Try to grab a write lock on the file.

            On platforms that support it, this will upgrade to a write lock
            without unlocking the file.
            Otherwise, this will release the read lock, and try to acquire a
            write lock.

            :return: A token which can be used to switch back to a read lock.
            (Rt_ctypes_WriteLockR'RRORPR‡RQ(R
RR((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRSås
(RRRRS(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR‡ßs	RˆcB@seZd„Zd„ZRS(cC@s7tt|ƒjƒ|j|ttBdtjdƒdS(Nisrb+(R?RˆRR4RmRqReRr(R
R'((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRùscC@s|jƒt|jƒS(sRestore the original ReadLock.(RR‡R'(R
((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRWþs
(RRRRW(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyRˆøs	R‚sNWe must have one of fcntl, pywin32, or ctypes available to support OS locking.t_RelockDebugMixincB@seZdZdZd„ZRS(s#Mixin support for -Drelock flag.

    Add this as a base class then call self._note_lock with 'r' or 'w' when
    acquiring a read- or write-lock.  If this object was previously locked (and
    locked the same way), and -Drelock is set, then this will trace.note a
    message about it.
    cC@sbdtjkrU|j|krU|dkr3d}nd}tjtdƒ||ƒn||_dS(Ntrelocktrtreadtwrites{0!r} was {1} locked again(RRt
_prev_lockRtnoteR(R
t	lock_typet	type_name((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyt
_note_locks	N(RRRRRŽR’(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyR‰scc@s%|jƒz	|VWd|jƒXdS(N(t
lock_writeR(tlockable((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pytwrite_locked(s
	(TRt
__future__Rt
contextlibR+RetsysRtbzrlibRRRRtbzrlib.hooksRtbzrlib.i18nRRtobjectRRRR#R9RQt
have_fcntltImportErrorRPthave_pywin32thave_ctypes_win32tplatformR„RZR^RaR‚R%t
_lock_classesR8R=RBRNtappendtpathtsupports_unicode_filenamesRwRYt
CreateFileRXRlRptctypes.wintypesRtRuRvtc_void_ptLPSECURITY_ATTRIBUTEStc_inttHANDLEt_function_nameRytWINFUNCTYPEtwindlltkernel32R€RRmRqRnR[R\RbRcRR‡RˆtlenR7t
_lock_typet	WriteLocktReadLockR‰tcontextmanagerR•(((s//usr/lib/python2.7/dist-packages/bzrlib/lock.pyt<module>"s¬"		


$



!)87				

Copyright © 2017 || Recoded By Mr.Bumblebee