\x89\x50\x4E\x47\x0D\x0A\x1A\x0A PNG  \x89\x50\x4E\x47\x0D\x0A\x1A\x0A  13\c@@sddlmZddlZddlZddlZddlZddlmZddlm Z m Z m Z m Z dZ defdYZdd Zd ZejZejZdS( i(tabsolute_importNi(t_(tencodingterrortpycompattutilcC@stj|jS(N(Rthfsignorecleantlower(ts((s8/usr/lib64/python2.7/site-packages/mercurial/pathutil.pyt _lowercleanst pathauditorcB@s>eZdZdeedZddZdZdZ RS(s^ensure that a filesystem path contains no banned components. the following properties of a path are checked: - ends with a directory separator - under top-level .hg - starts at the root of a windows drive - contains ".." More check are also done about the file system states: - traverses a symlink (e.g. a/symlink_here/b) - inside a nested repository (a callback can be used to approve some nested repositories, e.g., subrepositories) The file system checks are only done when 'realfs' is set to True (the default). They should be disable then we are auditing path for operation on stored history. If 'cached' is set to True, audited paths and sub-directories are cached. Be careful to not keep the cache of unmanaged directories for long because audited paths may be replaced with symlinks. cC@s}t|_t|_||_||_||_||_tjj |rmt j | rmt j |_ n d|_ dS(NcS@s|S(N((tx((s8/usr/lib64/python2.7/site-packages/mercurial/pathutil.pyt4s( tsettauditedt auditeddirtroott_realfst_cachedtcallbacktostpathtlexistsRtfscasesensitivetnormcase(tselfRRtrealfstcached((s8/usr/lib64/python2.7/site-packages/mercurial/pathutil.pyt__init__*s      "cC@stj|}|j|}||jkr1dStj|r\tjtd|ntj|}t j j |dst |dd kst j|krtjtd|nxo|D]g}d|kr|jdd \}}|jr0|jdkr0tjtd|q0qqWdt |krg|D]}t |j^qM}xqdD]f}||d krr|j|} t j j|| } tjtd |t j| fqrqrWntj|} |j| jg} xtt|D]x} t jj|| d  }t jj| | d  }||jkrjqn|jr|j||n| j|qW|jr|jj||jj | ndS(sPCheck the relative path. path may contain a pattern (e.g. foodir/**.txt)Ns$path ends in directory separator: %sis.hgs.hg.ts#path contains illegal component: %st~itHGtHG8B6Cs"path '%s' is inside nested repo %r(s.hgs.hg.R(RR (s.hgs.hg.(!Rt localpathRRt endswithsepRtAbortRt splitpathRRt splitdriveR RtospardirtsplittisdigittupperRtindextjointbytestrtpoptrangetlentossepRRt_checkfstappendRtaddtupdate(RRtmodetnormpathtpartstptfirsttlasttlpartstpostbaset normpartstprefixestitprefixt normprefix((s8/usr/lib64/python2.7/site-packages/mercurial/pathutil.pyt__call__6sP  % #    cC@s9tjj|j|}ytj|}Wn:tk rg}|jtjtjtj fkr5q5nXt j |j rt dtj|tj|f}tj|nt j|j r5tjjtjj|dr5|j s|j| r5t d}tj||tj|fq5ndS(s3raise exception if a file system backed check failss"path %r traverses symbolic link %rs.hgs"path '%s' is inside nested repo %rN(RRR+RtlstattOSErrorterrnotENOENTtENOTDIRtEINVALtstattS_ISLNKtst_modeRRR,RR#tS_ISDIRtisdirR(RRARtcurpathtstterrtmsg((s8/usr/lib64/python2.7/site-packages/mercurial/pathutil.pyR1ns!  ! cC@s4y||tSWnttjfk r/tSXdS(N(tTrueRERR#tFalse(RR((s8/usr/lib64/python2.7/site-packages/mercurial/pathutil.pytchecks  N( t__name__t __module__t__doc__tNoneRSRTRRCR1RU(((s8/usr/lib64/python2.7/site-packages/mercurial/pathutil.pyR s  8 c C@sEtj|r|}n |tj}|}tjj|sXtjj|||}ntjj|}|dkrt |}n||kr|j |r|t |}||tj |S||krdSg}xtrytj||}Wntk rt}nX|rY|s&dS|jtjj|}||tj |Stj|\}} |j| ||krPn|}qWd} yj||krt||||tj||d} | jtjr| d } ntd| } nWntjk rnXtjtd||fd| dS(sreturn the canonical path of myname, given cwd and root >>> def check(root, cwd, myname): ... a = pathauditor(root, realfs=False) ... try: ... return canonpath(root, cwd, myname, a) ... except error.Abort: ... return 'aborted' >>> def unixonly(root, cwd, myname, expected='aborted'): ... if pycompat.iswindows: ... return expected ... return check(root, cwd, myname) >>> def winonly(root, cwd, myname, expected='aborted'): ... if not pycompat.iswindows: ... return expected ... return check(root, cwd, myname) >>> winonly(b'd:\\repo', b'c:\\dir', b'filename') 'aborted' >>> winonly(b'c:\\repo', b'c:\\dir', b'filename') 'aborted' >>> winonly(b'c:\\repo', b'c:\\', b'filename') 'aborted' >>> winonly(b'c:\\repo', b'c:\\', b'repo\\filename', ... b'filename') 'filename' >>> winonly(b'c:\\repo', b'c:\\repo', b'filename', b'filename') 'filename' >>> winonly(b'c:\\repo', b'c:\\repo\\subdir', b'filename', ... b'subdir/filename') 'subdir/filename' >>> unixonly(b'/repo', b'/dir', b'filename') 'aborted' >>> unixonly(b'/repo', b'/', b'filename') 'aborted' >>> unixonly(b'/repo', b'/', b'repo/filename', b'filename') 'filename' >>> unixonly(b'/repo', b'/repo', b'filename', b'filename') 'filename' >>> unixonly(b'/repo', b'/repo/subdir', b'filename', b'subdir/filename') 'subdir/filename' Risconsider using '--cwd %s's%s not under root '%s'thintN(RR"RR0RRtisabsR+R6RYR t startswithR/tpconvertRStsamefileRERTtreverseR'R2t canonpathtpathtotendswithRRR#( RtcwdtmynametauditortrootseptnametrelRtdirnametbasenameRZtrelpath((s8/usr/lib64/python2.7/site-packages/mercurial/pathutil.pyR`sZ*                 cC@sFtjj|\}}t|ttjkr>|tjS|SdS(snormalize the specified path as path prefix Returned value can be used safely for "p.startswith(prefix)", "p[len(prefix):]", and so on. For efficiency, this expects "path" argument to be already normalized by "os.path.normpath", "os.path.realpath", and so on. See also issue3033 for detail about need of this function. >>> normasprefix(b'/foo/bar').replace(pycompat.ossep, b'/') '/foo/bar/' >>> normasprefix(b'/').replace(pycompat.ossep, b'/') '/' N(RRR%R/RR0(RtdR8((s8/usr/lib64/python2.7/site-packages/mercurial/pathutil.pyt normasprefixs (t __future__RRFRt posixpathRJti18nRRRRRRR tobjectR RYR`RmR+Ri(((s8/usr/lib64/python2.7/site-packages/mercurial/pathutil.pyts    " w d