0000: 2f 2a 0a 2a 2a 20 43 6f 70 79 72 69 67 68 74 20 /*.** Copyright
0010: 28 63 29 20 32 30 30 37 20 44 2e 20 52 69 63 68 (c) 2007 D. Rich
0020: 61 72 64 20 48 69 70 70 0a 2a 2a 0a 2a 2a 20 54 ard Hipp.**.** T
0030: 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 20 66 his program is f
0040: 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 79 6f ree software; yo
0050: 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62 75 u can redistribu
0060: 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a 2a 2a 20 te it and/or.**
0070: 6d 6f 64 69 66 79 20 69 74 20 75 6e 64 65 72 20 modify it under
0080: 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74 68 65 the terms of the
0090: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62 GNU General Pub
00a0: 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 76 lic.** License v
00b0: 65 72 73 69 6f 6e 20 32 20 61 73 20 70 75 62 6c ersion 2 as publ
00c0: 69 73 68 65 64 20 62 79 20 74 68 65 20 46 72 65 ished by the Fre
00d0: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64 e Software Found
00e0: 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 69 ation..**.** Thi
00f0: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73 s program is dis
0100: 74 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20 tributed in the
0110: 68 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c hope that it wil
0120: 6c 20 62 65 20 75 73 65 66 75 6c 2c 0a 2a 2a 20 l be useful,.**
0130: 62 75 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20 but WITHOUT ANY
0140: 57 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 WARRANTY; withou
0150: 74 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 t even the impli
0160: 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 2a ed warranty of.*
0170: 2a 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 * MERCHANTABILIT
0180: 59 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 Y or FITNESS FOR
0190: 20 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 A PARTICULAR PU
01a0: 52 50 4f 53 45 2e 20 20 53 65 65 20 74 68 65 20 RPOSE. See the
01b0: 47 4e 55 0a 2a 2a 20 47 65 6e 65 72 61 6c 20 50 GNU.** General P
01c0: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 66 6f ublic License fo
01d0: 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a r more details..
01e0: 2a 2a 20 0a 2a 2a 20 59 6f 75 20 73 68 6f 75 6c ** .** You shoul
01f0: 64 20 68 61 76 65 20 72 65 63 65 69 76 65 64 20 d have received
0200: 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e a copy of the GN
0210: 55 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 U General Public
0220: 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 61 6c 6f 6e .** License alon
0230: 67 20 77 69 74 68 20 74 68 69 73 20 6c 69 62 72 g with this libr
0240: 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 77 72 69 ary; if not, wri
0250: 74 65 20 74 6f 20 74 68 65 0a 2a 2a 20 46 72 65 te to the.** Fre
0260: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64 e Software Found
0270: 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 35 39 20 ation, Inc., 59
0280: 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 2d 20 53 Temple Place - S
0290: 75 69 74 65 20 33 33 30 2c 0a 2a 2a 20 42 6f 73 uite 330,.** Bos
02a0: 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2d 31 ton, MA 02111-1
02b0: 33 30 37 2c 20 55 53 41 2e 0a 2a 2a 0a 2a 2a 20 307, USA..**.**
02c0: 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74 20 69 Author contact i
02d0: 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 2a 2a 20 20 nformation:.**
02e0: 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a 2a drh@hwaci.com.*
02f0: 2a 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68 * http://www.h
0300: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 2a 2a waci.com/drh/.**
0310: 0a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a .***************
0320: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0330: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0340: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0350: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0360: 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 66 69 6c 65 .**.** This file
0370: 20 63 6f 6e 74 61 69 6e 73 20 63 6f 64 65 20 75 contains code u
0380: 73 65 64 20 74 6f 20 66 69 6e 64 20 64 65 63 65 sed to find dece
0390: 6e 64 61 6e 74 73 20 6f 66 20 61 20 76 65 72 73 ndants of a vers
03a0: 69 6f 6e 0a 2a 2a 20 6f 72 20 6c 65 61 76 65 73 ion.** or leaves
03b0: 20 6f 66 20 61 20 76 65 72 73 69 6f 6e 20 74 72 of a version tr
03c0: 65 65 2e 0a 2a 2f 0a 23 69 6e 63 6c 75 64 65 20 ee..*/.#include
03d0: 22 63 6f 6e 66 69 67 2e 68 22 0a 23 69 6e 63 6c "config.h".#incl
03e0: 75 64 65 20 22 64 65 73 63 65 6e 64 61 6e 74 73 ude "descendants
03f0: 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 3c 61 73 .h".#include <as
0400: 73 65 72 74 2e 68 3e 0a 0a 0a 2f 2a 0a 2a 2a 20 sert.h>.../*.**
0410: 43 72 65 61 74 65 20 61 20 74 65 6d 70 6f 72 61 Create a tempora
0420: 72 79 20 74 61 62 6c 65 20 6e 61 6d 65 64 20 22 ry table named "
0430: 6c 65 61 76 65 73 22 20 69 66 20 69 74 20 64 6f leaves" if it do
0440: 65 73 20 6e 6f 74 0a 2a 2a 20 61 6c 72 65 61 64 es not.** alread
0450: 79 20 65 78 69 73 74 2e 20 20 4c 6f 61 64 20 74 y exist. Load t
0460: 68 69 73 20 74 61 62 6c 65 20 77 69 74 68 20 74 his table with t
0470: 68 65 20 52 49 44 20 6f 66 20 61 6c 6c 0a 2a 2a he RID of all.**
0480: 20 63 68 65 63 6b 2d 69 6e 73 20 74 68 61 74 20 check-ins that
0490: 61 72 65 20 6c 65 61 76 65 73 20 77 68 69 63 68 are leaves which
04a0: 20 61 72 65 20 64 65 63 65 6e 64 65 64 20 66 72 are decended fr
04b0: 6f 6d 0a 2a 2a 20 63 68 65 63 6b 2d 69 6e 20 69 om.** check-in i
04c0: 42 61 73 65 2e 20 20 49 66 20 69 42 61 73 65 3d Base. If iBase=
04d0: 3d 30 2c 20 66 69 6e 64 20 61 6c 6c 20 6c 65 61 =0, find all lea
04e0: 76 65 73 20 77 69 74 68 69 6e 20 74 68 65 0a 2a ves within the.*
04f0: 2a 20 65 6e 74 69 72 65 20 63 68 65 63 6b 2d 69 * entire check-i
0500: 6e 20 68 69 65 72 61 72 63 68 79 2e 0a 2a 2a 0a n hierarchy..**.
0510: 2a 2a 20 41 20 22 6c 65 61 66 22 20 69 73 20 61 ** A "leaf" is a
0520: 20 63 68 65 63 6b 2d 69 6e 20 74 68 61 74 20 68 check-in that h
0530: 61 73 20 6e 6f 20 63 68 69 6c 64 72 65 6e 20 69 as no children i
0540: 6e 20 74 68 65 20 73 61 6d 65 20 62 72 61 6e 63 n the same branc
0550: 68 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 63 6c 6f h..**.** The clo
0560: 73 65 4d 6f 64 65 20 66 6c 61 67 20 64 65 74 65 seMode flag dete
0570: 72 6d 69 6e 65 73 20 62 65 68 61 76 69 6f 72 20 rmines behavior
0580: 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 associated with
0590: 74 68 65 20 22 63 6c 6f 73 65 64 22 0a 2a 2a 20 the "closed".**
05a0: 74 61 67 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 63 6c tag:.**.** cl
05b0: 6f 73 65 4d 6f 64 65 3d 3d 30 20 20 20 20 20 20 oseMode==0
05c0: 20 53 68 6f 77 20 61 6c 6c 20 6c 65 61 76 65 73 Show all leaves
05d0: 20 72 65 67 61 72 64 6c 65 73 73 20 6f 66 20 74 regardless of t
05e0: 68 65 20 22 63 6c 6f 73 65 64 22 20 74 61 67 2e he "closed" tag.
05f0: 0a 2a 2a 0a 2a 2a 20 20 20 20 63 6c 6f 73 65 4d .**.** closeM
0600: 6f 64 65 3d 3d 31 20 20 20 20 20 20 20 53 68 6f ode==1 Sho
0610: 77 20 6f 6e 6c 79 20 6c 65 61 76 65 73 20 77 69 w only leaves wi
0620: 74 68 6f 75 74 20 74 68 65 20 22 63 6c 6f 73 65 thout the "close
0630: 64 22 20 74 61 67 2e 0a 2a 2a 0a 2a 2a 20 20 20 d" tag..**.**
0640: 20 63 6c 6f 73 65 4d 6f 64 65 3d 3d 32 20 20 20 closeMode==2
0650: 20 20 20 20 53 68 6f 77 20 6f 6e 6c 79 20 6c 65 Show only le
0660: 61 76 65 73 20 77 69 74 68 20 74 68 65 20 22 63 aves with the "c
0670: 6c 6f 73 65 64 22 20 74 61 67 2e 0a 2a 2a 0a 2a losed" tag..**.*
0680: 2a 20 54 68 65 20 64 65 66 61 75 6c 74 20 62 65 * The default be
0690: 68 61 76 69 6f 72 20 69 73 20 74 6f 20 69 67 6e havior is to ign
06a0: 6f 72 65 20 63 6c 6f 73 65 64 20 6c 65 61 76 65 ore closed leave
06b0: 73 20 28 63 6c 6f 73 65 4d 6f 64 65 3d 3d 30 29 s (closeMode==0)
06c0: 2e 20 20 54 6f 0a 2a 2a 20 53 68 6f 77 20 61 6c . To.** Show al
06d0: 6c 20 6c 65 61 76 65 73 2c 20 75 73 65 20 63 6c l leaves, use cl
06e0: 6f 73 65 4d 6f 64 65 3d 3d 31 2e 20 20 54 6f 20 oseMode==1. To
06f0: 73 68 6f 77 20 6f 6e 6c 79 20 63 6c 6f 73 65 64 show only closed
0700: 20 6c 65 61 76 65 73 2c 20 75 73 65 0a 2a 2a 20 leaves, use.**
0710: 63 6c 6f 73 65 4d 6f 64 65 3d 3d 32 2e 0a 2a 2f closeMode==2..*/
0720: 0a 76 6f 69 64 20 63 6f 6d 70 75 74 65 5f 6c 65 .void compute_le
0730: 61 76 65 73 28 69 6e 74 20 69 42 61 73 65 2c 20 aves(int iBase,
0740: 69 6e 74 20 63 6c 6f 73 65 4d 6f 64 65 29 7b 0a int closeMode){.
0750: 0a 20 20 2f 2a 20 43 72 65 61 74 65 20 74 68 65 . /* Create the
0760: 20 4c 45 41 56 45 53 20 74 61 62 6c 65 20 69 66 LEAVES table if
0770: 20 69 74 20 64 6f 65 73 20 6e 6f 74 20 61 6c 72 it does not alr
0780: 65 61 64 79 20 65 78 69 73 74 2e 20 20 4d 61 6b eady exist. Mak
0790: 65 20 73 75 72 65 0a 20 20 2a 2a 20 69 74 20 69 e sure. ** it i
07a0: 73 20 65 6d 70 74 79 2e 0a 20 20 2a 2f 0a 20 20 s empty.. */.
07b0: 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28 0a 20 db_multi_exec(.
07c0: 20 20 20 22 43 52 45 41 54 45 20 54 45 4d 50 20 "CREATE TEMP
07d0: 54 41 42 4c 45 20 49 46 20 4e 4f 54 20 45 58 49 TABLE IF NOT EXI
07e0: 53 54 53 20 6c 65 61 76 65 73 28 22 0a 20 20 20 STS leaves(".
07f0: 20 22 20 20 72 69 64 20 49 4e 54 45 47 45 52 20 " rid INTEGER
0800: 50 52 49 4d 41 52 59 20 4b 45 59 22 0a 20 20 20 PRIMARY KEY".
0810: 20 22 29 3b 22 0a 20 20 20 20 22 44 45 4c 45 54 ");". "DELET
0820: 45 20 46 52 4f 4d 20 6c 65 61 76 65 73 3b 22 0a E FROM leaves;".
0830: 20 20 29 3b 0a 0a 20 20 2f 2a 20 57 65 20 61 72 );.. /* We ar
0840: 65 20 63 68 65 63 6b 69 6e 67 20 61 6c 6c 20 64 e checking all d
0850: 65 73 63 65 6e 64 61 6e 74 73 20 6f 66 20 69 42 escendants of iB
0860: 61 73 65 2e 20 20 49 66 20 69 42 61 73 65 3d 3d ase. If iBase==
0870: 30 2c 20 74 68 65 6e 0a 20 20 2a 2a 20 75 73 65 0, then. ** use
0880: 20 61 20 73 68 6f 72 74 2d 63 75 74 20 74 6f 20 a short-cut to
0890: 66 69 6e 64 20 61 6c 6c 20 6c 65 61 76 65 73 20 find all leaves
08a0: 61 6e 79 77 68 65 72 65 20 69 6e 20 74 68 65 20 anywhere in the
08b0: 68 69 65 72 61 72 63 68 79 2e 0a 20 20 2a 2f 0a hierarchy.. */.
08c0: 20 20 69 66 28 20 69 42 61 73 65 3c 3d 30 20 29 if( iBase<=0 )
08d0: 7b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69 5f 65 {. db_multi_e
08e0: 78 65 63 28 0a 20 20 20 20 20 20 22 49 4e 53 45 xec(. "INSE
08f0: 52 54 20 4f 52 20 49 47 4e 4f 52 45 20 49 4e 54 RT OR IGNORE INT
0900: 4f 20 6c 65 61 76 65 73 22 0a 20 20 20 20 20 20 O leaves".
0910: 22 20 20 53 45 4c 45 43 54 20 63 69 64 20 46 52 " SELECT cid FR
0920: 4f 4d 20 70 6c 69 6e 6b 22 0a 20 20 20 20 20 20 OM plink".
0930: 22 20 20 45 58 43 45 50 54 22 0a 20 20 20 20 20 " EXCEPT".
0940: 20 22 20 20 53 45 4c 45 43 54 20 70 69 64 20 46 " SELECT pid F
0950: 52 4f 4d 20 70 6c 69 6e 6b 22 0a 20 20 20 20 20 ROM plink".
0960: 20 22 20 20 20 57 48 45 52 45 20 63 6f 61 6c 65 " WHERE coale
0970: 73 63 65 28 28 53 45 4c 45 43 54 20 76 61 6c 75 sce((SELECT valu
0980: 65 20 46 52 4f 4d 20 74 61 67 78 72 65 66 22 0a e FROM tagxref".
0990: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
09a0: 20 20 20 20 20 20 20 20 20 22 20 57 48 45 52 45 " WHERE
09b0: 20 74 61 67 69 64 3d 25 64 20 41 4e 44 20 72 69 tagid=%d AND ri
09c0: 64 3d 70 6c 69 6e 6b 2e 70 69 64 29 2c 27 74 72 d=plink.pid),'tr
09d0: 75 6e 6b 27 29 22 0a 20 20 20 20 20 20 20 20 20 unk')".
09e0: 20 20 22 20 3d 3d 20 63 6f 61 6c 65 73 63 65 28 " == coalesce(
09f0: 28 53 45 4c 45 43 54 20 76 61 6c 75 65 20 46 52 (SELECT value FR
0a00: 4f 4d 20 74 61 67 78 72 65 66 22 0a 20 20 20 20 OM tagxref".
0a10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0a20: 20 20 20 20 20 22 20 57 48 45 52 45 20 74 61 67 " WHERE tag
0a30: 69 64 3d 25 64 20 41 4e 44 20 72 69 64 3d 70 6c id=%d AND rid=pl
0a40: 69 6e 6b 2e 63 69 64 29 2c 27 74 72 75 6e 6b 27 ink.cid),'trunk'
0a50: 29 3b 22 2c 0a 20 20 20 20 20 20 54 41 47 5f 42 );",. TAG_B
0a60: 52 41 4e 43 48 2c 20 54 41 47 5f 42 52 41 4e 43 RANCH, TAG_BRANC
0a70: 48 0a 20 20 20 20 29 3b 0a 20 20 7d 65 6c 73 65 H. );. }else
0a80: 7b 0a 20 20 20 20 42 61 67 20 73 65 65 6e 3b 20 {. Bag seen;
0a90: 20 20 20 20 2f 2a 20 44 65 73 63 65 6e 64 61 6e /* Descendan
0aa0: 74 73 20 73 65 65 6e 20 2a 2f 0a 20 20 20 20 42 ts seen */. B
0ab0: 61 67 20 70 65 6e 64 69 6e 67 3b 20 20 2f 2a 20 ag pending; /*
0ac0: 55 6e 70 72 6f 70 61 67 61 74 65 64 20 64 65 73 Unpropagated des
0ad0: 63 65 6e 64 61 6e 74 73 20 2a 2f 0a 20 20 20 20 cendants */.
0ae0: 53 74 6d 74 20 71 31 3b 20 20 20 20 20 20 2f 2a Stmt q1; /*
0af0: 20 51 75 65 72 79 20 74 6f 20 66 69 6e 64 20 63 Query to find c
0b00: 68 69 6c 64 72 65 6e 20 6f 66 20 61 20 63 68 65 hildren of a che
0b10: 63 6b 2d 69 6e 20 2a 2f 0a 20 20 20 20 53 74 6d ck-in */. Stm
0b20: 74 20 69 73 42 72 3b 20 20 20 20 2f 2a 20 51 75 t isBr; /* Qu
0b30: 65 72 79 20 74 6f 20 63 68 65 63 6b 20 74 6f 20 ery to check to
0b40: 73 65 65 20 69 66 20 61 20 63 68 65 63 6b 2d 69 see if a check-i
0b50: 6e 20 73 74 61 72 74 73 20 61 20 6e 65 77 20 62 n starts a new b
0b60: 72 61 6e 63 68 20 2a 2f 0a 20 20 20 20 53 74 6d ranch */. Stm
0b70: 74 20 69 6e 73 3b 20 20 20 20 20 2f 2a 20 49 4e t ins; /* IN
0b80: 53 45 52 54 20 73 74 61 74 65 6d 65 6e 74 20 66 SERT statement f
0b90: 6f 72 20 61 20 6e 65 77 20 72 65 63 6f 72 64 20 or a new record
0ba0: 2a 2f 0a 0a 20 20 20 20 2f 2a 20 49 6e 69 74 69 */.. /* Initi
0bb0: 61 6c 69 7a 65 20 74 68 65 20 62 61 67 73 2e 20 alize the bags.
0bc0: 2a 2f 0a 20 20 20 20 62 61 67 5f 69 6e 69 74 28 */. bag_init(
0bd0: 26 73 65 65 6e 29 3b 0a 20 20 20 20 62 61 67 5f &seen);. bag_
0be0: 69 6e 69 74 28 26 70 65 6e 64 69 6e 67 29 3b 0a init(&pending);.
0bf0: 20 20 20 20 62 61 67 5f 69 6e 73 65 72 74 28 26 bag_insert(&
0c00: 70 65 6e 64 69 6e 67 2c 20 69 42 61 73 65 29 3b pending, iBase);
0c10: 0a 0a 20 20 20 20 2f 2a 20 54 68 69 73 20 71 75 .. /* This qu
0c20: 65 72 79 20 72 65 74 75 72 6e 73 20 61 6c 6c 20 ery returns all
0c30: 6e 6f 6e 2d 62 72 61 6e 63 68 2d 6d 65 72 67 65 non-branch-merge
0c40: 20 63 68 69 6c 64 72 65 6e 20 6f 66 20 63 68 65 children of che
0c50: 63 6b 2d 69 6e 20 3a 72 69 64 2e 0a 20 20 20 20 ck-in :rid..
0c60: 2a 2a 0a 20 20 20 20 2a 2a 20 49 66 20 61 20 61 **. ** If a a
0c70: 20 63 68 69 6c 64 20 69 73 20 61 20 6d 65 72 67 child is a merg
0c80: 65 20 6f 66 20 61 20 66 6f 72 6b 20 77 69 74 68 e of a fork with
0c90: 69 6e 20 74 68 65 20 73 61 6d 65 20 62 72 61 6e in the same bran
0ca0: 63 68 2c 20 69 74 20 69 73 20 0a 20 20 20 20 2a ch, it is . *
0cb0: 2a 20 72 65 74 75 72 6e 65 64 2e 20 20 4f 6e 6c * returned. Onl
0cc0: 79 20 6d 65 72 67 65 20 63 68 69 6c 64 72 65 6e y merge children
0cd0: 20 69 6e 20 64 69 66 66 65 72 65 6e 74 20 62 72 in different br
0ce0: 61 6e 63 68 65 73 20 61 72 65 20 65 78 63 6c 75 anches are exclu
0cf0: 64 65 64 2e 0a 20 20 20 20 2a 2f 0a 20 20 20 20 ded.. */.
0d00: 64 62 5f 70 72 65 70 61 72 65 28 26 71 31 2c 0a db_prepare(&q1,.
0d10: 20 20 20 20 20 20 22 53 45 4c 45 43 54 20 63 69 "SELECT ci
0d20: 64 20 46 52 4f 4d 20 70 6c 69 6e 6b 22 0a 20 20 d FROM plink".
0d30: 20 20 20 20 22 20 57 48 45 52 45 20 70 69 64 3d " WHERE pid=
0d40: 3a 72 69 64 22 0a 20 20 20 20 20 20 22 20 20 20 :rid". "
0d50: 41 4e 44 20 28 69 73 70 72 69 6d 22 0a 20 20 20 AND (isprim".
0d60: 20 20 20 22 20 20 20 20 20 20 20 20 4f 52 20 63 " OR c
0d70: 6f 61 6c 65 73 63 65 28 28 53 45 4c 45 43 54 20 oalesce((SELECT
0d80: 76 61 6c 75 65 20 46 52 4f 4d 20 74 61 67 78 72 value FROM tagxr
0d90: 65 66 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 ef".
0da0: 20 20 20 20 20 20 20 20 20 20 20 20 22 20 20 20 "
0db0: 57 48 45 52 45 20 74 61 67 69 64 3d 25 64 20 41 WHERE tagid=%d A
0dc0: 4e 44 20 72 69 64 3d 70 6c 69 6e 6b 2e 70 69 64 ND rid=plink.pid
0dd0: 29 2c 20 27 74 72 75 6e 6b 27 29 22 0a 20 20 20 ), 'trunk')".
0de0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 3d "=
0df0: 63 6f 61 6c 65 73 63 65 28 28 53 45 4c 45 43 54 coalesce((SELECT
0e00: 20 76 61 6c 75 65 20 46 52 4f 4d 20 74 61 67 78 value FROM tagx
0e10: 72 65 66 22 0a 20 20 20 20 20 20 20 20 20 20 20 ref".
0e20: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 20 20 "
0e30: 20 57 48 45 52 45 20 74 61 67 69 64 3d 25 64 20 WHERE tagid=%d
0e40: 41 4e 44 20 72 69 64 3d 70 6c 69 6e 6b 2e 63 69 AND rid=plink.ci
0e50: 64 29 2c 20 27 74 72 75 6e 6b 27 29 29 22 2c 0a d), 'trunk'))",.
0e60: 20 20 20 20 20 20 54 41 47 5f 42 52 41 4e 43 48 TAG_BRANCH
0e70: 2c 20 54 41 47 5f 42 52 41 4e 43 48 0a 20 20 20 , TAG_BRANCH.
0e80: 20 29 3b 0a 20 20 0a 20 20 20 20 2f 2a 20 54 68 );. . /* Th
0e90: 69 73 20 71 75 65 72 79 20 72 65 74 75 72 6e 73 is query returns
0ea0: 20 61 20 73 69 6e 67 6c 65 20 72 6f 77 20 69 66 a single row if
0eb0: 20 63 68 65 63 6b 2d 69 6e 20 3a 72 69 64 20 69 check-in :rid i
0ec0: 73 20 74 68 65 20 66 69 72 73 74 0a 20 20 20 20 s the first.
0ed0: 2a 2a 20 63 68 65 63 6b 2d 69 6e 20 6f 66 20 61 ** check-in of a
0ee0: 20 6e 65 77 20 62 72 61 6e 63 68 2e 0a 20 20 20 new branch..
0ef0: 20 2a 2f 0a 20 20 20 20 64 62 5f 70 72 65 70 61 */. db_prepa
0f00: 72 65 28 26 69 73 42 72 2c 20 0a 20 20 20 20 20 re(&isBr, .
0f10: 20 20 22 53 45 4c 45 43 54 20 31 20 46 52 4f 4d "SELECT 1 FROM
0f20: 20 74 61 67 78 72 65 66 22 0a 20 20 20 20 20 20 tagxref".
0f30: 20 22 20 57 48 45 52 45 20 72 69 64 3d 3a 72 69 " WHERE rid=:ri
0f40: 64 20 41 4e 44 20 74 61 67 69 64 3d 25 64 20 41 d AND tagid=%d A
0f50: 4e 44 20 74 61 67 74 79 70 65 3d 32 22 0a 20 20 ND tagtype=2".
0f60: 20 20 20 20 20 22 20 20 20 41 4e 44 20 73 72 63 " AND src
0f70: 69 64 3e 30 22 2c 0a 20 20 20 20 20 20 20 54 41 id>0",. TA
0f80: 47 5f 42 52 41 4e 43 48 0a 20 20 20 20 29 3b 0a G_BRANCH. );.
0f90: 20 20 0a 20 20 20 20 2f 2a 20 54 68 69 73 20 73 . /* This s
0fa0: 74 61 74 65 6d 65 6e 74 20 69 6e 73 65 72 74 73 tatement inserts
0fb0: 20 63 68 65 63 6b 2d 69 6e 20 3a 72 69 64 20 69 check-in :rid i
0fc0: 6e 74 6f 20 74 68 65 20 4c 45 41 56 45 53 20 74 nto the LEAVES t
0fd0: 61 62 6c 65 2e 0a 20 20 20 20 2a 2f 0a 20 20 20 able.. */.
0fe0: 20 64 62 5f 70 72 65 70 61 72 65 28 26 69 6e 73 db_prepare(&ins
0ff0: 2c 20 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e , "INSERT OR IGN
1000: 4f 52 45 20 49 4e 54 4f 20 6c 65 61 76 65 73 20 ORE INTO leaves
1010: 56 41 4c 55 45 53 28 3a 72 69 64 29 22 29 3b 0a VALUES(:rid)");.
1020: 20 20 0a 20 20 20 20 77 68 69 6c 65 28 20 62 61 . while( ba
1030: 67 5f 63 6f 75 6e 74 28 26 70 65 6e 64 69 6e 67 g_count(&pending
1040: 29 20 29 7b 0a 20 20 20 20 20 20 69 6e 74 20 72 ) ){. int r
1050: 69 64 20 3d 20 62 61 67 5f 66 69 72 73 74 28 26 id = bag_first(&
1060: 70 65 6e 64 69 6e 67 29 3b 0a 20 20 20 20 20 20 pending);.
1070: 69 6e 74 20 63 6e 74 20 3d 20 30 3b 0a 20 20 20 int cnt = 0;.
1080: 20 20 20 62 61 67 5f 72 65 6d 6f 76 65 28 26 70 bag_remove(&p
1090: 65 6e 64 69 6e 67 2c 20 72 69 64 29 3b 0a 20 20 ending, rid);.
10a0: 20 20 20 20 64 62 5f 62 69 6e 64 5f 69 6e 74 28 db_bind_int(
10b0: 26 71 31 2c 20 22 3a 72 69 64 22 2c 20 72 69 64 &q1, ":rid", rid
10c0: 29 3b 0a 20 20 20 20 20 20 77 68 69 6c 65 28 20 );. while(
10d0: 64 62 5f 73 74 65 70 28 26 71 31 29 3d 3d 53 51 db_step(&q1)==SQ
10e0: 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 20 LITE_ROW ){.
10f0: 20 20 20 20 69 6e 74 20 63 69 64 20 3d 20 64 62 int cid = db
1100: 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 31 2c _column_int(&q1,
1110: 20 30 29 3b 0a 20 20 20 20 20 20 20 20 69 66 28 0);. if(
1120: 20 62 61 67 5f 69 6e 73 65 72 74 28 26 73 65 65 bag_insert(&see
1130: 6e 2c 20 63 69 64 29 20 29 7b 0a 20 20 20 20 20 n, cid) ){.
1140: 20 20 20 20 20 62 61 67 5f 69 6e 73 65 72 74 28 bag_insert(
1150: 26 70 65 6e 64 69 6e 67 2c 20 63 69 64 29 3b 0a &pending, cid);.
1160: 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 }.
1170: 20 20 64 62 5f 62 69 6e 64 5f 69 6e 74 28 26 69 db_bind_int(&i
1180: 73 42 72 2c 20 22 3a 72 69 64 22 2c 20 63 69 64 sBr, ":rid", cid
1190: 29 3b 0a 20 20 20 20 20 20 20 20 69 66 28 20 64 );. if( d
11a0: 62 5f 73 74 65 70 28 26 69 73 42 72 29 3d 3d 53 b_step(&isBr)==S
11b0: 51 4c 49 54 45 5f 44 4f 4e 45 20 29 7b 0a 20 20 QLITE_DONE ){.
11c0: 20 20 20 20 20 20 20 20 63 6e 74 2b 2b 3b 0a 20 cnt++;.
11d0: 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 }.
11e0: 20 64 62 5f 72 65 73 65 74 28 26 69 73 42 72 29 db_reset(&isBr)
11f0: 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 ;. }.
1200: 64 62 5f 72 65 73 65 74 28 26 71 31 29 3b 0a 20 db_reset(&q1);.
1210: 20 20 20 20 20 69 66 28 20 63 6e 74 3d 3d 30 20 if( cnt==0
1220: 26 26 20 21 69 73 5f 61 5f 6c 65 61 66 28 72 69 && !is_a_leaf(ri
1230: 64 29 20 29 7b 0a 20 20 20 20 20 20 20 20 63 6e d) ){. cn
1240: 74 2b 2b 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 t++;. }.
1250: 20 20 20 69 66 28 20 63 6e 74 3d 3d 30 20 29 7b if( cnt==0 ){
1260: 0a 20 20 20 20 20 20 20 20 64 62 5f 62 69 6e 64 . db_bind
1270: 5f 69 6e 74 28 26 69 6e 73 2c 20 22 3a 72 69 64 _int(&ins, ":rid
1280: 22 2c 20 72 69 64 29 3b 0a 20 20 20 20 20 20 20 ", rid);.
1290: 20 64 62 5f 73 74 65 70 28 26 69 6e 73 29 3b 0a db_step(&ins);.
12a0: 20 20 20 20 20 20 20 20 64 62 5f 72 65 73 65 74 db_reset
12b0: 28 26 69 6e 73 29 3b 0a 20 20 20 20 20 20 7d 0a (&ins);. }.
12c0: 20 20 20 20 7d 0a 20 20 20 20 64 62 5f 66 69 6e }. db_fin
12d0: 61 6c 69 7a 65 28 26 69 6e 73 29 3b 0a 20 20 20 alize(&ins);.
12e0: 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 69 73 db_finalize(&is
12f0: 42 72 29 3b 0a 20 20 20 20 64 62 5f 66 69 6e 61 Br);. db_fina
1300: 6c 69 7a 65 28 26 71 31 29 3b 0a 20 20 20 20 62 lize(&q1);. b
1310: 61 67 5f 63 6c 65 61 72 28 26 70 65 6e 64 69 6e ag_clear(&pendin
1320: 67 29 3b 0a 20 20 20 20 62 61 67 5f 63 6c 65 61 g);. bag_clea
1330: 72 28 26 73 65 65 6e 29 3b 0a 20 20 7d 0a 20 20 r(&seen);. }.
1340: 69 66 28 20 63 6c 6f 73 65 4d 6f 64 65 3d 3d 31 if( closeMode==1
1350: 20 29 7b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69 ){. db_multi
1360: 5f 65 78 65 63 28 0a 20 20 20 20 20 20 22 44 45 _exec(. "DE
1370: 4c 45 54 45 20 46 52 4f 4d 20 6c 65 61 76 65 73 LETE FROM leaves
1380: 20 57 48 45 52 45 20 72 69 64 20 49 4e 22 0a 20 WHERE rid IN".
1390: 20 20 20 20 20 22 20 20 28 53 45 4c 45 43 54 20 " (SELECT
13a0: 6c 65 61 76 65 73 2e 72 69 64 20 46 52 4f 4d 20 leaves.rid FROM
13b0: 6c 65 61 76 65 73 2c 20 74 61 67 78 72 65 66 22 leaves, tagxref"
13c0: 0a 20 20 20 20 20 20 22 20 20 20 20 57 48 45 52 . " WHER
13d0: 45 20 74 61 67 78 72 65 66 2e 72 69 64 3d 6c 65 E tagxref.rid=le
13e0: 61 76 65 73 2e 72 69 64 20 22 0a 20 20 20 20 20 aves.rid ".
13f0: 20 22 20 20 20 20 20 20 41 4e 44 20 74 61 67 78 " AND tagx
1400: 72 65 66 2e 74 61 67 69 64 3d 25 64 22 0a 20 20 ref.tagid=%d".
1410: 20 20 20 20 22 20 20 20 20 20 20 41 4e 44 20 74 " AND t
1420: 61 67 78 72 65 66 2e 74 61 67 74 79 70 65 3e 30 agxref.tagtype>0
1430: 29 22 2c 0a 20 20 20 20 20 20 54 41 47 5f 43 4c )",. TAG_CL
1440: 4f 53 45 44 0a 20 20 20 20 29 3b 0a 20 20 7d 65 OSED. );. }e
1450: 6c 73 65 20 69 66 28 20 63 6c 6f 73 65 4d 6f 64 lse if( closeMod
1460: 65 3d 3d 32 20 29 7b 0a 20 20 20 20 64 62 5f 6d e==2 ){. db_m
1470: 75 6c 74 69 5f 65 78 65 63 28 0a 20 20 20 20 20 ulti_exec(.
1480: 20 22 44 45 4c 45 54 45 20 46 52 4f 4d 20 6c 65 "DELETE FROM le
1490: 61 76 65 73 20 57 48 45 52 45 20 72 69 64 20 4e aves WHERE rid N
14a0: 4f 54 20 49 4e 22 0a 20 20 20 20 20 20 22 20 20 OT IN". "
14b0: 28 53 45 4c 45 43 54 20 6c 65 61 76 65 73 2e 72 (SELECT leaves.r
14c0: 69 64 20 46 52 4f 4d 20 6c 65 61 76 65 73 2c 20 id FROM leaves,
14d0: 74 61 67 78 72 65 66 22 0a 20 20 20 20 20 20 22 tagxref". "
14e0: 20 20 20 20 57 48 45 52 45 20 74 61 67 78 72 65 WHERE tagxre
14f0: 66 2e 72 69 64 3d 6c 65 61 76 65 73 2e 72 69 64 f.rid=leaves.rid
1500: 20 22 0a 20 20 20 20 20 20 22 20 20 20 20 20 20 ". "
1510: 41 4e 44 20 74 61 67 78 72 65 66 2e 74 61 67 69 AND tagxref.tagi
1520: 64 3d 25 64 22 0a 20 20 20 20 20 20 22 20 20 20 d=%d". "
1530: 20 20 20 41 4e 44 20 74 61 67 78 72 65 66 2e 74 AND tagxref.t
1540: 61 67 74 79 70 65 3e 30 29 22 2c 0a 20 20 20 20 agtype>0)",.
1550: 20 20 54 41 47 5f 43 4c 4f 53 45 44 0a 20 20 20 TAG_CLOSED.
1560: 20 29 3b 0a 20 20 7d 0a 7d 0a 0a 2f 2a 0a 2a 2a );. }.}../*.**
1570: 20 4c 6f 61 64 20 74 68 65 20 72 65 63 6f 72 64 Load the record
1580: 20 49 44 20 72 69 64 20 61 6e 64 20 75 70 20 74 ID rid and up t
1590: 6f 20 4e 2d 31 20 63 6c 6f 73 65 73 74 20 61 6e o N-1 closest an
15a0: 63 65 73 74 6f 72 73 20 69 6e 74 6f 0a 2a 2a 20 cestors into.**
15b0: 74 68 65 20 22 6f 6b 22 20 74 61 62 6c 65 2e 0a the "ok" table..
15c0: 2a 2f 0a 76 6f 69 64 20 63 6f 6d 70 75 74 65 5f */.void compute_
15d0: 61 6e 63 65 73 74 6f 72 73 28 69 6e 74 20 72 69 ancestors(int ri
15e0: 64 2c 20 69 6e 74 20 4e 29 7b 0a 20 20 42 61 67 d, int N){. Bag
15f0: 20 73 65 65 6e 3b 0a 20 20 50 51 75 65 75 65 20 seen;. PQueue
1600: 71 75 65 75 65 3b 0a 20 20 62 61 67 5f 69 6e 69 queue;. bag_ini
1610: 74 28 26 73 65 65 6e 29 3b 0a 20 20 70 71 75 65 t(&seen);. pque
1620: 75 65 5f 69 6e 69 74 28 26 71 75 65 75 65 29 3b ue_init(&queue);
1630: 0a 20 20 62 61 67 5f 69 6e 73 65 72 74 28 26 73 . bag_insert(&s
1640: 65 65 6e 2c 20 72 69 64 29 3b 0a 20 20 70 71 75 een, rid);. pqu
1650: 65 75 65 5f 69 6e 73 65 72 74 28 26 71 75 65 75 eue_insert(&queu
1660: 65 2c 20 72 69 64 2c 20 30 2e 30 29 3b 0a 20 20 e, rid, 0.0);.
1670: 77 68 69 6c 65 28 20 28 4e 2d 2d 29 3e 30 20 26 while( (N--)>0 &
1680: 26 20 28 72 69 64 20 3d 20 70 71 75 65 75 65 5f & (rid = pqueue_
1690: 65 78 74 72 61 63 74 28 26 71 75 65 75 65 29 29 extract(&queue))
16a0: 21 3d 30 20 29 7b 0a 20 20 20 20 53 74 6d 74 20 !=0 ){. Stmt
16b0: 71 3b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69 5f q;. db_multi_
16c0: 65 78 65 63 28 22 49 4e 53 45 52 54 20 4f 52 20 exec("INSERT OR
16d0: 49 47 4e 4f 52 45 20 49 4e 54 4f 20 6f 6b 20 56 IGNORE INTO ok V
16e0: 41 4c 55 45 53 28 25 64 29 22 2c 20 72 69 64 29 ALUES(%d)", rid)
16f0: 3b 0a 20 20 20 20 64 62 5f 70 72 65 70 61 72 65 ;. db_prepare
1700: 28 26 71 2c 0a 20 20 20 20 20 20 20 22 53 45 4c (&q,. "SEL
1710: 45 43 54 20 61 2e 70 69 64 2c 20 62 2e 6d 74 69 ECT a.pid, b.mti
1720: 6d 65 20 46 52 4f 4d 20 70 6c 69 6e 6b 20 61 20 me FROM plink a
1730: 4c 45 46 54 20 4a 4f 49 4e 20 70 6c 69 6e 6b 20 LEFT JOIN plink
1740: 62 20 4f 4e 20 62 2e 63 69 64 3d 61 2e 70 69 64 b ON b.cid=a.pid
1750: 22 0a 20 20 20 20 20 20 20 22 20 57 48 45 52 45 ". " WHERE
1760: 20 61 2e 63 69 64 3d 25 64 22 2c 20 72 69 64 0a a.cid=%d", rid.
1770: 20 20 20 20 29 3b 0a 20 20 20 20 77 68 69 6c 65 );. while
1780: 28 20 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 ( db_step(&q)==S
1790: 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 QLITE_ROW ){.
17a0: 20 20 20 69 6e 74 20 70 69 64 20 3d 20 64 62 5f int pid = db_
17b0: 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 30 column_int(&q, 0
17c0: 29 3b 0a 20 20 20 20 20 20 64 6f 75 62 6c 65 20 );. double
17d0: 6d 74 69 6d 65 20 3d 20 64 62 5f 63 6f 6c 75 6d mtime = db_colum
17e0: 6e 5f 64 6f 75 62 6c 65 28 26 71 2c 20 31 29 3b n_double(&q, 1);
17f0: 0a 20 20 20 20 20 20 69 66 28 20 62 61 67 5f 69 . if( bag_i
1800: 6e 73 65 72 74 28 26 73 65 65 6e 2c 20 70 69 64 nsert(&seen, pid
1810: 29 20 29 7b 0a 20 20 20 20 20 20 20 20 70 71 75 ) ){. pqu
1820: 65 75 65 5f 69 6e 73 65 72 74 28 26 71 75 65 75 eue_insert(&queu
1830: 65 2c 20 70 69 64 2c 20 2d 6d 74 69 6d 65 29 3b e, pid, -mtime);
1840: 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 . }. }.
1850: 20 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 db_finalize(&
1860: 71 29 3b 0a 20 20 7d 0a 20 20 62 61 67 5f 63 6c q);. }. bag_cl
1870: 65 61 72 28 26 73 65 65 6e 29 3b 0a 20 20 70 71 ear(&seen);. pq
1880: 75 65 75 65 5f 63 6c 65 61 72 28 26 71 75 65 75 ueue_clear(&queu
1890: 65 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 4c 6f 61 e);.}../*.** Loa
18a0: 64 20 74 68 65 20 72 65 63 6f 72 64 20 49 44 20 d the record ID
18b0: 72 69 64 20 61 6e 64 20 75 70 20 74 6f 20 4e 2d rid and up to N-
18c0: 31 20 63 6c 6f 73 65 73 74 20 64 65 73 63 65 6e 1 closest descen
18d0: 64 61 6e 74 73 20 69 6e 74 6f 0a 2a 2a 20 74 68 dants into.** th
18e0: 65 20 22 6f 6b 22 20 74 61 62 6c 65 2e 0a 2a 2f e "ok" table..*/
18f0: 0a 76 6f 69 64 20 63 6f 6d 70 75 74 65 5f 64 65 .void compute_de
1900: 73 63 65 6e 64 61 6e 74 73 28 69 6e 74 20 72 69 scendants(int ri
1910: 64 2c 20 69 6e 74 20 4e 29 7b 0a 20 20 42 61 67 d, int N){. Bag
1920: 20 73 65 65 6e 3b 0a 20 20 50 51 75 65 75 65 20 seen;. PQueue
1930: 71 75 65 75 65 3b 0a 20 20 62 61 67 5f 69 6e 69 queue;. bag_ini
1940: 74 28 26 73 65 65 6e 29 3b 0a 20 20 70 71 75 65 t(&seen);. pque
1950: 75 65 5f 69 6e 69 74 28 26 71 75 65 75 65 29 3b ue_init(&queue);
1960: 0a 20 20 62 61 67 5f 69 6e 73 65 72 74 28 26 73 . bag_insert(&s
1970: 65 65 6e 2c 20 72 69 64 29 3b 0a 20 20 70 71 75 een, rid);. pqu
1980: 65 75 65 5f 69 6e 73 65 72 74 28 26 71 75 65 75 eue_insert(&queu
1990: 65 2c 20 72 69 64 2c 20 30 2e 30 29 3b 0a 20 20 e, rid, 0.0);.
19a0: 77 68 69 6c 65 28 20 28 4e 2d 2d 29 3e 30 20 26 while( (N--)>0 &
19b0: 26 20 28 72 69 64 20 3d 20 70 71 75 65 75 65 5f & (rid = pqueue_
19c0: 65 78 74 72 61 63 74 28 26 71 75 65 75 65 29 29 extract(&queue))
19d0: 21 3d 30 20 29 7b 0a 20 20 20 20 53 74 6d 74 20 !=0 ){. Stmt
19e0: 71 3b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69 5f q;. db_multi_
19f0: 65 78 65 63 28 22 49 4e 53 45 52 54 20 4f 52 20 exec("INSERT OR
1a00: 49 47 4e 4f 52 45 20 49 4e 54 4f 20 6f 6b 20 56 IGNORE INTO ok V
1a10: 41 4c 55 45 53 28 25 64 29 22 2c 20 72 69 64 29 ALUES(%d)", rid)
1a20: 3b 0a 20 20 20 20 64 62 5f 70 72 65 70 61 72 65 ;. db_prepare
1a30: 28 26 71 2c 22 53 45 4c 45 43 54 20 63 69 64 2c (&q,"SELECT cid,
1a40: 20 6d 74 69 6d 65 20 46 52 4f 4d 20 70 6c 69 6e mtime FROM plin
1a50: 6b 20 57 48 45 52 45 20 70 69 64 3d 25 64 22 2c k WHERE pid=%d",
1a60: 20 72 69 64 29 3b 0a 20 20 20 20 77 68 69 6c 65 rid);. while
1a70: 28 20 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 ( db_step(&q)==S
1a80: 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 QLITE_ROW ){.
1a90: 20 20 20 69 6e 74 20 70 69 64 20 3d 20 64 62 5f int pid = db_
1aa0: 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 30 column_int(&q, 0
1ab0: 29 3b 0a 20 20 20 20 20 20 64 6f 75 62 6c 65 20 );. double
1ac0: 6d 74 69 6d 65 20 3d 20 64 62 5f 63 6f 6c 75 6d mtime = db_colum
1ad0: 6e 5f 64 6f 75 62 6c 65 28 26 71 2c 20 31 29 3b n_double(&q, 1);
1ae0: 0a 20 20 20 20 20 20 69 66 28 20 62 61 67 5f 69 . if( bag_i
1af0: 6e 73 65 72 74 28 26 73 65 65 6e 2c 20 70 69 64 nsert(&seen, pid
1b00: 29 20 29 7b 0a 20 20 20 20 20 20 20 20 70 71 75 ) ){. pqu
1b10: 65 75 65 5f 69 6e 73 65 72 74 28 26 71 75 65 75 eue_insert(&queu
1b20: 65 2c 20 70 69 64 2c 20 6d 74 69 6d 65 29 3b 0a e, pid, mtime);.
1b30: 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20 }. }.
1b40: 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71 db_finalize(&q
1b50: 29 3b 0a 20 20 7d 0a 20 20 62 61 67 5f 63 6c 65 );. }. bag_cle
1b60: 61 72 28 26 73 65 65 6e 29 3b 0a 20 20 70 71 75 ar(&seen);. pqu
1b70: 65 75 65 5f 63 6c 65 61 72 28 26 71 75 65 75 65 eue_clear(&queue
1b80: 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d 4d );.}../*.** COMM
1b90: 41 4e 44 3a 20 20 64 65 73 63 65 6e 64 61 6e 74 AND: descendant
1ba0: 73 0a 2a 2a 0a 2a 2a 20 55 73 61 67 65 3a 20 25 s.**.** Usage: %
1bb0: 66 6f 73 73 69 6c 20 64 65 73 63 65 6e 64 61 6e fossil descendan
1bc0: 74 73 20 3f 42 41 53 45 4c 49 4e 45 2d 49 44 3f ts ?BASELINE-ID?
1bd0: 0a 2a 2a 0a 2a 2a 20 46 69 6e 64 20 61 6c 6c 20 .**.** Find all
1be0: 6c 65 61 66 20 64 65 73 63 65 6e 64 61 6e 74 73 leaf descendants
1bf0: 20 6f 66 20 74 68 65 20 62 61 73 65 6c 69 6e 65 of the baseline
1c00: 20 73 70 65 63 69 66 69 65 64 20 6f 72 20 69 66 specified or if
1c10: 20 74 68 65 20 61 72 67 75 6d 65 6e 74 0a 2a 2a the argument.**
1c20: 20 69 73 20 6f 6d 69 74 74 65 64 2c 20 6f 66 20 is omitted, of
1c30: 74 68 65 20 62 61 73 65 6c 69 6e 65 20 63 75 72 the baseline cur
1c40: 72 65 6e 74 6c 79 20 63 68 65 63 6b 65 64 20 6f rently checked o
1c50: 75 74 2e 0a 2a 2f 0a 76 6f 69 64 20 64 65 73 63 ut..*/.void desc
1c60: 65 6e 64 61 6e 74 73 5f 63 6d 64 28 76 6f 69 64 endants_cmd(void
1c70: 29 7b 0a 20 20 53 74 6d 74 20 71 3b 0a 20 20 69 ){. Stmt q;. i
1c80: 6e 74 20 62 61 73 65 3b 0a 0a 20 20 64 62 5f 6d nt base;.. db_m
1c90: 75 73 74 5f 62 65 5f 77 69 74 68 69 6e 5f 74 72 ust_be_within_tr
1ca0: 65 65 28 29 3b 0a 20 20 69 66 28 20 67 2e 61 72 ee();. if( g.ar
1cb0: 67 63 3d 3d 32 20 29 7b 0a 20 20 20 20 62 61 73 gc==2 ){. bas
1cc0: 65 20 3d 20 64 62 5f 6c 67 65 74 5f 69 6e 74 28 e = db_lget_int(
1cd0: 22 63 68 65 63 6b 6f 75 74 22 2c 20 30 29 3b 0a "checkout", 0);.
1ce0: 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 62 61 73 }else{. bas
1cf0: 65 20 3d 20 6e 61 6d 65 5f 74 6f 5f 72 69 64 28 e = name_to_rid(
1d00: 67 2e 61 72 67 76 5b 32 5d 29 3b 0a 20 20 7d 0a g.argv[2]);. }.
1d10: 20 20 69 66 28 20 62 61 73 65 3d 3d 30 20 29 20 if( base==0 )
1d20: 72 65 74 75 72 6e 3b 0a 20 20 63 6f 6d 70 75 74 return;. comput
1d30: 65 5f 6c 65 61 76 65 73 28 62 61 73 65 2c 20 30 e_leaves(base, 0
1d40: 29 3b 0a 20 20 64 62 5f 70 72 65 70 61 72 65 28 );. db_prepare(
1d50: 26 71 2c 0a 20 20 20 20 22 25 73 22 0a 20 20 20 &q,. "%s".
1d60: 20 22 20 20 20 41 4e 44 20 65 76 65 6e 74 2e 6f " AND event.o
1d70: 62 6a 69 64 20 49 4e 20 28 53 45 4c 45 43 54 20 bjid IN (SELECT
1d80: 72 69 64 20 46 52 4f 4d 20 6c 65 61 76 65 73 29 rid FROM leaves)
1d90: 22 0a 20 20 20 20 22 20 4f 52 44 45 52 20 42 59 ". " ORDER BY
1da0: 20 65 76 65 6e 74 2e 6d 74 69 6d 65 20 44 45 53 event.mtime DES
1db0: 43 22 2c 0a 20 20 20 20 74 69 6d 65 6c 69 6e 65 C",. timeline
1dc0: 5f 71 75 65 72 79 5f 66 6f 72 5f 74 74 79 28 29 _query_for_tty()
1dd0: 0a 20 20 29 3b 0a 20 20 70 72 69 6e 74 5f 74 69 . );. print_ti
1de0: 6d 65 6c 69 6e 65 28 26 71 2c 20 32 30 29 3b 0a meline(&q, 20);.
1df0: 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71 db_finalize(&q
1e00: 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d 4d );.}../*.** COMM
1e10: 41 4e 44 3a 20 20 6c 65 61 76 65 73 0a 2a 2a 0a AND: leaves.**.
1e20: 2a 2a 20 55 73 61 67 65 3a 20 25 66 6f 73 73 69 ** Usage: %fossi
1e30: 6c 20 6c 65 61 76 65 73 20 3f 2d 2d 61 6c 6c 3f l leaves ?--all?
1e40: 20 3f 2d 2d 63 6c 6f 73 65 64 3f 0a 2a 2a 0a 2a ?--closed?.**.*
1e50: 2a 20 46 69 6e 64 20 6c 65 61 76 65 73 20 6f 66 * Find leaves of
1e60: 20 61 6c 6c 20 62 72 61 6e 63 68 65 73 2e 20 20 all branches.
1e70: 42 79 20 64 65 66 61 75 6c 74 20 73 68 6f 77 20 By default show
1e80: 6f 6e 6c 79 20 6f 70 65 6e 20 6c 65 61 76 65 73 only open leaves
1e90: 2e 0a 2a 2a 20 54 68 65 20 2d 2d 61 6c 6c 20 66 ..** The --all f
1ea0: 6c 61 67 20 63 61 75 73 65 73 20 61 6c 6c 20 6c lag causes all l
1eb0: 65 61 76 65 73 20 28 63 6c 6f 73 65 64 20 61 6e eaves (closed an
1ec0: 64 20 6f 70 65 6e 29 20 74 6f 20 62 65 20 73 68 d open) to be sh
1ed0: 6f 77 6e 2e 0a 2a 2a 20 54 68 65 20 2d 2d 63 6c own..** The --cl
1ee0: 6f 73 65 64 20 66 6c 61 67 20 73 68 6f 77 73 20 osed flag shows
1ef0: 6f 6e 6c 79 20 63 6c 6f 73 65 64 20 6c 65 61 76 only closed leav
1f00: 65 73 2e 0a 2a 2f 0a 76 6f 69 64 20 6c 65 61 76 es..*/.void leav
1f10: 65 73 5f 63 6d 64 28 76 6f 69 64 29 7b 0a 20 20 es_cmd(void){.
1f20: 53 74 6d 74 20 71 3b 0a 20 20 69 6e 74 20 73 68 Stmt q;. int sh
1f30: 6f 77 41 6c 6c 20 3d 20 66 69 6e 64 5f 6f 70 74 owAll = find_opt
1f40: 69 6f 6e 28 22 61 6c 6c 22 2c 20 30 2c 20 30 29 ion("all", 0, 0)
1f50: 21 3d 30 3b 0a 20 20 69 6e 74 20 73 68 6f 77 43 !=0;. int showC
1f60: 6c 6f 73 65 64 20 3d 20 66 69 6e 64 5f 6f 70 74 losed = find_opt
1f70: 69 6f 6e 28 22 63 6c 6f 73 65 64 22 2c 20 30 2c ion("closed", 0,
1f80: 20 30 29 21 3d 30 3b 0a 0a 20 20 64 62 5f 6d 75 0)!=0;.. db_mu
1f90: 73 74 5f 62 65 5f 77 69 74 68 69 6e 5f 74 72 65 st_be_within_tre
1fa0: 65 28 29 3b 0a 20 20 63 6f 6d 70 75 74 65 5f 6c e();. compute_l
1fb0: 65 61 76 65 73 28 30 2c 20 73 68 6f 77 41 6c 6c eaves(0, showAll
1fc0: 20 3f 20 30 20 3a 20 73 68 6f 77 43 6c 6f 73 65 ? 0 : showClose
1fd0: 64 20 3f 20 32 20 3a 20 31 29 3b 0a 20 20 64 62 d ? 2 : 1);. db
1fe0: 5f 70 72 65 70 61 72 65 28 26 71 2c 0a 20 20 20 _prepare(&q,.
1ff0: 20 22 25 73 22 0a 20 20 20 20 22 20 20 20 41 4e "%s". " AN
2000: 44 20 62 6c 6f 62 2e 72 69 64 20 49 4e 20 6c 65 D blob.rid IN le
2010: 61 76 65 73 22 0a 20 20 20 20 22 20 4f 52 44 45 aves". " ORDE
2020: 52 20 42 59 20 65 76 65 6e 74 2e 6d 74 69 6d 65 R BY event.mtime
2030: 20 44 45 53 43 22 2c 0a 20 20 20 20 74 69 6d 65 DESC",. time
2040: 6c 69 6e 65 5f 71 75 65 72 79 5f 66 6f 72 5f 74 line_query_for_t
2050: 74 79 28 29 0a 20 20 29 3b 0a 20 20 70 72 69 6e ty(). );. prin
2060: 74 5f 74 69 6d 65 6c 69 6e 65 28 26 71 2c 20 32 t_timeline(&q, 2
2070: 30 30 30 29 3b 0a 20 20 64 62 5f 66 69 6e 61 6c 000);. db_final
2080: 69 7a 65 28 26 71 29 3b 0a 7d 0a 0a 2f 2a 0a 2a ize(&q);.}../*.*
2090: 2a 20 54 68 69 73 20 72 6f 75 74 69 6e 65 20 69 * This routine i
20a0: 73 20 63 61 6c 6c 65 64 20 77 68 69 6c 65 20 66 s called while f
20b0: 6f 72 20 65 61 63 68 20 63 68 65 63 6b 2d 69 6e or each check-in
20c0: 20 74 68 61 74 20 69 73 20 72 65 6e 64 65 72 65 that is rendere
20d0: 64 20 62 79 0a 2a 2a 20 74 68 65 20 22 6c 65 61 d by.** the "lea
20e0: 76 65 73 22 20 70 61 67 65 2e 20 20 41 64 64 20 ves" page. Add
20f0: 73 6f 6d 65 20 61 64 64 69 74 69 6f 6e 61 6c 20 some additional
2100: 68 79 70 65 72 6c 69 6e 6b 20 74 6f 20 73 68 6f hyperlink to sho
2110: 77 20 74 68 65 20 0a 2a 2a 20 61 6e 63 65 73 74 w the .** ancest
2120: 6f 72 73 20 6f 66 20 74 68 65 20 6c 65 61 66 2e ors of the leaf.
2130: 0a 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 64 20 .*/.static void
2140: 6c 65 61 76 65 73 5f 65 78 74 72 61 28 69 6e 74 leaves_extra(int
2150: 20 72 69 64 29 7b 0a 20 20 69 66 28 20 67 2e 6f rid){. if( g.o
2160: 6b 48 69 73 74 6f 72 79 20 29 7b 0a 20 20 20 20 kHistory ){.
2170: 40 20 3c 61 20 68 72 65 66 3d 22 25 73 28 67 2e @ <a href="%s(g.
2180: 7a 42 61 73 65 55 52 4c 29 2f 74 69 6d 65 6c 69 zBaseURL)/timeli
2190: 6e 65 3f 70 3d 25 64 28 72 69 64 29 22 3e 5b 74 ne?p=%d(rid)">[t
21a0: 69 6d 65 6c 69 6e 65 5d 3c 2f 61 3e 0a 20 20 7d imeline]</a>. }
21b0: 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 57 45 42 50 41 47 .}../*.** WEBPAG
21c0: 45 3a 20 20 6c 65 61 76 65 73 0a 2a 2a 0a 2a 2a E: leaves.**.**
21d0: 20 46 69 6e 64 20 6c 65 61 76 65 73 20 6f 66 20 Find leaves of
21e0: 61 6c 6c 20 62 72 61 6e 63 68 65 73 2e 0a 2a 2f all branches..*/
21f0: 0a 76 6f 69 64 20 6c 65 61 76 65 73 5f 70 61 67 .void leaves_pag
2200: 65 28 76 6f 69 64 29 7b 0a 20 20 53 74 6d 74 20 e(void){. Stmt
2210: 71 3b 0a 20 20 69 6e 74 20 73 68 6f 77 41 6c 6c q;. int showAll
2220: 20 3d 20 50 28 22 61 6c 6c 22 29 21 3d 30 3b 0a = P("all")!=0;.
2230: 20 20 69 6e 74 20 73 68 6f 77 43 6c 6f 73 65 64 int showClosed
2240: 20 3d 20 50 28 22 63 6c 6f 73 65 64 22 29 21 3d = P("closed")!=
2250: 30 3b 0a 0a 20 20 6c 6f 67 69 6e 5f 63 68 65 63 0;.. login_chec
2260: 6b 5f 63 72 65 64 65 6e 74 69 61 6c 73 28 29 3b k_credentials();
2270: 0a 20 20 69 66 28 20 21 67 2e 6f 6b 52 65 61 64 . if( !g.okRead
2280: 20 29 7b 20 6c 6f 67 69 6e 5f 6e 65 65 64 65 64 ){ login_needed
2290: 28 29 3b 20 72 65 74 75 72 6e 3b 20 7d 0a 0a 20 (); return; }..
22a0: 20 69 66 28 20 21 73 68 6f 77 41 6c 6c 20 29 7b if( !showAll ){
22b0: 0a 20 20 20 20 73 74 79 6c 65 5f 73 75 62 6d 65 . style_subme
22c0: 6e 75 5f 65 6c 65 6d 65 6e 74 28 22 41 6c 6c 22 nu_element("All"
22d0: 2c 20 22 41 6c 6c 22 2c 20 22 6c 65 61 76 65 73 , "All", "leaves
22e0: 3f 61 6c 6c 22 29 3b 0a 20 20 7d 0a 20 20 69 66 ?all");. }. if
22f0: 28 20 21 73 68 6f 77 43 6c 6f 73 65 64 20 29 7b ( !showClosed ){
2300: 0a 20 20 20 20 73 74 79 6c 65 5f 73 75 62 6d 65 . style_subme
2310: 6e 75 5f 65 6c 65 6d 65 6e 74 28 22 43 6c 6f 73 nu_element("Clos
2320: 65 64 22 2c 20 22 43 6c 6f 73 65 64 22 2c 20 22 ed", "Closed", "
2330: 6c 65 61 76 65 73 3f 63 6c 6f 73 65 64 22 29 3b leaves?closed");
2340: 0a 20 20 7d 0a 20 20 69 66 28 20 73 68 6f 77 43 . }. if( showC
2350: 6c 6f 73 65 64 20 7c 7c 20 73 68 6f 77 41 6c 6c losed || showAll
2360: 20 29 7b 0a 20 20 20 20 73 74 79 6c 65 5f 73 75 ){. style_su
2370: 62 6d 65 6e 75 5f 65 6c 65 6d 65 6e 74 28 22 4f bmenu_element("O
2380: 70 65 6e 22 2c 20 22 4f 70 65 6e 22 2c 20 22 6c pen", "Open", "l
2390: 65 61 76 65 73 22 29 3b 0a 20 20 7d 0a 20 20 73 eaves");. }. s
23a0: 74 79 6c 65 5f 68 65 61 64 65 72 28 22 4c 65 61 tyle_header("Lea
23b0: 76 65 73 22 29 3b 0a 20 20 6c 6f 67 69 6e 5f 61 ves");. login_a
23c0: 6e 6f 6e 79 6d 6f 75 73 5f 61 76 61 69 6c 61 62 nonymous_availab
23d0: 6c 65 28 29 3b 0a 20 20 63 6f 6d 70 75 74 65 5f le();. compute_
23e0: 6c 65 61 76 65 73 28 30 2c 20 73 68 6f 77 41 6c leaves(0, showAl
23f0: 6c 20 3f 20 30 20 3a 20 73 68 6f 77 43 6c 6f 73 l ? 0 : showClos
2400: 65 64 20 3f 20 32 20 3a 20 31 29 3b 0a 20 20 73 ed ? 2 : 1);. s
2410: 74 79 6c 65 5f 73 69 64 65 62 6f 78 5f 62 65 67 tyle_sidebox_beg
2420: 69 6e 28 22 4e 6f 6d 65 6e 63 6c 61 74 75 72 65 in("Nomenclature
2430: 3a 22 2c 20 22 33 33 25 22 29 3b 0a 20 20 40 20 :", "33%");. @
2440: 3c 6f 6c 3e 0a 20 20 40 20 3c 6c 69 3e 20 41 20 <ol>. @ <li> A
2450: 3c 62 3e 6c 65 61 66 3c 2f 62 3e 20 69 73 20 61 <b>leaf</b> is a
2460: 20 63 68 65 63 6b 2d 69 6e 20 77 69 74 68 20 6e check-in with n
2470: 6f 20 64 65 73 63 65 6e 64 61 6e 74 73 2e 3c 2f o descendants.</
2480: 6c 69 3e 0a 20 20 40 20 3c 6c 69 3e 20 41 6e 20 li>. @ <li> An
2490: 3c 62 3e 6f 70 65 6e 20 6c 65 61 66 3c 2f 62 3e <b>open leaf</b>
24a0: 20 69 73 20 61 20 6c 65 61 66 20 74 68 61 74 20 is a leaf that
24b0: 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 61 20 does not have a
24c0: 22 63 6c 6f 73 65 64 22 20 74 61 67 0a 20 20 40 "closed" tag. @
24d0: 20 61 6e 64 20 69 73 20 74 68 75 73 20 61 73 73 and is thus ass
24e0: 75 6d 65 64 20 74 6f 20 73 74 69 6c 6c 20 62 65 umed to still be
24f0: 20 69 6e 20 75 73 65 2e 3c 2f 6c 69 3e 0a 20 20 in use.</li>.
2500: 40 20 3c 6c 69 3e 20 41 20 3c 62 3e 63 6c 6f 73 @ <li> A <b>clos
2510: 65 64 20 6c 65 61 66 3c 2f 62 3e 20 68 61 73 20 ed leaf</b> has
2520: 61 20 22 63 6c 6f 73 65 64 22 20 74 61 67 20 61 a "closed" tag a
2530: 6e 64 20 69 73 20 74 68 75 73 20 61 73 73 75 6d nd is thus assum
2540: 65 64 20 74 6f 0a 20 20 40 20 62 65 20 68 69 73 ed to. @ be his
2550: 74 6f 72 69 63 61 6c 20 61 6e 64 20 6e 6f 20 6c torical and no l
2560: 6f 6e 67 65 72 20 69 6e 20 61 63 74 69 76 65 20 onger in active
2570: 75 73 65 2e 3c 2f 6c 69 3e 0a 20 20 40 20 3c 2f use.</li>. @ </
2580: 6f 6c 3e 0a 20 20 73 74 79 6c 65 5f 73 69 64 65 ol>. style_side
2590: 62 6f 78 5f 65 6e 64 28 29 3b 0a 0a 20 20 69 66 box_end();.. if
25a0: 28 20 73 68 6f 77 41 6c 6c 20 29 7b 0a 20 20 20 ( showAll ){.
25b0: 20 40 20 3c 68 31 3e 41 6c 6c 20 6c 65 61 76 65 @ <h1>All leave
25c0: 73 2c 20 62 6f 74 68 20 6f 70 65 6e 20 61 6e 64 s, both open and
25d0: 20 63 6c 6f 73 65 64 3a 3c 2f 68 31 3e 0a 20 20 closed:</h1>.
25e0: 7d 65 6c 73 65 20 69 66 28 20 73 68 6f 77 43 6c }else if( showCl
25f0: 6f 73 65 64 20 29 7b 0a 20 20 20 20 40 20 3c 68 osed ){. @ <h
2600: 31 3e 43 6c 6f 73 65 64 20 6c 65 61 76 65 73 3a 1>Closed leaves:
2610: 3c 2f 68 31 3e 0a 20 20 7d 65 6c 73 65 7b 0a 20 </h1>. }else{.
2620: 20 20 20 40 20 3c 68 31 3e 4f 70 65 6e 20 6c 65 @ <h1>Open le
2630: 61 76 65 73 3a 3c 2f 68 31 3e 0a 20 20 7d 0a 20 aves:</h1>. }.
2640: 20 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c 0a db_prepare(&q,.
2650: 20 20 20 20 22 25 73 22 0a 20 20 20 20 22 20 20 "%s". "
2660: 20 41 4e 44 20 62 6c 6f 62 2e 72 69 64 20 49 4e AND blob.rid IN
2670: 20 6c 65 61 76 65 73 22 0a 20 20 20 20 22 20 4f leaves". " O
2680: 52 44 45 52 20 42 59 20 65 76 65 6e 74 2e 6d 74 RDER BY event.mt
2690: 69 6d 65 20 44 45 53 43 22 2c 0a 20 20 20 20 74 ime DESC",. t
26a0: 69 6d 65 6c 69 6e 65 5f 71 75 65 72 79 5f 66 6f imeline_query_fo
26b0: 72 5f 77 77 77 28 29 0a 20 20 29 3b 0a 20 20 77 r_www(). );. w
26c0: 77 77 5f 70 72 69 6e 74 5f 74 69 6d 65 6c 69 6e ww_print_timelin
26d0: 65 28 26 71 2c 20 54 49 4d 45 4c 49 4e 45 5f 4c e(&q, TIMELINE_L
26e0: 45 41 46 4f 4e 4c 59 2c 20 6c 65 61 76 65 73 5f EAFONLY, leaves_
26f0: 65 78 74 72 61 29 3b 0a 20 20 64 62 5f 66 69 6e extra);. db_fin
2700: 61 6c 69 7a 65 28 26 71 29 3b 0a 20 20 40 20 3c alize(&q);. @ <
2710: 62 72 20 63 6c 65 61 72 3d 22 62 6f 74 68 22 3e br clear="both">
2720: 0a 20 20 40 20 3c 73 63 72 69 70 74 3e 0a 20 20 . @ <script>.
2730: 40 20 66 75 6e 63 74 69 6f 6e 20 78 69 6e 28 69 @ function xin(i
2740: 64 29 7b 0a 20 20 40 20 7d 0a 20 20 40 20 66 75 d){. @ }. @ fu
2750: 6e 63 74 69 6f 6e 20 78 6f 75 74 28 69 64 29 7b nction xout(id){
2760: 0a 20 20 40 20 7d 0a 20 20 40 20 3c 2f 73 63 72 . @ }. @ </scr
2770: 69 70 74 3e 0a 20 20 73 74 79 6c 65 5f 66 6f 6f ipt>. style_foo
2780: 74 65 72 28 29 3b 0a 7d 0a ter();.}.