Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/hgext/bookmarks.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
�c@sNdZddklZddklZlZlZlZddkl	Z	l
Z
lZlZl
Z
ddkZd�Zd�Zd�Zd	�Zddeedd
�Zd�Zdd
�Zd�Zd�Zd�Zheddeed�fddded�fddeed�fddded�fged�fd<ZdS(s	track a line of development with movable markers

Bookmarks are local movable markers to changesets. Every bookmark
points to a changeset identified by its hash. If you commit a
changeset that is based on a changeset that has a bookmark on it, the
bookmark shifts to the new changeset.

It is possible to use bookmark names in every revision lookup (e.g. hg
merge, hg update).

By default, when several bookmarks point to the same changeset, they
will all move forward together. It is possible to obtain a more
git-like experience by adding the following configuration option to
your .hgrc::

  [bookmarks]
  track.current = True

This will cause Mercurial to track the bookmark that you are currently
using, and only update it. This is similar to git's approach to
branching.
i�(t_(tnullidtnullrevthextshort(tutiltcommandst	localrepotrepairt
extensionsNcCs�yp|io|iSnh|_xK|id�D]:}|i�idd�\}}|i|�|i|<q1WWnnX|iS(sCParse .hg/bookmarks file and return a dictionary

    Bookmarks are stored as {HASH}\s{NAME}\n (localtags format) values
    in the .hg/bookmarks file. They are read by the parse() method and
    returned as a dictionary with name => hash values.

    The parsed dictionary is cached until a write() operation is done.
    t	bookmarkst i(t
_bookmarkstopenertstriptsplittlookup(trepotlinetshatrefspec((s"/sys/lib/python/hgext/bookmarks.pytparse$s	
	cCs�tii|id��o&ti|id�|id��nt|�|jot|d�n|i	�}z`|i
dddt�}x7|i�D])\}}|i
dt|�|f�q�W|i�Wd|i�XdS(s�Write bookmarks

    Write the given bookmark => hash dictionary to the .hg/bookmarks file
    in a format equal to those of localtags.

    We also store a backup of the previous state in undo.bookmarks that
    can be copied back on rollback.
    R
sundo.bookmarkstwt
atomictemps%s %s
N(tostpathtexiststjoinRtcopyfiletcurrentt
setcurrenttNonetwlockR
tTruet	iteritemstwriteRtrenametrelease(RtrefsR tfileRtnode((s"/sys/lib/python/hgext/bookmarks.pyR#8s	&
!cCs�|io|iSnd}tii|id��oN|id�}|i�pdgd}|djo
d}n|i�n||_|S(s�Get the current bookmark

    If we use gittishsh branches we have a current bookmark that
    we are on. This function returns the name of the bookmark. It
    is stored in .hg/bookmarks.current
    sbookmarks.currenttiN(	t_bookmarkcurrentRRRRRR
t	readlinestclose(RtmarkR'((s"/sys/lib/python/hgext/bookmarks.pyRNs


	cCs�t|�|jodSnt|�}|oH||jo;t|�o.|t|�|id�i�jodSn||jo
d}n|i�}z3|idddt�}|i|�|i�Wd|i	�X||_
dS(s�Set the name of the bookmark that we are currently on

    Set the name of the bookmark that we are on (hg update <bookmark>).
    The name is recorded in .hg/bookmarks.current
    Nt.R)sbookmarks.currentRR(RRt	changectxR(R R
R!R#R$R%R*(RR-R&R R'((s"/sys/lib/python/hgext/bookmarks.pyRbs3


c
Cs�|iotpt}t|�}|id�i�}	|o�||jotitd���n||jo!|otitd���n|djotitd���n||||<||=t
|�|jot||�nt||�dSn|o�|djotitd���n||jotitd���n|t
|�jot|d�n||=t||�dSn|djod|jotitd���n|i
�}||jo!|otitd���n||i�jp||ii�jo!|otitd	���n|o|i|�||<n'|id�i�||<t||�t||�dSn|djo�otitd���nt|�d
jo|id�n�x�|i�D]�\}
}|idd
�o1|
t
|�jo||	jodpd}n||	jodpd}|id||
|ii|�||�f�qWdSndS(s?track a line of development with movable markers

    Bookmarks are pointers to certain commits that move when
    committing. Bookmarks are local. They can be renamed, copied and
    deleted. It is possible to use bookmark names in 'hg merge' and
    'hg update' to merge and update respectively to a given bookmark.

    You can use 'hg bookmark NAME' to set a bookmark on the working
    directory's parent revision with the given name. If you specify
    a revision using -r REV (where REV may be an existing bookmark),
    the bookmark is assigned to that revision.
    R.s&a bookmark of this name does not exists*a bookmark of the same name already existssnew bookmark name requiredNsbookmark name requireds
s%bookmark name cannot contain newliness5a bookmark cannot have the name of an existing branchisno bookmarks set
R
s
track.currentt*Rs %s %-25s %d:%s
(t	debugflagRRRR/R(RtAbortRRRRR#Rt
branchtagstdirstatetbranchRtlentstatusR"t
configboolt	changelogtrev(
tuiRR-R:tforcetdeleteR$thexfntmarkstcurtbmarktntprefix((s"/sys/lib/python/hgext/bookmarks.pytbookmark|sn








)



1	*c	Cs|i|�}|g}g}x�t|t|��D]�}|i|�}|d|jp|d|job|i|�|dtjo@x=|D]1}||jo||jo|i|�q�q�Wq�q4q4Wg}|D]}||jo||q�q�~S(Nii(R:txrangeR6t
parentrevstappendR(	R9R(tsrevttostript	saveheadstrtparentstpt_[1]((s"/sys/lib/python/hgext/bookmarks.pyt_revstostrip�s	"
!tallcCs�t|i|�}t|�}g}xD|i�D]6\}}	|ii|	�|jo|i|�q1q1W|||||�t|�djo;x'|D]}
|id�i�||
<q�Wt	||�ndS(s~Strip bookmarks if revisions are stripped using
    the mercurial.strip method. This usually happens during
    qpush and qpopiR.N(
ROR9RR"R:RGR6R/R(R#(toldstripR;RR(tbackupt	revisionsR?tupdateR-RBtm((s"/sys/lib/python/hgext/bookmarks.pyR�s
cs\t|ti�pdSnd|_d|_d|if��fd��Y��|_dS(Nt
bookmark_repocs_eZ�fd�Z�fd�Ze��fd�Ze��fd�Z�fd�ZRS(csUtii|id��o&ti|id�|id��nt�|�i�S(Nsundo.bookmarksR
(RRRRRR$tsupertrollback(tself(RV(s"/sys/lib/python/hgext/bookmarks.pyRX�s&csZ|idjot|�|_n||ijo|i|}nt�|�i|�S(N(RRRRWR(RYtkey(RV(s"/sys/lib/python/hgext/bookmarks.pyR�s
c
sA|i�}z#t�|�i||�}|djodSn|ii|�}|dtjo|df}nt|�}t}�i	dd�o<t
|�}|o%|||jo|||<t}qn?x;|i�D]-\}}	|	|jo|||<t}q�q�|ot
||�n|SWd|i�XdS(sBAdd a revision to the repository and
            move the bookmarkiiR
s
track.currentN(R RWt	commitctxRR9RLRRtFalseR8RR!titemsR#R%(
RYtctxterrorR R(RLR?RTR-RB(R;RV(s"/sys/lib/python/hgext/bookmarks.pyR[�s0




cs|ii�}t�|�i||||�}|djo|Sn|ii�}t|�}t}	�idd�o<t	|�}
|
o%||
|jo|||
<t
}	q�?x;|i�D]-\}
}||jo|||
<t
}	q�q�W|	ot||�n|S(NiR
s
track.current(
R4RLRWtaddchangegroupR9ttipRR\R8RR!R]R#(RYtsourcetsrctypeturltemptyokRLtresultR(R?RTR-RB(R;RV(s"/sys/lib/python/hgext/bookmarks.pyR`s*




cs8t�|�i�\}}|it|��||fS(s Merge bookmarks with normal tags(RWt	_findtagsRTR(RYttagsttagtypes(RV(s"/sys/lib/python/hgext/bookmarks.pyRg2s(t__name__t
__module__RXRR\R[R`Rg((R;RV(s"/sys/lib/python/hgext/bookmarks.pyRV�s
(t
isinstanceRtlocalrepositoryRRR*t	__class__(R;R((R;RVs"/sys/lib/python/hgext/bookmarks.pyt	reposetup�s		"IcCsDtitdt�|idd�otitidt�ndS(NRR
s
track.currentRT(	R	twrapfunctionRRR8twrapcommandRttabletupdatecurbookmark(R;((s"/sys/lib/python/hgext/bookmarks.pytuisetup:scOsY|||||�}|d}|o!t|�djo|d}nt||�|S(srSet the current bookmark

    If the user updates to a bookmark we update the .hg/bookmarks.current
    file.
    R:i(R6R(torigR;RtargstoptstresR:((s"/sys/lib/python/hgext/bookmarks.pyRs?s

tfR<RKR:R)trevisiontdR=sdelete a given bookmarkRUR$srename a given bookmarks0hg bookmarks [-f] [-d] [-m NAME] [-r REV] [NAME]R
(t__doc__tmercurial.i18nRtmercurial.nodeRRRRt	mercurialRRRRR	RRR#RRRR\RDRORRoRtRstcmdtable(((s"/sys/lib/python/hgext/bookmarks.pys<module>s*"(				L		T		


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.