Rfc@sdZddlZddlZddlZddlZdddZdddZdZd Zdd Z d Z e d kry eWqe k rZejejkrqqXndS( sConsolidate a bunch of CVS or RCS logs read from stdin. Input should be the output of a CVS or RCS logging command, e.g. cvs log -rrelease14: which dumps all log messages from release1.4 upwards (assuming that release 1.4 was tagged with tag 'release14'). Note the trailing colon! This collects all the revision records and outputs them sorted by date rather than by file, collapsing duplicate revision record, i.e., records with the same message for different files. The -t option causes it to truncate (discard) the last revision log entry; this is useful when using something like the above cvs log command, which shows the revisions including the given tag, while you probably want everything *since* that tag. The -r option reverses the output (oldest first; the default is oldest last). The -b tag option restricts the output to *only* checkin messages belonging to the given branch tag. The form -b HEAD restricts the output to checkin messages belonging to the CVS head (trunk). (It produces some output if tag is a non-branch tag, but this output is not very useful.) -h prints this message and exits. XXX This code was created by reverse engineering CVS 1.9 and RCS 5.7 from their output. iNt=iMs t-ic Cs'd}d}d }tjtjdd\}}xt|D]l\}}|dkrYd}q8|dkrnd}q8|dkr|}q8|dkr8tGHtjdq8q8Wg}xKttj}|sPnt||} |r| d=n| |t |)q|j |s|j nt |d S( s Main programiistrb:hs-ts-rs-bs-hiN( tNonetgetopttsystargvt__doc__texitt read_chunktstdint digest_chunktlentsorttreverset format_output( t truncate_lastR tbranchtoptstargstotatdatabasetchunktrecords((s./usr/lib64/python2.7/Tools/scripts/logmerge.pytmain*s6          cCsg}g}xw|j}|s%Pn|tkrK|rG|j|nPn|tkrv|r|j|g}qq|j|q|S(skRead a chunk -- data for one file, ending with sep1. Split the chunk in parts separated by sep2. (treadlinetsep1tappendtsep2(tfpRtlinestline((s./usr/lib64/python2.7/Tools/scripts/logmerge.pyRHs      c Cs5|d}d}t|}x8|D]*}|| |kr#||j}Pq#q#Wd}|dkrfn"|dkrtjd}ni}d}d}x~|D]v}||krd}q|r|ddkr |j\} } | dd kr| d } n| || $s.0.t.t^s\.\d+$iisdate:t;t isauthor:itrevisionN( R tstripRtretcompiletsplittgettfindtreplacetescapetinserttmatchR(RRRtkeytkeylenRt working_filet revisionstfoundttagtrevRtrevlinetdatelinettexttwordstauthortdatewordttimewordtdate((s./usr/lib64/python2.7/Tools/scripts/logmerge.pyR `sx           &    "   "  "   c Csd}g}|jdx|D]\}}}}}||kr|rtGx+|D]#\}} } } |G| G| G| GHqRWtjj|ng}n|j||||f|}q WdS(N(NNNNN(RRRRtstdoutt writelines( RtprevtexttprevR?R3R7R<R:tp_datetp_working_filetp_revtp_author((s./usr/lib64/python2.7/Tools/scripts/logmerge.pyRs   t__main__(RRterrnoRR(RRRRRR Rt__name__tIOErrortetEPIPE(((s./usr/lib64/python2.7/Tools/scripts/logmerge.pyt#s0   E