
    6hP              	         S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	J
r
  SSKJrJrJrJrJrJrJrJrJrJrJrJrJrJr  SSKJrJrJr  0 r\R>                  " \5      rSr Sr!S	r"S
r#\"\RH                  0r%S r&S r'S r(S r)S r*S r+S r,S r-S r.S r/S r0 " S S\Rb                  " SS5      5      r2 " S S5      r3Sr4\" SSS/\Rj                   V s/ s H  o S   \4;  d  M  U PM     sn -   S \Rl                  S!9S" 5       r7gs  sn f )#ztrack previous positions of bookmarks (EXPERIMENTAL)

This extension adds a new command: `hg journal`, which shows you where
bookmarks were previously located.

    )annotationsN)_)binhex)	bookmarkscmdutildispatchencodingerror
extensionshg	localrepolock
logcmdutilmergepycompat	registrarutil)dateutilprocutil
stringutils   ships-with-hg-cores   bookmarks
   wdirparentc                   S[         l        [        R                  " [        S[
        5        [        R                  " [        R                  S[        5        [        R                  " [        R                  S[        5        [        R                  " [        S[        5        [        R                  " [        S[        5        g )NF
runcommand_write   dirstate	postshare	copystore)r   MAYBE_USE_RUST_UPDATEr   wrapfunctionr	   r   r   bmstorerecordbookmarkswrapfilecacher   localrepositorywrapdirstater   wrappostshareunsharejournal)uis    //usr/lib/python3/dist-packages/hgext/journal.pyextsetupr)   G   su    "'EHlJ?I--xI!!; B];B^<    c                    UR                  5       (       aX  [        U5      Ul        UR                  R	                  S5        [
        R                  " US5      u  p#U(       a  [        X5        g g g )N   namejournalr   )localjournalstoragejournal_wlockfreeprefixaddr   isfilecached_setupdirstate)r'   repodirstatecacheds       r(   	reposetupr7   R   sY    zz||%d+!!.1$11$D 4*	  r*   c                <    [         R                  " U6   U " XX4/UQ76 $ )z;Track the command line options for recording in the journal)r.   recordcommand)origluir4   cmdfullargsargss         r(   r   r   _   s"      (+30400r*   c                R    U R                   Ul        UR                  S[        5        g N   journal)r/   r.   addparentchangecallbackrecorddirstateparents)r4   r5   s     r(   r3   r3   e   s    "llH$$Z1FGr*   c                N    U " U5      n[        US5      (       a  [        X5        U$ )z5Make journal storage available to the dirstate objectr/   )hasattrr3   )r:   r4   r5   s      r(   r$   r$   k   s%    DzHtYt&Or*   c                &   [        U5      n[        U5      n[        U S5      (       aj  US   U R                  R                  :X  a  USS OUnUS   U R                  R                  :X  a  USS OUnU R                  R                  [        SX45        gg)z3Records all dirstate parent changes in the journal.r.      N   .)listrE   _nodeconstantsnullidr.   recordwdirparenttype)r5   oldnew	oldhashes	newhashess        r(   rC   rC   s   s    
s)C
s)Cx)**"1v)@)@)G)GGCGS	"1v)@)@)G)GGCGS	&&D)	
	 +r*   c                   UR                   n[        US5      (       a  [        R                  " U5      nUR	                  5        VVs1 s H  u  pVUiM	     nnnUR                  S UR	                  5        5       5        [        U5       Ha  nUR                  XR                  5      n	UR                  XR                  5      n
X:w  d  M@  UR                  R                  [        XU	5        Mc     U " X5      $ s  snnf )z,Records all bookmark changes in the journal.r/   c              3  *   #    U  H	  u  pUv   M     g 7fN ).0bns      r(   	<genexpr>"recordbookmarks.<locals>.<genexpr>   s     5}tq}s   )_reporE   r   r    itemsupdatesortedgetrK   r/   rL   bookmarktype)r:   storefpr4   oldmarksrW   rX   	all_marksmarkvalueoldvalues              r(   r!   r!      s    ;;DtY$$T*#+>>#34#341Q#3	45u{{}559%DIIdKK0E||D++6H ##L$%H	 &
 ? 5s   C6c                     [        U R                  R                  S5      R                  5       5      $ ! [         a    [        5       s $ f = f)z,A set of shared features for this repository   shared)setvfsread
splitlinesFileNotFoundError)r4   s    r(   _readsharedfeaturesro      s>    488==+66899 us   14 A
Ac               /    #    UR                  S[        5      nU  Vs/ s H  n[        U5      PM     n n0 n[        U 5       H  u  pS [	        U5      XS/XE'   M     U(       a8  U" UR                  5       5      u  penUv    [	        U5      XE   S'   U(       a  M7  ggs  snf ! [
         a     Mk  f = f! [
         a    XE	  N/f = f7f)zGiven a set of sorted iterables, yield the next entry in merged order

Note that by default entries go from most recent to oldest.
orderr   N)popmaxiter	enumeratenextStopIterationvalues)	iterableskwargsrq   ititerable_mapkeyrf   s          r(   _mergeentriesiterr~      s     
 JJw$E$-.IbbII.
 LY'	!%b3 3L ( |2245B	"#'8La 	 , /  		  	"!	"s]   CBCB(C?B0 CC
B-)C,B--C0B?<C>B??Cc                    UR                  5          U " X40 UD6  UR                  SS5       nUR                  S5        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)z<Mark this shared working copy as sharing journal informationri      as   journal
N)wlockrk   write)r:   
sourcerepodestreporz   rb   s        r(   r%   r%      sR    		Z,V,\\)T*bHH\" + 
	** 
	s!   A!AA!
A	A!!
A/c                  ^
 UR                   U:X  Ga&  UR                  5       (       Ga  [        US5      (       a  [        R                  " U5      n[        U5      m
U(       a  T
S1:  a  UR                  R                  S5      (       a4  UR                  R                  S5      n[        R                  " XUS-   5        UR                  nUR                  UR                  SSS9nU
4S jUR                  UR                  SS	9 5       n[        Xx[        S
9 H  n	UR                  UR                  U	5        M!     U " XU5      $ )z9Copy shared journal entries into this repo when unsharingr/   rA   r,   s   .baks   namejournal.bakF)filename_newestfirstc              3  r   >#    U  H,  n[         R                  UR                  5      T;   d  M(  Uv   M.     g 7frT   )sharednamespacesr_   	namespace)rV   esharedfeaturess     r(   rY   !unsharejournal.<locals>.<genexpr>   s1      JA#''4F Js   '7	7)r   )rq   )pathsharedrE   r   sharedreposourcero   rk   existsjoinr   renamer/   _openr~   minr   )r:   r'   r4   repopath
sharedrepojournalpathstorager-   r   entryr   s             @r(   r&   r&      s    yyH743K3K((.
,T2.J<7 xx~.."hhmmN;Kw)>?llGMM#5E " E z~~EJF
 +5Dtxx/ E (##r*   c                  R    \ rS rSrSr\S 5       rS r\R                  " \5      r
Srg)journalentry   a|  Individual journal entry

* timestamp: a mercurial (time, timezone) tuple
* user: the username that ran the command
* namespace: the entry namespace, an opaque string
* name: the name of the changed item, opaque string with meaning in the
  namespace
* command: the hg command that triggered this record
* oldhashes: a tuple of one or more binary hashes for the old location
* newhashes: a tuple of one or more binary hashes for the new location

Handles serialisation from and to the storage format. Fields are
separated by newlines, hashes are written out in hex separated by commas,
timestamp and timezone are separated by a space.

c           	     $   UR                  S5      u  nnnnnnnUR                  5       u  p[        U	5      [        U
5      p[        S UR                  S5       5       5      n[        S UR                  S5       5       5      nU " X4UUUUUU5      $ )N   
c              3  8   #    U  H  n[        U5      v   M     g 7frT   r   rV   hashs     r(   rY   +journalentry.fromstorage.<locals>.<genexpr>        F0E#d))0E      ,c              3  8   #    U  H  n[        U5      v   M     g 7frT   r   r   s     r(   rY   r      r   r   )splitfloatinttuple)clslinetimeusercommandr   namerP   rQ   	timestamptzs              r(   fromstoragejournalentry.fromstorage   s     JJu	


	i(#b'2F	0EFF	F	0EFF	O
 	
r*   c           	        SR                  [        [        R                  U R                  5      5      nSR                  U R
                   Vs/ s H  n[        U5      PM     sn5      nSR                  U R                   Vs/ s H  n[        U5      PM     sn5      nSR                  UU R                  U R                  U R                  U R                  UU45      $ s  snf s  snf )z bytes representation for storage    r   r   )r   mapr   bytestrr   rP   r   rQ   r   r   r   r   )selfr   r   rP   rQ   s        r(   	__bytes__journalentry.__bytes__	  s    yyX--t~~>?IIT^^D^Ts4y^DE	IIT^^D^Ts4y^DE	zz				

 
	
 EDs   CC#rU   N)__name__
__module____qualname____firstlineno____doc__classmethodr   r   r
   	strmethod__str____static_attributes__rU   r*   r(   r   r      s2    " 
 
0
"   +Gr*   r   z9timestamp user command namespace name oldhashes newhashesc                  x    \ rS rSrSrSrSrS r\S 5       r	\
S 5       rS rS	 rS
 rS rSS jrS rSS jrSrg)r.   i  a=  Storage for journal entries

Entries are divided over two files; one with entries that pertain to the
local working copy *only*, and one with entries that are shared across
multiple working copies when shared using the share extension.

Entries are stored with NUL bytes as separators. See the journalentry
class for the per-entry structure.

The file format starts with an integer version, delimited by a NUL.

This storage uses a dedicated lock; this makes it easier to avoid issues
with adding entries that added when the regular wlock is unlocked (e.g.
the dirstate).

rU   Nc                J   [         R                  " 5       U l        UR                  U l        UR                  U l        S =U l        U l        UR                  5       (       aD  [        U5      n[        R                  " U5      nUb  SU;   a  UR                  U l        X l        g g g g r@   )r   getuserr   r'   rk   r   	sharedvfsr   ro   r   r   )r   r4   featuresr   s       r(   __init__journalstorage.__init__2  s    $$&	''88 043dn;;==*40H,,T2J%**@!+&.# +A% r*   c                    SR                  [        [        R                  [        R
                  5      5      nSU;   a  UR                  S5      S   S-   nU$ )Nr   r   r   s    ...)r   r   r   
shellquoter.   _currentcommand	partition)r   
commandstrs     r(   r   journalstorage.commandA  sP    YY##^%C%CD

 J#--e4Q7'AJr*   c                    Xl         g)z:Set the current hg arguments, stored with recorded entriesN)r   )r   r=   s     r(   r9   journalstorage.recordcommandK  s
    
 'r*   c                F    Uc  gU" 5       nUb  UR                   (       d  gU$ )z_Returns the lock if it's held, or None if it's not.

(This is copied from the localrepo class)
N)held)r   lockrefls      r(   _currentlockjournalstorage._currentlockR  s&    
 ?I9AFFr*   c           	     |   U R                  U R                  5      b  [        R                  " [	        S5      5      e[	        S5      UR
                  -  n [        R                  " USSUS9n[        R                  " U5      U l        U$ ! [        R                   a  nU R                  R                  [	        S5      X$R                  4-  5        [        R                  " USU R                  R                  SS	5      US9nU R                  R                  [	        S
5      UR                  -  5         SnANSnAff = f)z"Create a lock for the journal fileNs%   journal lock does not support nestings   journal of %ss   namejournal.lockr   )descs"   waiting for lock on %s held by %r
s   uis   timeouts   got lock after %s seconds
)r   _lockrefr   Abortr   baser   LockHeldr'   warnlocker	configintdelayweakrefref)r   rk   r   r   insts        r(   jlockjournalstorage.jlock^  s    T]]+7++a HIJJ!"SXX-	F		#2ADAA  A ~~ 	FGGLL89T;;<OO 		#!!%4	A GGLL9:QWWDEE	Fs   B	 	D;BD66D;c           	        [        U[        5      (       d  U/n[        U[        5      (       d  U/n[        [        R                  " 5       U R
                  U R                  UUUU5      nU R                  nU R                  b/  [        R                  U5      U R                  ;   a  U R                  nU R                  Xe5        g)a  Record a new journal entry

* namespace: an opaque string; this can be used to filter on the type
  of recorded entries.
* name: the name defining this entry; for bookmarks, this is the
  bookmark name. Can be filtered on when retrieving entries.
* oldhashes and newhashes: each a single binary hash, or a list of
  binary hashes. These represent the old and new position of the named
  item.

N)
isinstancerI   r   r   makedater   r   rk   r   r   r_   r   r   )r   r   r   rP   rQ   r   rk   s          r(   rL   journalstorage.recordt  s     )T**"I)T**"IIILL
 hh>>%  ##I.$2E2EEnnCr*   c                z   U R                  U5         U" SSS9 nUR                  S[        R                  5        UR	                  S5      R                  S5      S   nU(       aF  US[        -  :w  a9  U R                  R                  [        S5      U-  5         S S S 5        S S S 5        g U(       d  UR                  S[        -  S-   5        UR                  S[        R                  5        UR                  [        U5      S-   5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)	Nr,   s   a+b)moder             %ds&   unsupported journal file version '%s'
)r   seekosSEEK_SETrl   r   storageversionr'   r   r   r   SEEK_ENDbytes)r   rk   r   fversions        r(   r   journalstorage._write  s    ZZ_^&1Qq"++& &&)--e4Q7w%.*@@
 GGLLDEO  2 _  GGU^3u<=q"++&eu,-% 2 _11 _s0   D,B DD,+AD
D,
D)	%D,,
D:c              #    #    Ub  [         R                  " U5      S   nUb  [         R                  " U5      S   nU  H?  nUb  U" UR                  5      (       d  M  Ub  U" UR                  5      (       d  M;  Uv   MA     g7f)a-  Yield all journal entries with the given namespace or name

Both the namespace and the name are optional; if neither is given all
entries in the journal are produced.

Matching supports regular expressions by using the `re:` prefix
(use `literal:` to match names or namespaces that start with `re:`)

N)r   stringmatcherr   r   )r   r   r   r   s       r(   filteredjournalstorage.filtered  sz       "00;B?I++D1"5DE$Yu-G-GUZZ(8(8K s   A?Bc                   ^  T R                  T R                  5      nT R                  c  U$ U 4S jT R                  T R                  5       5       n[        X5      $ )z\Iterate over the storage

Yields journalentry instances for each contained journal record.

c              3     >#    U  H6  n[         R                  UR                  5      TR                  ;   d  M2  Uv   M8     g 7frT   )r   r_   r   r   )rV   r   r   s     r(   rY   *journalstorage.__iter__.<locals>.<genexpr>  s7      
/##AKK0D4G4GG A/s
   1A	A)r   rk   r   r~   )r   r-   r   s   `  r(   __iter__journalstorage.__iter__  sO     

488$>>!L
ZZ/

 !//r*   c              #    #    UR                  U5      (       d  g U" U5       nUR                  5       nS S S 5        WR                  S5      nU=(       a    US   nUS[        -  :w  a6  U=(       d    [	        S5      n[
        R                  " [	        S5      U-  5      eUSS  nU(       a  [        U5      nU H#  nU(       d  M  [        R                  U5      v   M%     g ! , (       d  f       N= f7f)Nr   r   r   s   not availables!   unknown journal file version '%s'rG   )
r   rl   r   r   r   r   r   reversedr   r   )	r   rk   r   r   r   rawlinesr   r   s	            r(   r   journalstorage._open  s     zz(##]a&&(C  		% $E!Hen,,4#3!4G++a DEOPP
 ab	UOED**400  ]s    C/CB+C/
C,(C/)r   r   r   r'   r   rk   )NN)r,   T)r   r   r   r   r   r   r   r   propertyr   r   r9   r   r   rL   r   r   r  r   r   rU   r*   r(   r.   r.     sd    " OH/   ' '
," H..*0(1r*   r.   )s	   no-mergess   graphrA   )r*      allNs   show history for all names)   c   commitsNs   show commit metadatarG   s   [OPTION]... [BOOKMARKNAME])helpcategoryc           
       ^ [         R                  " U5      nSnUR                  S5      (       a(  U(       a  [        R                  " [        S5      5      eSnU(       a  US   nU R                  SU5      mU4S jnUR                  S5      S	:w  a1  Uc  [        S
5      nOSU-  nU R                  [        S5      U-  5        [        R                  " U5      nSnU R                  S5        [        UR                  R                  US95       GH  u  pX:X  a    GOTR                  5         TR                  U R                   SSU" UR"                  5      5        TR%                  SSU" UR&                  5      5        TR                  U R                   SSUR(                  5        TR                  UR                  S5      =(       d    UR+                  S5      SSUR,                  5        TR                  U R                   SSTR/                  UR0                  S5      5        TR%                  SSUR2                  5        UR                  S5      (       d  GMJ  TR5                  5       (       a  [        R6                  " XU5      n
O%[        R8                  " XTR;                  S5      US9n
UR&                   H  n X   nU
R=                  U5        M     U
RE                  5         GM     TRG                  5         Uc  U R                  [        S 5      5        gg! [        R>                   a3  nTRA                  S[         RB                  " U5      -  5         SnAM  SnAff = f)!a6  show the previous position of bookmarks and the working copy

The journal is used to see the previous commits that bookmarks and the
working copy pointed to. By default the previous locations for the working
copy.  Passing a bookmark name will show all the previous positions of
that bookmark. Use the --all switch to show previous locations for all
bookmarks and the working copy; each line will then include the bookmark
name, or '.' for the working copy, as well.

If `name` starts with `re:`, the remainder of the name is treated as
a regular expression. To match a name that actually starts with `re:`,
use the prefix `literal:`.

By default hg journal only shows the commit hash and the command that was
running at that time. -v/--verbose will show the prior hash, the user, and
the time at which it happened.

Use -c/--commits to output log information on each commit hash; at this
point you can use the usual `--patch`, `--git`, `--stat` and `--template`
switches to alter the log output for these.

`hg journal -T json` can be used to produce machine readable output.

rH   r  s/   You can't combine --all and filtering on a nameNr   rA   c                N   > TR                  [        TR                  U 5      SSS9$ )Ns   noder   )r   sep)
formatlistr   hexfunc)nodesfms    r(   formatnodesjournal.<locals>.formatnodes&  s#    }}SU3't}LLr*   s   templates   jsons   the working copy and bookmarkss   '%s's   previous locations of %s:
)r   s   oldnodess   %s -> s   newnodess   %ss   users    %-8ss   re:s   names     %-8ss   dates    %ss   %Y-%m-%d %H:%M %1%2s   commands     %s
r  s
   changesets)diffoptss   %s

s   no recorded locations
)$r   byteskwargsr_   r   r   r   	formatterstatusr   getlimitpagerru   r/   r   	startitem	condwriteverboserP   r   rQ   r   
startswithr   
formatdater   r   isplainchangesetdisplayerchangesetformatternestedshowRepoLookupErrorplainr   closeend)r'   r4   r>   optsr   r  displaynamelimitr   count	displayerr   ctxr   r  s                 @r(   r/   r/     s   F %DDxx++DE  Aw	j$	'BM xx'<=>K!D.K
		!23kAB%EEHHZ!$,,"7"7T"7"BC>

JJYEOO0L	
 	e[%AB
RZZ(EJJ? 	HHV7 7JJ	
 	JJMM%//+AB		
 	Y688Jzz||&99"DI	&99bii6	 >*CNN3' ( OOU DX FFH}
		!./0  ,, >HHY)9)9!)<<==>s   9LM*(MM)8r   
__future__r   collectionsr   r   mercurial.i18nr   mercurial.noder   r   	mercurialr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   mercurial.utilsr   r   r   cmdtabler   
testedwithr   r`   rM   sharedbookmarksr   r)   r7   r   r3   r$   rC   r!   ro   r~   r%   r&   
namedtupler   r.   _ignoreoptslogoptsCATEGORY_CHANGE_ORGANIZATIONr/   )opts   0r(   <module>rB     sU   #  	  
      


H
% #
   "$$ =
+1H

 ":#$6A,CA,HQ1 Q1l ' 	:9 ooCosQ{)BsoC	D
 "55	b1	b1	 Ds   D$D