Hex Artifact Content
Not logged in

Artifact e3ece24fa595702c627e5a3dd595f744f340de2d:

File www/sync.wiki part of check-in [adc0b3bfb0] - Additional documentation updates. by drh on 2008-07-15 14:33:48.

0000: 3c 68 31 20 61 6c 69 67 6e 3d 22 63 65 6e 74 65  <h1 align="cente
0010: 72 22 3e 54 68 65 20 46 6f 73 73 69 6c 20 53 79  r">The Fossil Sy
0020: 6e 63 20 50 72 6f 74 6f 63 6f 6c 3c 2f 68 31 3e  nc Protocol</h1>
0030: 0a 0a 3c 70 3e 46 6f 73 73 69 6c 20 73 75 70 70  ..<p>Fossil supp
0040: 6f 72 74 73 20 63 6f 6d 6d 61 6e 64 73 20 3c 62  orts commands <b
0050: 3e 70 75 73 68 3c 2f 62 3e 2c 20 3c 62 3e 70 75  >push</b>, <b>pu
0060: 6c 6c 3c 2f 62 3e 2c 20 61 6e 64 20 3c 62 3e 73  ll</b>, and <b>s
0070: 79 6e 63 3c 2f 62 3e 0a 66 6f 72 20 74 72 61 6e  ync</b>.for tran
0080: 73 66 65 72 72 69 6e 67 20 69 6e 66 6f 72 6d 61  sferring informa
0090: 74 69 6f 6e 20 66 72 6f 6d 20 6f 6e 65 20 72 65  tion from one re
00a0: 70 6f 73 69 74 6f 72 79 20 74 6f 20 61 6e 6f 74  pository to anot
00b0: 68 65 72 2e 20 20 54 68 65 0a 63 6f 6d 6d 61 6e  her.  The.comman
00c0: 64 20 69 73 20 72 75 6e 20 6f 6e 20 74 68 65 20  d is run on the 
00d0: 63 6c 69 65 6e 74 20 72 65 70 6f 73 69 74 6f 72  client repositor
00e0: 79 2e 20 20 41 20 55 52 4c 20 66 6f 72 20 74 68  y.  A URL for th
00f0: 65 20 73 65 72 76 65 72 20 72 65 70 6f 73 69 74  e server reposit
0100: 6f 72 79 0a 69 73 20 73 70 65 63 69 66 69 65 64  ory.is specified
0110: 20 61 73 20 70 61 72 74 20 6f 66 20 74 68 65 20   as part of the 
0120: 63 6f 6d 6d 61 6e 64 2e 20 20 54 68 69 73 20 64  command.  This d
0130: 6f 63 75 6d 65 6e 74 20 64 65 73 63 72 69 62 65  ocument describe
0140: 73 20 77 68 61 74 20 68 61 70 70 65 6e 73 0a 62  s what happens.b
0150: 65 68 69 6e 64 20 74 68 65 20 73 63 65 6e 65 73  ehind the scenes
0160: 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 73 79 6e   in order to syn
0170: 63 68 72 6f 6e 69 7a 65 20 74 68 65 20 69 6e 66  chronize the inf
0180: 6f 72 6d 61 74 69 6f 6e 20 6f 6e 20 74 68 65 20  ormation on the 
0190: 74 77 6f 0a 72 65 70 6f 73 69 74 6f 72 69 65 73  two.repositories
01a0: 2e 3c 2f 70 3e 0a 0a 3c 68 32 3e 31 2e 30 20 4f  .</p>..<h2>1.0 O
01b0: 76 65 72 76 69 65 77 3c 2f 68 32 3e 0a 0a 3c 70  verview</h2>..<p
01c0: 3e 54 68 65 20 67 6c 6f 62 61 6c 20 73 74 61 74  >The global stat
01d0: 65 20 6f 66 20 61 20 66 6f 73 73 69 6c 20 72 65  e of a fossil re
01e0: 70 6f 73 69 74 6f 72 79 20 63 6f 6e 73 69 73 74  pository consist
01f0: 73 20 6f 66 20 61 6e 20 75 6e 6f 72 64 65 72 65  s of an unordere
0200: 64 0a 63 6f 6c 6c 65 63 74 69 6f 6e 20 6f 66 20  d.collection of 
0210: 61 72 74 69 66 61 63 74 73 2e 20 20 45 61 63 68  artifacts.  Each
0220: 20 61 72 74 69 66 61 63 74 20 69 73 20 69 64 65   artifact is ide
0230: 6e 74 69 66 69 65 64 20 62 79 20 69 74 73 20 53  ntified by its S
0240: 48 41 31 20 68 61 73 68 2e 0a 53 79 6e 63 68 72  HA1 hash..Synchr
0250: 6f 6e 69 7a 61 74 69 6f 6e 20 69 73 20 73 69 6d  onization is sim
0260: 70 6c 79 20 74 68 65 20 70 72 6f 63 65 73 73 20  ply the process 
0270: 6f 66 20 73 68 61 72 69 6e 67 20 61 72 74 69 66  of sharing artif
0280: 61 63 74 73 20 62 65 74 77 65 65 6e 0a 73 65 72  acts between.ser
0290: 76 65 72 73 20 73 6f 20 74 68 61 74 20 61 6c 6c  vers so that all
02a0: 20 73 65 72 76 65 72 73 20 68 61 76 65 20 63 6f   servers have co
02b0: 70 69 65 73 20 6f 66 20 61 6c 6c 20 61 72 74 69  pies of all arti
02c0: 66 61 63 74 73 2e 20 20 42 65 63 61 75 73 65 0a  facts.  Because.
02d0: 61 72 74 69 66 61 63 74 73 20 61 72 65 20 75 6e  artifacts are un
02e0: 6f 72 64 65 72 65 64 2c 20 74 68 65 20 6f 72 64  ordered, the ord
02f0: 65 72 20 69 6e 20 77 68 69 63 68 20 61 72 74 69  er in which arti
0300: 66 61 63 74 73 20 61 72 65 20 72 65 63 65 69 76  facts are receiv
0310: 65 64 0a 61 74 20 61 20 73 65 72 76 65 72 20 69  ed.at a server i
0320: 73 20 69 6e 63 6f 6e 73 65 71 75 65 6e 74 69 61  s inconsequentia
0330: 6c 2e 20 20 49 74 20 69 73 20 61 73 73 75 6d 65  l.  It is assume
0340: 64 20 74 68 61 74 20 74 68 65 20 53 48 41 31 20  d that the SHA1 
0350: 68 61 73 68 65 73 0a 6f 66 20 61 72 74 69 66 61  hashes.of artifa
0360: 63 74 73 20 61 72 65 20 75 6e 69 71 75 65 20 2d  cts are unique -
0370: 20 74 68 61 74 20 65 76 65 72 79 20 61 72 74 69   that every arti
0380: 66 61 63 74 20 68 61 73 20 61 20 64 69 66 66 65  fact has a diffe
0390: 72 65 6e 74 20 53 48 41 31 20 68 61 73 68 2e 0a  rent SHA1 hash..
03a0: 54 6f 20 66 69 72 73 74 20 61 70 70 72 6f 78 69  To first approxi
03b0: 6d 61 74 69 6f 6e 2c 20 73 79 6e 63 68 72 6f 6e  mation, synchron
03c0: 69 7a 61 74 69 6f 6e 20 70 72 6f 63 65 65 64 73  ization proceeds
03d0: 20 62 79 20 73 68 61 72 69 6e 67 20 6c 69 73 74   by sharing list
03e0: 73 20 0a 53 48 41 31 20 68 61 73 68 65 73 20 6f  s .SHA1 hashes o
03f0: 66 20 61 76 61 69 6c 61 62 6c 65 20 61 72 74 69  f available arti
0400: 66 61 63 74 73 2c 20 74 68 65 6e 20 73 68 61 72  facts, then shar
0410: 69 6e 67 20 74 68 6f 73 65 20 61 72 74 69 66 61  ing those artifa
0420: 63 74 73 20 74 68 61 74 0a 61 72 65 20 6e 6f 74  cts that.are not
0430: 20 66 6f 75 6e 64 20 6f 6e 20 6f 6e 65 20 73 69   found on one si
0440: 64 65 20 6f 72 20 74 68 65 20 6f 74 68 65 72 20  de or the other 
0450: 6f 66 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 6f  of the connectio
0460: 6e 2e 20 20 49 6e 20 70 72 61 63 74 69 63 65 2c  n.  In practice,
0470: 0a 61 20 72 65 70 6f 73 69 74 6f 72 79 20 6d 69  .a repository mi
0480: 67 68 74 20 63 6f 6e 74 61 69 6e 20 6d 69 6c 6c  ght contain mill
0490: 69 6f 6e 73 20 6f 66 20 61 72 74 69 66 61 63 74  ions of artifact
04a0: 73 2e 20 20 54 68 65 20 6c 69 73 74 20 6f 66 0a  s.  The list of.
04b0: 53 48 41 31 20 68 61 73 68 65 73 20 66 6f 72 20  SHA1 hashes for 
04c0: 74 68 69 73 20 6d 61 6e 79 20 61 72 74 69 66 61  this many artifa
04d0: 63 74 73 20 63 61 6e 20 62 65 20 6c 61 72 67 65  cts can be large
04e0: 2e 20 20 53 6f 20 6f 70 74 69 6d 69 7a 61 74 69  .  So optimizati
04f0: 6f 6e 73 20 61 72 65 0a 65 6d 70 6c 6f 79 65 64  ons are.employed
0500: 20 74 68 61 74 20 75 73 75 61 6c 6c 79 20 72 65   that usually re
0510: 64 75 63 65 20 74 68 65 20 6e 75 6d 62 65 72 20  duce the number 
0520: 6f 66 20 53 48 41 31 20 68 61 73 68 65 73 20 74  of SHA1 hashes t
0530: 68 61 74 20 6e 65 65 64 20 74 6f 20 62 65 0a 73  hat need to be.s
0540: 68 61 72 65 64 20 74 6f 20 61 20 66 65 77 20 68  hared to a few h
0550: 75 6e 64 72 65 64 2e 3c 2f 70 3e 0a 0a 3c 68 32  undred.</p>..<h2
0560: 3e 32 2e 30 20 54 72 61 6e 73 70 6f 72 74 3c 2f  >2.0 Transport</
0570: 68 32 3e 0a 0a 3c 70 3e 41 6c 6c 20 63 6f 6d 6d  h2>..<p>All comm
0580: 75 6e 69 63 61 74 69 6f 6e 20 62 65 74 77 65 65  unication betwee
0590: 6e 20 63 6c 69 65 6e 74 20 61 6e 64 20 73 65 72  n client and ser
05a0: 76 65 72 20 69 73 20 76 69 61 20 48 54 54 50 20  ver is via HTTP 
05b0: 72 65 71 75 65 73 74 73 2e 0a 54 68 65 20 73 65  requests..The se
05c0: 72 76 65 72 20 69 73 20 6c 69 73 74 65 6e 69 6e  rver is listenin
05d0: 67 20 66 6f 72 20 69 6e 63 6f 6d 69 6e 67 20 48  g for incoming H
05e0: 54 54 50 20 72 65 71 75 65 73 74 73 2e 20 20 54  TTP requests.  T
05f0: 68 65 20 63 6c 69 65 6e 74 0a 69 73 73 75 65 73  he client.issues
0600: 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 48 54 54   one or more HTT
0610: 50 20 72 65 71 75 65 73 74 73 20 61 6e 64 20 72  P requests and r
0620: 65 63 65 69 76 65 73 20 72 65 70 6c 69 65 73 20  eceives replies 
0630: 66 6f 72 20 65 61 63 68 0a 72 65 71 75 65 73 74  for each.request
0640: 2e 3c 2f 70 3e 0a 0a 3c 70 3e 54 68 65 20 73 65  .</p>..<p>The se
0650: 72 76 65 72 20 6d 69 67 68 74 20 62 65 20 72 75  rver might be ru
0660: 6e 6e 69 6e 67 20 61 73 20 61 6e 20 69 6e 64 65  nning as an inde
0670: 70 65 6e 64 65 6e 74 20 73 65 72 76 65 72 0a 75  pendent server.u
0680: 73 69 6e 67 20 74 68 65 20 3c 62 3e 73 65 72 76  sing the <b>serv
0690: 65 72 3c 2f 62 3e 20 63 6f 6d 6d 61 6e 64 2c 20  er</b> command, 
06a0: 6f 72 20 69 74 20 6d 69 67 68 74 20 62 65 20 6c  or it might be l
06b0: 61 75 6e 63 68 65 64 20 66 72 6f 6d 0a 69 6e 65  aunched from.ine
06c0: 74 64 20 6f 72 20 78 69 6e 65 74 64 20 75 73 69  td or xinetd usi
06d0: 6e 67 20 74 68 65 20 3c 62 3e 68 74 74 70 3c 2f  ng the <b>http</
06e0: 62 3e 20 63 6f 6d 6d 61 6e 64 2e 20 20 4f 72 20  b> command.  Or 
06f0: 74 68 65 20 73 65 72 76 65 72 20 6d 69 67 68 74  the server might
0700: 0a 62 65 20 6c 61 75 6e 63 68 65 64 20 66 72 6f  .be launched fro
0710: 6d 20 43 47 49 2e 20 20 54 68 65 20 64 65 74 61  m CGI.  The deta
0720: 69 6c 73 20 6f 66 20 68 6f 77 20 74 68 65 20 73  ils of how the s
0730: 65 72 76 65 72 20 69 73 20 63 6f 6e 66 69 67 75  erver is configu
0740: 72 65 64 0a 74 6f 20 22 6c 69 73 74 65 6e 22 20  red.to "listen" 
0750: 66 6f 72 20 69 6e 63 6f 6d 69 6e 67 20 48 54 54  for incoming HTT
0760: 50 20 72 65 71 75 65 73 74 73 20 69 73 20 69 6d  P requests is im
0770: 6d 61 74 65 72 69 61 6c 2e 20 20 54 68 65 20 69  material.  The i
0780: 6d 70 6f 72 74 61 6e 74 0a 70 6f 69 6e 74 20 69  mportant.point i
0790: 73 20 74 68 61 74 20 74 68 65 20 73 65 72 76 65  s that the serve
07a0: 72 20 69 73 20 6c 69 73 74 65 6e 69 6e 67 20 66  r is listening f
07b0: 6f 72 20 72 65 71 75 65 73 74 73 20 61 6e 64 20  or requests and 
07c0: 74 68 65 20 63 6c 69 65 6e 74 0a 69 73 20 74 68  the client.is th
07d0: 65 20 69 73 73 75 65 72 20 6f 66 20 74 68 65 20  e issuer of the 
07e0: 72 65 71 75 65 73 74 73 2e 3c 2f 70 3e 0a 0a 3c  requests.</p>..<
07f0: 70 3e 41 20 73 69 6e 67 6c 65 20 70 75 73 68 2c  p>A single push,
0800: 20 70 75 6c 6c 2c 20 6f 72 20 73 79 6e 63 20 6d   pull, or sync m
0810: 69 67 68 74 20 69 6e 76 6f 6c 76 65 20 6d 75 6c  ight involve mul
0820: 74 69 70 6c 65 20 48 54 54 50 20 72 65 71 75 65  tiple HTTP reque
0830: 73 74 73 2e 0a 54 68 65 20 63 6c 69 65 6e 74 20  sts..The client 
0840: 6d 61 69 6e 74 61 69 6e 73 20 73 74 61 74 65 20  maintains state 
0850: 62 65 74 77 65 65 6e 20 61 6c 6c 20 72 65 71 75  between all requ
0860: 65 73 74 73 2e 20 20 42 75 74 20 6f 6e 20 74 68  ests.  But on th
0870: 65 20 73 65 72 76 65 72 0a 73 69 64 65 2c 20 65  e server.side, e
0880: 61 63 68 20 72 65 71 75 65 73 74 20 69 73 20 69  ach request is i
0890: 6e 64 65 70 65 6e 64 65 6e 74 2e 20 20 54 68 65  ndependent.  The
08a0: 20 73 65 72 76 65 72 20 64 6f 65 73 20 6e 6f 74   server does not
08b0: 20 70 72 65 73 65 72 76 65 0a 61 6e 79 20 69 6e   preserve.any in
08c0: 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20  formation about 
08d0: 74 68 65 20 63 6c 69 65 6e 74 20 66 72 6f 6d 20  the client from 
08e0: 6f 6e 65 20 72 65 71 75 65 73 74 20 74 6f 20 74  one request to t
08f0: 68 65 20 6e 65 78 74 2e 3c 2f 70 3e 0a 0a 3c 68  he next.</p>..<h
0900: 33 3e 32 2e 31 20 53 65 72 76 65 72 20 49 64 65  3>2.1 Server Ide
0910: 6e 74 69 66 69 63 61 74 69 6f 6e 3c 2f 68 33 3e  ntification</h3>
0920: 0a 0a 3c 70 3e 54 68 65 20 73 65 72 76 65 72 20  ..<p>The server 
0930: 69 73 20 69 64 65 6e 74 69 66 69 65 64 20 62 79  is identified by
0940: 20 61 20 55 52 4c 20 61 72 67 75 6d 65 6e 74 20   a URL argument 
0950: 74 68 61 74 20 61 63 63 6f 6d 70 61 6e 69 65 73  that accompanies
0960: 20 74 68 65 0a 70 75 73 68 2c 20 70 75 6c 6c 2c   the.push, pull,
0970: 20 6f 72 20 73 79 6e 63 20 63 6f 6d 6d 61 6e 64   or sync command
0980: 20 6f 6e 20 74 68 65 20 63 6c 69 65 6e 74 2e 20   on the client. 
0990: 20 28 41 73 20 61 20 63 6f 6e 76 65 6e 69 65 6e   (As a convenien
09a0: 63 65 20 74 6f 0a 75 73 65 72 73 2c 20 74 68 65  ce to.users, the
09b0: 20 55 52 4c 20 63 61 6e 20 62 65 20 6f 6d 69 74   URL can be omit
09c0: 74 65 64 20 6f 6e 20 74 68 65 20 63 6c 69 65 6e  ted on the clien
09d0: 74 20 63 6f 6d 6d 61 6e 64 20 61 6e 64 20 74 68  t command and th
09e0: 65 20 73 61 6d 65 20 55 52 4c 0a 66 72 6f 6d 20  e same URL.from 
09f0: 74 68 65 20 6d 6f 73 74 20 72 65 63 65 6e 74 20  the most recent 
0a00: 70 75 73 68 2c 20 70 75 6c 6c 2c 20 6f 72 20 73  push, pull, or s
0a10: 79 6e 63 20 77 69 6c 6c 20 62 65 20 72 65 75 73  ync will be reus
0a20: 65 64 2e 20 20 54 68 69 73 20 73 61 76 65 73 0a  ed.  This saves.
0a30: 74 79 70 69 6e 67 20 69 6e 20 74 68 65 20 63 6f  typing in the co
0a40: 6d 6d 6f 6e 20 63 61 73 65 20 77 68 65 72 65 20  mmon case where 
0a50: 74 68 65 20 63 6c 69 65 6e 74 20 64 6f 65 73 20  the client does 
0a60: 6d 75 6c 74 69 70 6c 65 20 73 79 6e 63 73 20 74  multiple syncs t
0a70: 6f 0a 74 68 65 20 73 61 6d 65 20 73 65 72 76 65  o.the same serve
0a80: 72 2e 29 3c 2f 70 3e 0a 0a 3c 70 3e 54 68 65 20  r.)</p>..<p>The 
0a90: 63 6c 69 65 6e 74 20 6d 6f 64 69 66 69 65 73 20  client modifies 
0aa0: 74 68 65 20 55 52 4c 20 62 79 20 61 70 70 65 6e  the URL by appen
0ab0: 64 69 6e 67 20 74 68 65 20 6d 65 74 68 6f 64 20  ding the method 
0ac0: 6e 61 6d 65 20 22 3c 62 3e 2f 78 66 65 72 3c 2f  name "<b>/xfer</
0ad0: 62 3e 22 0a 74 6f 20 74 68 65 20 65 6e 64 2e 20  b>".to the end. 
0ae0: 20 46 6f 72 20 65 78 61 6d 70 6c 65 2c 20 69 66   For example, if
0af0: 20 74 68 65 20 55 52 4c 20 73 70 65 63 69 66 69   the URL specifi
0b00: 65 64 20 6f 6e 20 74 68 65 20 63 6c 69 65 6e 74  ed on the client
0b10: 20 63 6f 6d 6d 61 6e 64 0a 6c 69 6e 65 20 69 73   command.line is
0b20: 3c 2f 70 3e 0a 0a 3c 62 6c 6f 63 6b 71 75 6f 74  </p>..<blockquot
0b30: 65 3e 0a 68 74 74 70 3a 2f 2f 66 6f 73 73 69 6c  e>.http://fossil
0b40: 2d 73 63 6d 2e 68 77 61 63 69 2e 63 6f 6d 2f 66  -scm.hwaci.com/f
0b50: 6f 73 73 69 6c 0a 3c 2f 62 6c 6f 63 6b 71 75 6f  ossil.</blockquo
0b60: 74 65 3e 0a 0a 3c 70 3e 54 68 65 6e 20 74 68 65  te>..<p>Then the
0b70: 20 55 52 4c 20 74 68 61 74 20 69 73 20 72 65 61   URL that is rea
0b80: 6c 6c 79 20 75 73 65 64 20 74 6f 20 64 6f 20 74  lly used to do t
0b90: 68 65 20 73 79 6e 63 68 72 6f 6e 69 7a 61 74 69  he synchronizati
0ba0: 6f 6e 20 77 69 6c 6c 0a 62 65 3a 3c 2f 70 3e 0a  on will.be:</p>.
0bb0: 0a 3c 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 68 74  .<blockquote>.ht
0bc0: 74 70 3a 2f 2f 66 6f 73 73 69 6c 2d 73 63 6d 2e  tp://fossil-scm.
0bd0: 68 77 61 63 69 2e 63 6f 6d 2f 66 6f 73 73 69 6c  hwaci.com/fossil
0be0: 2f 78 66 65 72 0a 3c 2f 62 6c 6f 63 6b 71 75 6f  /xfer.</blockquo
0bf0: 74 65 3e 0a 0a 3c 68 33 3e 32 2e 32 20 48 54 54  te>..<h3>2.2 HTT
0c00: 50 20 52 65 71 75 65 73 74 20 46 6f 72 6d 61 74  P Request Format
0c10: 3c 2f 68 33 3e 0a 0a 3c 70 3e 54 68 65 20 63 6c  </h3>..<p>The cl
0c20: 69 65 6e 74 20 61 6c 77 61 79 73 20 73 65 6e 64  ient always send
0c30: 73 20 61 20 50 4f 53 54 20 72 65 71 75 65 73 74  s a POST request
0c40: 20 74 6f 20 74 68 65 20 73 65 72 76 65 72 2e 20   to the server. 
0c50: 20 54 68 65 0a 67 65 6e 65 72 61 6c 20 66 6f 72   The.general for
0c60: 6d 61 74 20 6f 66 20 74 68 65 20 50 4f 53 54 20  mat of the POST 
0c70: 72 65 71 75 65 73 74 20 69 73 20 61 73 20 66 6f  request is as fo
0c80: 6c 6c 6f 77 73 3a 3c 2f 70 3e 0a 0a 3c 62 6c 6f  llows:</p>..<blo
0c90: 63 6b 71 75 6f 74 65 3e 3c 70 72 65 3e 0a 50 4f  ckquote><pre>.PO
0ca0: 53 54 20 2f 66 6f 73 73 69 6c 2f 78 66 65 72 20  ST /fossil/xfer 
0cb0: 48 54 54 50 2f 31 2e 30 0a 48 6f 73 74 3a 20 66  HTTP/1.0.Host: f
0cc0: 6f 73 73 69 6c 2d 73 63 6d 2e 68 77 61 63 69 2e  ossil-scm.hwaci.
0cd0: 63 6f 6d 3a 38 30 0a 43 6f 6e 74 65 6e 74 2d 54  com:80.Content-T
0ce0: 79 70 65 3a 20 61 70 70 6c 69 63 61 74 69 6f 6e  ype: application
0cf0: 2f 78 2d 66 6f 73 73 69 6c 0a 43 6f 6e 74 65 6e  /x-fossil.Conten
0d00: 74 2d 4c 65 6e 67 74 68 3a 20 34 32 31 36 0a 0a  t-Length: 4216..
0d10: 3c 69 3e 63 6f 6e 74 65 6e 74 2e 2e 2e 3c 2f 69  <i>content...</i
0d20: 3e 0a 3c 2f 70 72 65 3e 3c 2f 62 6c 6f 63 6b 71  >.</pre></blockq
0d30: 75 6f 74 65 3e 0a 0a 3c 70 3e 49 6e 20 74 68 65  uote>..<p>In the
0d40: 20 65 78 61 6d 70 6c 65 20 61 62 6f 76 65 2c 20   example above, 
0d50: 74 68 65 20 70 61 74 68 6e 61 6d 65 20 67 69 76  the pathname giv
0d60: 65 6e 20 61 66 74 65 72 20 74 68 65 20 50 4f 53  en after the POS
0d70: 54 20 6b 65 79 77 6f 72 64 0a 6f 6e 20 74 68 65  T keyword.on the
0d80: 20 66 69 72 73 74 20 6c 69 6e 65 20 69 73 20 61   first line is a
0d90: 20 63 6f 70 79 20 6f 66 20 74 68 65 20 55 52 4c   copy of the URL
0da0: 20 70 61 74 68 6e 61 6d 65 2e 20 20 54 68 65 20   pathname.  The 
0db0: 48 6f 73 74 3a 20 70 61 72 61 6d 65 74 65 72 0a  Host: parameter.
0dc0: 69 73 20 61 6c 73 6f 20 74 61 6b 65 6e 20 66 72  is also taken fr
0dd0: 6f 6d 20 74 68 65 20 55 52 4c 2e 20 20 54 68 65  om the URL.  The
0de0: 20 63 6f 6e 74 65 6e 74 20 74 79 70 65 20 69 73   content type is
0df0: 20 61 6c 77 61 79 73 20 65 69 74 68 65 72 0a 22   always either."
0e00: 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 2d 66 6f  application/x-fo
0e10: 73 73 69 6c 22 20 6f 72 20 22 61 70 70 6c 69 63  ssil" or "applic
0e20: 61 74 69 6f 6e 2f 78 2d 66 6f 73 73 69 6c 2d 64  ation/x-fossil-d
0e30: 65 62 75 67 22 2e 20 20 54 68 65 20 22 78 2d 66  ebug".  The "x-f
0e40: 6f 73 73 69 6c 22 0a 63 6f 6e 74 65 6e 74 20 74  ossil".content t
0e50: 79 70 65 20 69 73 20 74 68 65 20 64 65 66 61 75  ype is the defau
0e60: 6c 74 2e 20 20 54 68 65 20 6f 6e 6c 79 20 64 69  lt.  The only di
0e70: 66 66 65 72 65 6e 63 65 20 69 73 20 74 68 61 74  fference is that
0e80: 20 22 78 2d 66 6f 73 73 69 6c 22 0a 63 6f 6e 74   "x-fossil".cont
0e90: 65 6e 74 20 69 73 20 63 6f 6d 70 72 65 73 73 65  ent is compresse
0ea0: 64 20 75 73 69 6e 67 20 7a 6c 69 62 20 77 68 65  d using zlib whe
0eb0: 72 65 61 73 20 22 78 2d 66 6f 73 73 69 6c 2d 64  reas "x-fossil-d
0ec0: 65 62 75 67 22 20 69 73 20 73 65 6e 74 0a 75 6e  ebug" is sent.un
0ed0: 63 6f 6d 70 72 65 73 73 65 64 2e 3c 2f 70 3e 0a  compressed.</p>.
0ee0: 0a 3c 70 3e 41 20 74 79 70 69 63 61 6c 20 72 65  .<p>A typical re
0ef0: 70 6c 79 20 66 72 6f 6d 20 74 68 65 20 73 65 72  ply from the ser
0f00: 76 65 72 20 6d 69 67 68 74 20 6c 6f 6f 6b 20 73  ver might look s
0f10: 6f 6d 65 74 68 69 6e 67 20 6c 69 6b 65 20 74 68  omething like th
0f20: 69 73 3a 3c 2f 70 3e 0a 0a 3c 62 6c 6f 63 6b 71  is:</p>..<blockq
0f30: 75 6f 74 65 3e 3c 70 72 65 3e 0a 48 54 54 50 2f  uote><pre>.HTTP/
0f40: 31 2e 30 20 32 30 30 20 4f 4b 0a 44 61 74 65 3a  1.0 200 OK.Date:
0f50: 20 4d 6f 6e 2c 20 31 30 20 53 65 70 20 32 30 30   Mon, 10 Sep 200
0f60: 37 20 31 32 3a 32 31 3a 30 31 20 47 4d 54 0a 43  7 12:21:01 GMT.C
0f70: 6f 6e 6e 65 63 74 69 6f 6e 3a 20 63 6c 6f 73 65  onnection: close
0f80: 0a 43 61 63 68 65 2d 63 6f 6e 74 72 6f 6c 3a 20  .Cache-control: 
0f90: 70 72 69 76 61 74 65 0a 43 6f 6e 74 65 6e 74 2d  private.Content-
0fa0: 54 79 70 65 3a 20 61 70 70 6c 69 63 61 74 69 6f  Type: applicatio
0fb0: 6e 2f 78 2d 66 6f 73 73 69 6c 3b 20 63 68 61 72  n/x-fossil; char
0fc0: 73 65 74 3d 55 53 2d 41 53 43 49 49 0a 43 6f 6e  set=US-ASCII.Con
0fd0: 74 65 6e 74 2d 4c 65 6e 67 74 68 3a 20 32 36 35  tent-Length: 265
0fe0: 0a 0a 3c 69 3e 63 6f 6e 74 65 6e 74 2e 2e 2e 3c  ..<i>content...<
0ff0: 2f 69 3e 0a 3c 2f 70 72 65 3e 3c 2f 62 6c 6f 63  /i>.</pre></bloc
1000: 6b 71 75 6f 74 65 3e 0a 0a 3c 70 3e 54 68 65 20  kquote>..<p>The 
1010: 63 6f 6e 74 65 6e 74 20 74 79 70 65 20 6f 66 20  content type of 
1020: 74 68 65 20 72 65 70 6c 79 20 69 73 20 61 6c 77  the reply is alw
1030: 61 79 73 20 74 68 65 20 73 61 6d 65 20 61 73 20  ays the same as 
1040: 74 68 65 20 63 6f 6e 74 65 6e 74 20 74 79 70 65  the content type
1050: 0a 6f 66 20 74 68 65 20 72 65 71 75 65 73 74 2e  .of the request.
1060: 3c 2f 70 3e 0a 0a 3c 68 32 3e 33 2e 30 20 46 6f  </p>..<h2>3.0 Fo
1070: 73 73 69 6c 20 53 79 6e 63 68 72 6f 6e 69 7a 61  ssil Synchroniza
1080: 74 69 6f 6e 20 43 6f 6e 74 65 6e 74 3c 2f 68 32  tion Content</h2
1090: 3e 0a 0a 3c 70 3e 41 20 73 79 6e 63 68 72 6f 6e  >..<p>A synchron
10a0: 69 7a 61 74 69 6f 6e 20 72 65 71 75 65 73 74 20  ization request 
10b0: 62 65 74 77 65 65 6e 20 61 20 63 6c 69 65 6e 74  between a client
10c0: 20 61 6e 64 20 73 65 72 76 65 72 20 63 6f 6e 73   and server cons
10d0: 69 73 74 73 20 6f 66 0a 6f 6e 65 20 6f 72 20 6d  ists of.one or m
10e0: 6f 72 65 20 48 54 54 50 20 72 65 71 75 65 73 74  ore HTTP request
10f0: 73 20 61 73 20 64 65 73 63 72 69 62 65 64 20 69  s as described i
1100: 6e 20 74 68 65 20 70 72 65 76 69 6f 75 73 20 73  n the previous s
1110: 65 63 74 69 6f 6e 2e 20 20 54 68 69 73 0a 73 65  ection.  This.se
1120: 63 74 69 6f 6e 20 64 65 74 61 69 6c 73 20 74 68  ction details th
1130: 65 20 22 78 2d 66 6f 73 73 69 6c 22 20 63 6f 6e  e "x-fossil" con
1140: 74 65 6e 74 20 74 79 70 65 2e 3c 2f 70 3e 0a 0a  tent type.</p>..
1150: 3c 68 33 3e 33 2e 31 20 4c 69 6e 65 2d 6f 72 69  <h3>3.1 Line-ori
1160: 65 6e 74 65 64 20 46 6f 72 6d 61 74 3c 2f 68 33  ented Format</h3
1170: 3e 0a 0a 3c 70 3e 54 68 65 20 78 2d 66 6f 73 73  >..<p>The x-foss
1180: 69 6c 20 63 6f 6e 74 65 6e 74 20 74 79 70 65 20  il content type 
1190: 63 6f 6e 73 69 73 74 73 20 6f 66 20 7a 65 72 6f  consists of zero
11a0: 20 6f 72 20 6d 6f 72 65 20 22 63 61 72 64 73 22   or more "cards"
11b0: 2e 20 20 43 61 72 64 73 0a 61 72 65 20 73 65 70  .  Cards.are sep
11c0: 61 72 61 74 65 20 62 79 20 74 68 65 20 6e 65 77  arate by the new
11d0: 6c 69 6e 65 20 63 68 61 72 61 63 74 65 72 20 28  line character (
11e0: 22 5c 6e 22 29 2e 20 20 4c 65 61 64 69 6e 67 20  "\n").  Leading 
11f0: 61 6e 64 20 74 72 61 69 6c 69 6e 67 0a 77 68 69  and trailing.whi
1200: 74 65 73 70 61 63 65 20 6f 6e 20 61 20 63 61 72  tespace on a car
1210: 64 20 69 73 20 69 67 6e 6f 72 65 64 2e 20 20 42  d is ignored.  B
1220: 6c 61 6e 6b 20 63 61 72 64 73 20 61 72 65 20 69  lank cards are i
1230: 67 6e 6f 72 65 64 2e 3c 2f 70 3e 0a 0a 3c 70 3e  gnored.</p>..<p>
1240: 45 61 63 68 20 63 61 72 64 20 69 73 20 64 69 76  Each card is div
1250: 69 64 65 64 20 69 6e 74 6f 20 7a 65 72 6f 20 6f  ided into zero o
1260: 72 20 6d 6f 72 65 20 73 70 61 63 65 20 73 65 70  r more space sep
1270: 61 72 61 74 65 64 20 74 6f 6b 65 6e 73 2e 0a 54  arated tokens..T
1280: 68 65 20 66 69 72 73 74 20 74 6f 6b 65 6e 20 6f  he first token o
1290: 6e 20 65 61 63 68 20 63 61 72 64 20 69 73 20 74  n each card is t
12a0: 68 65 20 6f 70 65 72 61 74 6f 72 2e 20 20 53 75  he operator.  Su
12b0: 62 73 65 71 75 65 6e 74 20 74 6f 6b 65 6e 73 0a  bsequent tokens.
12c0: 61 72 65 20 61 72 67 75 6d 65 6e 74 73 2e 20 20  are arguments.  
12d0: 54 68 65 20 73 65 74 20 6f 66 20 6f 70 65 72 61  The set of opera
12e0: 74 6f 72 73 20 75 6e 64 65 72 73 74 6f 6f 64 20  tors understood 
12f0: 62 79 20 73 65 72 76 65 72 73 20 69 73 20 73 6c  by servers is sl
1300: 69 67 68 74 6c 79 0a 64 69 66 66 65 72 65 6e 74  ightly.different
1310: 20 66 72 6f 6d 20 74 68 65 20 6f 70 65 72 61 74   from the operat
1320: 6f 72 73 20 75 6e 64 65 72 73 74 6f 6f 64 20 62  ors understood b
1330: 79 20 63 6c 69 65 6e 74 73 2c 20 74 68 6f 75 67  y clients, thoug
1340: 68 20 74 68 65 20 74 77 6f 0a 61 72 65 20 76 65  h the two.are ve
1350: 72 79 20 73 69 6d 69 6c 61 72 2e 3c 2f 70 3e 0a  ry similar.</p>.
1360: 0a 3c 68 33 3e 33 2e 32 20 4c 6f 67 69 6e 20 43  .<h3>3.2 Login C
1370: 61 72 64 73 3c 2f 68 33 3e 0a 0a 3c 70 3e 45 76  ards</h3>..<p>Ev
1380: 65 72 79 20 6d 65 73 73 61 67 65 20 66 72 6f 6d  ery message from
1390: 20 63 6c 69 65 6e 74 20 74 6f 20 73 65 72 76 65   client to serve
13a0: 72 20 62 65 67 69 6e 73 20 77 69 74 68 20 6f 6e  r begins with on
13b0: 65 20 6f 72 20 6d 6f 72 65 20 6c 6f 67 69 6e 0a  e or more login.
13c0: 63 61 72 64 73 2e 20 20 45 61 63 68 20 6c 6f 67  cards.  Each log
13d0: 69 6e 20 63 61 72 64 20 68 61 73 20 74 68 65 20  in card has the 
13e0: 66 6f 6c 6c 6f 77 69 6e 67 20 66 6f 72 6d 61 74  following format
13f0: 3a 3c 2f 70 3e 0a 0a 3c 62 6c 6f 63 6b 71 75 6f  :</p>..<blockquo
1400: 74 65 3e 0a 3c 62 3e 6c 6f 67 69 6e 3c 2f 62 3e  te>.<b>login</b>
1410: 20 20 3c 69 3e 75 73 65 72 69 64 20 20 6e 6f 6e    <i>userid  non
1420: 63 65 20 20 73 69 67 6e 61 74 75 72 65 3c 2f 69  ce  signature</i
1430: 3e 0a 3c 2f 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a  >.</blockquote>.
1440: 0a 3c 70 3e 54 68 65 20 75 73 65 72 69 64 20 69  .<p>The userid i
1450: 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 68  s the name of th
1460: 65 20 75 73 65 72 20 74 68 61 74 20 69 73 20 72  e user that is r
1470: 65 71 75 65 73 74 69 6e 67 20 73 65 72 76 69 63  equesting servic
1480: 65 0a 66 72 6f 6d 20 74 68 65 20 73 65 72 76 65  e.from the serve
1490: 72 2e 20 20 54 68 65 20 6e 6f 6e 63 65 20 69 73  r.  The nonce is
14a0: 20 74 68 65 20 53 48 41 31 20 68 61 73 68 20 6f   the SHA1 hash o
14b0: 66 20 74 68 65 20 72 65 6d 61 69 6e 64 65 72 20  f the remainder 
14c0: 6f 66 0a 74 68 65 20 6d 65 73 73 61 67 65 20 2d  of.the message -
14d0: 20 61 6c 6c 20 74 65 78 74 20 74 68 61 74 20 66   all text that f
14e0: 6f 6c 6c 6f 77 73 20 74 68 65 20 6e 65 77 6c 69  ollows the newli
14f0: 6e 65 20 63 68 61 72 61 63 74 65 72 20 74 68 61  ne character tha
1500: 74 0a 74 65 72 6d 69 6e 61 74 65 73 20 74 68 65  t.terminates the
1510: 20 6c 6f 67 69 6e 20 63 61 72 64 2e 20 20 54 68   login card.  Th
1520: 65 20 73 69 67 6e 61 74 75 72 65 20 69 73 20 74  e signature is t
1530: 68 65 20 53 48 41 31 20 68 61 73 68 20 6f 66 0a  he SHA1 hash of.
1540: 74 68 65 20 63 6f 6e 63 61 74 65 6e 61 74 69 6f  the concatenatio
1550: 6e 20 6f 66 20 74 68 65 20 6e 6f 6e 63 65 20 61  n of the nonce a
1560: 6e 64 20 74 68 65 20 75 73 65 72 73 20 70 61 73  nd the users pas
1570: 73 77 6f 72 64 2e 3c 2f 70 3e 0a 0a 3c 70 3e 46  sword.</p>..<p>F
1580: 6f 72 20 65 61 63 68 20 6c 6f 67 69 6e 20 63 61  or each login ca
1590: 72 64 2c 20 74 68 65 20 73 65 72 76 65 72 20 6c  rd, the server l
15a0: 6f 6f 6b 73 20 75 70 20 74 68 65 20 75 73 65 72  ooks up the user
15b0: 20 61 6e 64 20 76 65 72 69 66 69 65 73 0a 74 68   and verifies.th
15c0: 61 74 20 74 68 65 20 6e 6f 6e 63 65 20 6d 61 74  at the nonce mat
15d0: 63 68 65 73 20 74 68 65 20 53 48 41 31 20 68 61  ches the SHA1 ha
15e0: 73 68 20 6f 66 20 74 68 65 20 72 65 6d 61 69 6e  sh of the remain
15f0: 64 65 72 20 6f 66 20 74 68 65 0a 6d 65 73 73 61  der of the.messa
1600: 67 65 2e 20 20 49 74 20 74 68 65 6e 20 63 68 65  ge.  It then che
1610: 63 6b 73 20 74 68 65 20 73 69 67 6e 61 74 75 72  cks the signatur
1620: 65 20 68 61 73 68 20 74 6f 20 6d 61 6b 65 20 73  e hash to make s
1630: 75 72 65 20 74 68 65 20 0a 73 69 67 6e 61 74 75  ure the .signatu
1640: 72 65 20 6d 61 74 63 68 65 73 2e 20 20 49 66 20  re matches.  If 
1650: 65 76 65 72 79 74 68 69 6e 67 0a 63 68 65 63 6b  everything.check
1660: 73 20 6f 75 74 2c 20 74 68 65 6e 20 74 68 65 20  s out, then the 
1670: 63 6c 69 65 6e 74 20 69 73 20 67 72 61 6e 74 65  client is grante
1680: 64 20 61 6c 6c 20 70 72 69 76 69 6c 65 67 65 73  d all privileges
1690: 20 6f 66 20 74 68 65 0a 73 70 65 63 69 66 69 65   of the.specifie
16a0: 64 20 75 73 65 72 2e 3c 2f 70 3e 0a 0a 3c 70 3e  d user.</p>..<p>
16b0: 50 72 69 76 69 6c 65 67 65 73 20 61 72 65 20 63  Privileges are c
16c0: 75 6d 75 6c 61 74 69 76 65 2e 20 20 54 68 65 72  umulative.  Ther
16d0: 65 20 63 61 6e 20 62 65 20 6d 75 6c 74 69 70 6c  e can be multipl
16e0: 65 20 73 75 63 63 65 73 73 66 75 6c 0a 6c 6f 67  e successful.log
16f0: 69 6e 20 63 61 72 64 73 2e 20 20 54 68 65 20 73  in cards.  The s
1700: 65 73 73 69 6f 6e 20 70 72 69 76 69 6c 65 67 65  ession privilege
1710: 73 20 61 72 65 20 74 68 65 20 62 69 74 2d 77 69  s are the bit-wi
1720: 73 65 20 4f 52 20 6f 66 20 74 68 65 0a 70 72 69  se OR of the.pri
1730: 76 69 6c 65 67 65 73 20 6f 66 20 65 61 63 68 20  vileges of each 
1740: 69 6e 64 69 76 69 64 75 61 6c 20 6c 6f 67 69 6e  individual login
1750: 2e 3c 2f 70 3e 0a 0a 3c 68 33 3e 33 2e 33 20 46  .</p>..<h3>3.3 F
1760: 69 6c 65 20 43 61 72 64 73 3c 2f 68 33 3e 0a 0a  ile Cards</h3>..
1770: 3c 70 3e 52 65 70 6f 73 69 74 6f 72 79 20 63 6f  <p>Repository co
1780: 6e 74 65 6e 74 20 72 65 63 6f 72 64 73 20 6f 72  ntent records or
1790: 20 66 69 6c 65 73 20 61 72 65 20 74 72 61 6e 73   files are trans
17a0: 66 65 72 72 65 64 20 75 73 69 6e 67 0a 61 20 22  ferred using.a "
17b0: 66 69 6c 65 22 20 63 61 72 64 2e 20 20 46 69 6c  file" card.  Fil
17c0: 65 20 63 61 72 64 73 20 63 6f 6d 65 20 69 6e 20  e cards come in 
17d0: 74 77 6f 20 64 69 66 66 65 72 65 6e 74 20 66 6f  two different fo
17e0: 72 6d 61 74 73 20 64 65 70 65 6e 64 69 6e 67 0a  rmats depending.
17f0: 6f 6e 20 77 68 65 74 68 65 72 20 74 68 65 20 66  on whether the f
1800: 69 6c 65 20 69 73 20 73 65 6e 74 20 64 69 72 65  ile is sent dire
1810: 63 74 6c 79 20 6f 72 20 61 73 20 61 20 64 65 6c  ctly or as a del
1820: 74 61 20 66 72 6f 6d 20 73 6f 6d 65 0a 6f 74 68  ta from some.oth
1830: 65 72 20 66 69 6c 65 2e 3c 2f 70 3e 0a 0a 3c 62  er file.</p>..<b
1840: 6c 6f 63 6b 71 75 6f 74 65 3e 0a 3c 62 3e 66 69  lockquote>.<b>fi
1850: 6c 65 3c 2f 62 3e 20 3c 69 3e 75 75 69 64 20 73  le</b> <i>uuid s
1860: 69 7a 65 3c 2f 69 3e 20 3c 62 3e 5c 6e 3c 2f 62  ize</i> <b>\n</b
1870: 3e 20 3c 69 3e 63 6f 6e 74 65 6e 74 3c 2f 69 3e  > <i>content</i>
1880: 3c 62 72 3e 0a 3c 62 3e 66 69 6c 65 3c 2f 62 3e  <br>.<b>file</b>
1890: 20 3c 69 3e 75 75 69 64 20 64 65 6c 74 61 2d 75   <i>uuid delta-u
18a0: 75 69 64 20 73 69 7a 65 3c 2f 69 3e 20 3c 62 3e  uid size</i> <b>
18b0: 5c 6e 3c 2f 62 3e 20 3c 69 3e 63 6f 6e 74 65 6e  \n</b> <i>conten
18c0: 74 3c 2f 69 3e 0a 3c 2f 62 6c 6f 63 6b 71 75 6f  t</i>.</blockquo
18d0: 74 65 3e 0a 0a 3c 70 3e 46 69 6c 65 20 63 61 72  te>..<p>File car
18e0: 64 73 20 61 72 65 20 64 69 66 66 65 72 65 6e 74  ds are different
18f0: 20 66 72 6f 6d 20 61 6c 6c 20 6f 74 68 65 72 20   from all other 
1900: 63 61 72 64 73 20 69 6e 20 74 68 61 74 20 74 68  cards in that th
1910: 65 79 0a 66 6f 6c 6c 6f 77 65 64 20 62 79 20 69  ey.followed by i
1920: 6e 2d 6c 69 6e 65 20 22 70 61 79 6c 6f 61 64 22  n-line "payload"
1930: 20 64 61 74 61 2e 20 20 54 68 65 20 63 6f 6e 74   data.  The cont
1940: 65 6e 74 20 6f 66 20 74 68 65 20 66 69 6c 65 0a  ent of the file.
1950: 6f 72 20 74 68 65 20 66 69 6c 65 20 64 65 6c 74  or the file delt
1960: 61 20 63 6f 6e 73 69 73 74 73 20 6f 66 20 74 68  a consists of th
1970: 65 20 66 69 72 73 74 20 3c 69 3e 73 69 7a 65 3c  e first <i>size<
1980: 2f 69 3e 20 62 79 74 65 73 20 6f 66 20 74 68 65  /i> bytes of the
1990: 0a 78 2d 66 6f 73 73 69 6c 20 63 6f 6e 74 65 6e  .x-fossil conten
19a0: 74 20 74 68 61 74 20 69 6d 6d 65 64 69 61 74 65  t that immediate
19b0: 6c 79 20 66 6f 6c 6c 6f 77 20 74 68 65 20 6e 65  ly follow the ne
19c0: 77 6c 69 6e 65 20 74 68 61 74 0a 74 65 72 6d 69  wline that.termi
19d0: 6e 61 74 65 73 20 74 68 65 20 66 69 6c 65 20 63  nates the file c
19e0: 61 72 64 2e 20 20 4e 6f 20 6f 74 68 65 72 20 63  ard.  No other c
19f0: 61 72 64 73 20 68 61 76 65 20 74 68 69 73 20 63  ards have this c
1a00: 68 61 72 61 63 74 65 72 69 73 74 69 63 2e 0a 3c  haracteristic..<
1a10: 2f 70 3e 0a 0a 3c 70 3e 54 68 65 20 66 69 72 73  /p>..<p>The firs
1a20: 74 20 61 72 67 75 6d 65 6e 74 20 6f 66 20 61 20  t argument of a 
1a30: 66 69 6c 65 20 63 61 72 64 20 69 73 20 74 68 65  file card is the
1a40: 20 55 55 49 44 20 6f 66 20 74 68 65 20 66 69 6c   UUID of the fil
1a50: 65 20 74 68 61 74 0a 69 73 20 62 65 69 6e 67 20  e that.is being 
1a60: 74 72 61 6e 73 66 65 72 72 65 64 2e 20 20 54 68  transferred.  Th
1a70: 65 20 55 55 49 44 20 69 73 20 74 68 65 20 6c 6f  e UUID is the lo
1a80: 77 65 72 2d 63 61 73 65 20 68 65 78 61 64 65 63  wer-case hexadec
1a90: 69 6d 61 6c 0a 72 65 70 72 65 73 65 6e 74 61 74  imal.representat
1aa0: 69 6f 6e 20 6f 66 20 74 68 65 20 53 48 41 31 20  ion of the SHA1 
1ab0: 68 61 73 68 20 6f 66 20 74 68 65 20 65 6e 74 69  hash of the enti
1ac0: 72 65 20 66 69 6c 65 20 63 6f 6e 74 65 6e 74 2e  re file content.
1ad0: 0a 54 68 65 20 6c 61 73 74 20 61 72 67 75 6d 65  .The last argume
1ae0: 6e 74 20 6f 66 20 74 68 65 20 66 69 6c 65 20 63  nt of the file c
1af0: 61 72 64 20 69 73 20 74 68 65 20 6e 75 6d 62 65  ard is the numbe
1b00: 72 20 6f 66 20 62 79 74 65 73 20 6f 66 0a 70 61  r of bytes of.pa
1b10: 79 6c 6f 61 64 20 74 68 61 74 20 69 6d 6d 65 64  yload that immed
1b20: 69 61 74 65 6c 79 20 66 6f 6c 6c 6f 77 20 74 68  iately follow th
1b30: 65 20 66 69 6c 65 20 63 61 72 64 2e 20 20 49 66  e file card.  If
1b40: 20 74 68 65 20 66 69 6c 65 0a 63 61 72 64 20 68   the file.card h
1b50: 61 73 20 6f 6e 6c 79 20 74 77 6f 20 61 72 67 75  as only two argu
1b60: 6d 65 6e 74 73 2c 20 74 68 61 74 20 6d 65 61 6e  ments, that mean
1b70: 73 20 74 68 65 20 70 61 79 6c 6f 61 64 20 69 73  s the payload is
1b80: 20 74 68 65 0a 63 6f 6d 70 6c 65 74 65 20 63 6f   the.complete co
1b90: 6e 74 65 6e 74 20 6f 66 20 74 68 65 20 66 69 6c  ntent of the fil
1ba0: 65 2e 20 20 49 66 20 74 68 65 20 66 69 6c 65 20  e.  If the file 
1bb0: 63 61 72 64 20 68 61 73 20 74 68 72 65 65 0a 61  card has three.a
1bc0: 72 67 75 6d 65 6e 74 73 2c 20 74 68 65 6e 20 74  rguments, then t
1bd0: 68 65 20 70 61 79 6c 6f 61 64 20 69 73 20 61 20  he payload is a 
1be0: 64 65 6c 74 61 20 61 6e 64 20 73 65 63 6f 6e 64  delta and second
1bf0: 20 61 72 67 75 6d 65 6e 74 20 69 73 0a 74 68 65   argument is.the
1c00: 20 55 55 49 44 20 6f 66 20 61 6e 6f 74 68 65 72   UUID of another
1c10: 20 66 69 6c 65 20 74 68 61 74 20 69 73 20 74 68   file that is th
1c20: 65 20 73 6f 75 72 63 65 20 6f 66 20 74 68 65 20  e source of the 
1c30: 64 65 6c 74 61 2e 3c 2f 70 3e 0a 0a 3c 70 3e 46  delta.</p>..<p>F
1c40: 69 6c 65 20 63 61 72 64 73 20 61 72 65 20 73 65  ile cards are se
1c50: 6e 74 20 69 6e 20 62 6f 74 68 20 64 69 72 65 63  nt in both direc
1c60: 74 69 6f 6e 73 3a 20 63 6c 69 65 6e 74 20 74 6f  tions: client to
1c70: 20 73 65 72 76 65 72 20 61 6e 64 0a 73 65 72 76   server and.serv
1c80: 65 72 20 74 6f 20 63 6c 69 65 6e 74 2e 20 20 41  er to client.  A
1c90: 20 64 65 6c 74 61 20 6d 69 67 68 74 20 62 65 20   delta might be 
1ca0: 73 65 6e 74 20 62 65 66 6f 72 65 20 74 68 65 20  sent before the 
1cb0: 73 6f 75 72 63 65 20 6f 66 0a 74 68 65 20 64 65  source of.the de
1cc0: 6c 74 61 2c 20 73 6f 20 62 6f 74 68 20 63 6c 69  lta, so both cli
1cd0: 65 6e 74 20 61 6e 64 20 73 65 72 76 65 72 20 73  ent and server s
1ce0: 68 6f 75 6c 64 20 72 65 6d 65 6d 62 65 72 20 64  hould remember d
1cf0: 65 6c 74 61 73 0a 61 6e 64 20 62 65 20 61 62 6c  eltas.and be abl
1d00: 65 20 74 6f 20 61 70 70 6c 79 20 74 68 65 6d 20  e to apply them 
1d10: 77 68 65 6e 20 74 68 65 69 72 20 73 6f 75 72 63  when their sourc
1d20: 65 20 61 72 72 69 76 65 73 2e 3c 2f 70 3e 0a 0a  e arrives.</p>..
1d30: 3c 68 33 3e 33 2e 34 20 50 75 73 68 20 61 6e 64  <h3>3.4 Push and
1d40: 20 50 75 6c 6c 20 43 61 72 64 73 3c 2f 68 33 3e   Pull Cards</h3>
1d50: 0a 0a 3c 70 3e 41 6d 6f 6e 67 20 6f 66 20 74 68  ..<p>Among of th
1d60: 65 20 66 69 72 73 74 20 63 61 72 64 73 20 69 6e  e first cards in
1d70: 20 61 20 63 6c 69 65 6e 74 2d 74 6f 2d 73 65 72   a client-to-ser
1d80: 76 65 72 20 6d 65 73 73 61 67 65 20 61 72 65 0a  ver message are.
1d90: 74 68 65 20 70 75 73 68 20 61 6e 64 20 70 75 6c  the push and pul
1da0: 6c 20 63 61 72 64 73 2e 20 20 54 68 65 20 70 75  l cards.  The pu
1db0: 73 68 20 63 61 72 64 20 74 65 6c 6c 20 74 68 65  sh card tell the
1dc0: 20 73 65 72 76 65 72 20 74 68 61 74 0a 74 68 65   server that.the
1dd0: 20 63 6c 69 65 6e 74 20 69 73 20 70 75 73 68 69   client is pushi
1de0: 6e 67 20 63 6f 6e 74 65 6e 74 2e 20 20 54 68 65  ng content.  The
1df0: 20 70 75 6c 6c 20 63 61 72 64 20 74 65 6c 6c 20   pull card tell 
1e00: 74 68 65 20 73 65 72 76 65 72 0a 74 68 61 74 20  the server.that 
1e10: 74 68 65 20 63 6c 69 65 6e 74 20 77 61 6e 74 73  the client wants
1e20: 20 74 6f 20 70 75 6c 6c 20 63 6f 6e 74 65 6e 74   to pull content
1e30: 2e 20 20 49 6e 20 74 68 65 20 65 76 65 6e 74 20  .  In the event 
1e40: 6f 66 20 61 20 73 79 6e 63 2c 0a 62 6f 74 68 20  of a sync,.both 
1e50: 63 61 72 64 73 20 61 72 65 20 73 65 6e 74 2e 20  cards are sent. 
1e60: 20 54 68 65 20 66 6f 72 6d 61 74 20 69 73 20 61   The format is a
1e70: 73 20 66 6f 6c 6c 6f 77 73 3a 3c 2f 70 3e 0a 0a  s follows:</p>..
1e80: 3c 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 3c 62 3e  <blockquote>.<b>
1e90: 70 75 73 68 3c 2f 62 3e 20 3c 69 3e 73 65 72 76  push</b> <i>serv
1ea0: 65 72 63 6f 64 65 20 70 72 6f 6a 65 63 74 63 6f  ercode projectco
1eb0: 64 65 3c 2f 69 3e 3c 62 72 3e 0a 3c 62 3e 70 75  de</i><br>.<b>pu
1ec0: 6c 6c 3c 2f 62 3e 20 3c 69 3e 73 65 72 76 65 72  ll</b> <i>server
1ed0: 63 6f 64 65 20 70 72 6f 6a 65 63 74 63 6f 64 65  code projectcode
1ee0: 3c 2f 69 3e 0a 3c 2f 62 6c 6f 63 6b 71 75 6f 74  </i>.</blockquot
1ef0: 65 3e 0a 0a 3c 70 3e 54 68 65 20 3c 69 3e 73 65  e>..<p>The <i>se
1f00: 72 76 65 72 63 6f 64 65 3c 2f 69 3e 20 61 72 67  rvercode</i> arg
1f10: 75 6d 65 6e 74 20 69 73 20 74 68 65 20 72 65 70  ument is the rep
1f20: 6f 73 69 74 6f 72 79 20 49 44 20 66 6f 72 20 74  ository ID for t
1f30: 68 65 0a 63 6c 69 65 6e 74 2e 20 20 54 68 65 20  he.client.  The 
1f40: 73 65 72 76 65 72 20 77 69 6c 6c 20 6f 6e 6c 79  server will only
1f50: 20 61 6c 6c 6f 77 20 74 68 65 20 74 72 61 6e 73   allow the trans
1f60: 61 63 74 69 6f 6e 20 74 6f 20 70 72 6f 63 65 65  action to procee
1f70: 64 0a 69 66 20 74 68 65 20 73 65 72 76 65 72 63  d.if the serverc
1f80: 6f 64 65 20 69 73 20 64 69 66 66 65 72 65 6e 74  ode is different
1f90: 20 66 72 6f 6d 20 69 74 73 20 6f 77 6e 20 73 65   from its own se
1fa0: 72 76 65 72 63 6f 64 65 2e 20 20 54 68 69 73 0a  rvercode.  This.
1fb0: 70 72 65 76 65 6e 74 73 20 61 20 73 79 6e 63 2d  prevents a sync-
1fc0: 6c 6f 6f 70 2e 20 20 54 68 65 20 3c 69 3e 70 72  loop.  The <i>pr
1fd0: 6f 6a 65 63 74 63 6f 64 65 3c 2f 69 3e 20 69 73  ojectcode</i> is
1fe0: 20 74 68 65 20 69 64 65 6e 74 69 66 69 65 72 0a   the identifier.
1ff0: 6f 66 20 74 68 65 20 73 6f 66 74 77 61 72 65 20  of the software 
2000: 70 72 6f 6a 65 63 74 20 74 68 61 74 20 74 68 65  project that the
2010: 20 63 6c 69 65 6e 74 20 72 65 70 6f 73 69 74 6f   client reposito
2020: 72 79 20 63 6f 6e 74 61 69 6e 73 2e 0a 54 68 65  ry contains..The
2030: 20 70 72 6f 6a 65 63 74 63 6f 64 65 20 66 6f 72   projectcode for
2040: 20 74 68 65 20 63 6c 69 65 6e 74 20 61 6e 64 20   the client and 
2050: 73 65 72 76 65 72 20 6d 75 73 74 20 6d 61 74 63  server must matc
2060: 68 20 69 6e 20 6f 72 64 65 72 0a 66 6f 72 20 74  h in order.for t
2070: 68 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 20 74  he transaction t
2080: 6f 20 70 72 6f 63 65 65 64 2e 3c 2f 70 3e 0a 0a  o proceed.</p>..
2090: 3c 70 3e 54 68 65 20 73 65 72 76 65 72 20 77 69  <p>The server wi
20a0: 6c 6c 20 61 6c 73 6f 20 73 65 6e 64 20 61 20 70  ll also send a p
20b0: 75 73 68 20 63 61 72 64 20 62 61 63 6b 20 74 6f  ush card back to
20c0: 20 74 68 65 20 63 6c 69 65 6e 74 0a 64 75 72 69   the client.duri
20d0: 6e 67 20 61 20 63 6c 6f 6e 65 2e 20 20 54 68 69  ng a clone.  Thi
20e0: 73 20 69 73 20 68 6f 77 20 74 68 65 20 63 6c 69  s is how the cli
20f0: 65 6e 74 20 64 65 74 65 72 6d 69 6e 65 73 20 77  ent determines w
2100: 68 61 74 20 70 72 6f 6a 65 63 74 0a 63 6f 64 65  hat project.code
2110: 20 74 6f 20 70 75 74 20 69 6e 20 74 68 65 20 6e   to put in the n
2120: 65 77 20 72 65 70 6f 73 69 74 6f 72 79 20 69 74  ew repository it
2130: 20 69 73 20 63 6f 6e 73 74 72 75 63 74 69 6e 67   is constructing
2140: 2e 3c 2f 70 3e 0a 0a 3c 68 33 3e 33 2e 35 20 43  .</p>..<h3>3.5 C
2150: 6c 6f 6e 65 20 43 61 72 64 73 3c 2f 68 33 3e 0a  lone Cards</h3>.
2160: 0a 3c 70 3e 41 20 63 6c 6f 6e 65 20 63 61 72 64  .<p>A clone card
2170: 20 77 6f 72 6b 73 20 6c 69 6b 65 20 61 20 70 75   works like a pu
2180: 6c 6c 20 63 61 72 64 20 69 6e 20 74 68 61 74 20  ll card in that 
2190: 69 74 20 69 73 20 73 65 6e 74 20 66 72 6f 6d 0a  it is sent from.
21a0: 63 6c 69 65 6e 74 20 74 6f 20 73 65 72 76 65 72  client to server
21b0: 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 74 65 6c   in order to tel
21c0: 6c 20 74 68 65 20 73 65 72 76 65 72 20 74 68 61  l the server tha
21d0: 74 20 74 68 65 20 63 6c 69 65 6e 74 0a 77 61 6e  t the client.wan
21e0: 74 73 20 74 6f 20 70 75 6c 6c 20 63 6f 6e 74 65  ts to pull conte
21f0: 6e 74 2e 20 20 42 75 74 20 75 6e 6c 69 6b 65 20  nt.  But unlike 
2200: 74 68 65 20 70 75 6c 6c 20 63 61 72 64 2c 20 74  the pull card, t
2210: 68 65 20 63 6c 6f 6e 65 0a 63 61 72 64 20 68 61  he clone.card ha
2220: 73 20 6e 6f 20 61 72 67 75 6d 65 6e 74 73 2e 3c  s no arguments.<
2230: 2f 70 3e 0a 0a 3c 62 6c 6f 63 6b 71 75 6f 74 65  /p>..<blockquote
2240: 3e 0a 3c 62 3e 63 6c 6f 6e 65 3c 2f 62 3e 0a 3c  >.<b>clone</b>.<
2250: 2f 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 0a 3c 70  /blockquote>..<p
2260: 3e 49 6e 20 72 65 73 70 6f 6e 73 65 20 74 6f 20  >In response to 
2270: 61 20 63 6c 6f 6e 65 20 6d 65 73 73 61 67 65 2c  a clone message,
2280: 20 74 68 65 20 73 65 72 76 65 72 20 61 6c 73 6f   the server also
2290: 20 73 65 6e 64 73 20 74 68 65 20 63 6c 69 65 6e   sends the clien
22a0: 74 0a 61 20 70 75 73 68 20 6d 65 73 73 61 67 65  t.a push message
22b0: 20 73 6f 20 74 68 61 74 20 74 68 65 20 63 6c 69   so that the cli
22c0: 65 6e 74 20 63 61 6e 20 64 69 73 63 6f 76 65 72  ent can discover
22d0: 20 74 68 65 20 70 72 6f 6a 65 63 74 63 6f 64 65   the projectcode
22e0: 20 66 6f 72 0a 74 68 69 73 20 70 72 6f 6a 65 63   for.this projec
22f0: 74 2e 3c 2f 70 3e 0a 0a 3c 68 33 3e 33 2e 36 20  t.</p>..<h3>3.6 
2300: 49 67 6f 74 20 43 61 72 64 73 3c 2f 68 33 3e 0a  Igot Cards</h3>.
2310: 0a 3c 70 3e 41 6e 20 69 67 6f 74 20 63 61 72 64  .<p>An igot card
2320: 20 63 61 6e 20 62 65 20 73 65 6e 74 20 66 72 6f   can be sent fro
2330: 6d 20 65 69 74 68 65 72 20 63 6c 69 65 6e 74 20  m either client 
2340: 74 6f 20 73 65 72 76 65 72 20 6f 72 20 66 72 6f  to server or fro
2350: 6d 0a 73 65 72 76 65 72 20 74 6f 20 63 6c 69 65  m.server to clie
2360: 6e 74 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 69  nt in order to i
2370: 6e 64 69 63 61 74 65 20 74 68 61 74 20 74 68 65  ndicate that the
2380: 20 73 65 6e 64 65 72 20 68 6f 6c 64 73 20 61 20   sender holds a 
2390: 63 6f 70 79 0a 6f 66 20 61 20 70 61 72 74 69 63  copy.of a partic
23a0: 75 6c 61 72 20 66 69 6c 65 2e 20 20 54 68 65 20  ular file.  The 
23b0: 66 6f 72 6d 61 74 20 69 73 3a 3c 2f 70 3e 0a 0a  format is:</p>..
23c0: 3c 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 3c 62 3e  <blockquote>.<b>
23d0: 69 67 6f 74 3c 2f 62 3e 20 3c 69 3e 75 75 69 64  igot</b> <i>uuid
23e0: 3c 2f 69 3e 0a 3c 2f 62 6c 6f 63 6b 71 75 6f 74  </i>.</blockquot
23f0: 65 3e 0a 0a 3c 70 3e 54 68 65 20 61 72 67 75 6d  e>..<p>The argum
2400: 65 6e 74 20 6f 66 20 74 68 65 20 69 67 6f 74 20  ent of the igot 
2410: 63 61 72 64 20 69 73 20 74 68 65 20 55 55 49 44  card is the UUID
2420: 20 6f 66 20 74 68 65 20 66 69 6c 65 20 74 68 61   of the file tha
2430: 74 0a 74 68 65 20 73 65 6e 64 65 72 20 70 6f 73  t.the sender pos
2440: 73 65 73 73 65 73 2e 0a 54 68 65 20 72 65 63 65  sesses..The rece
2450: 69 76 65 72 20 6f 66 20 61 6e 20 69 67 6f 74 20  iver of an igot 
2460: 63 61 72 64 20 77 69 6c 6c 20 74 79 70 69 63 61  card will typica
2470: 6c 6c 79 20 63 68 65 63 6b 20 74 6f 20 73 65 65  lly check to see
2480: 20 69 66 0a 69 74 20 61 6c 73 6f 20 68 6f 6c 64   if.it also hold
2490: 73 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65 20  s the same file 
24a0: 61 6e 64 20 69 66 20 6e 6f 74 20 69 74 20 77 69  and if not it wi
24b0: 6c 6c 20 72 65 71 75 65 73 74 20 74 68 65 20 66  ll request the f
24c0: 69 6c 65 0a 75 73 69 6e 67 20 61 20 67 69 6d 6d  ile.using a gimm
24d0: 65 20 63 61 72 64 20 69 6e 20 65 69 74 68 65 72  e card in either
24e0: 20 74 68 65 20 72 65 70 6c 79 20 6f 72 20 69 6e   the reply or in
24f0: 20 74 68 65 20 6e 65 78 74 20 6d 65 73 73 61 67   the next messag
2500: 65 2e 3c 2f 70 3e 0a 0a 3c 68 33 3e 33 2e 37 20  e.</p>..<h3>3.7 
2510: 47 69 6d 6d 65 20 43 61 72 64 73 3c 2f 68 33 3e  Gimme Cards</h3>
2520: 0a 0a 3c 70 3e 41 20 67 69 6d 6d 65 20 63 61 72  ..<p>A gimme car
2530: 64 20 69 73 20 73 65 6e 74 20 66 72 6f 6d 20 65  d is sent from e
2540: 69 74 68 65 72 20 63 6c 69 65 6e 74 20 74 6f 20  ither client to 
2550: 73 65 72 76 65 72 20 6f 72 20 66 72 6f 6d 20 73  server or from s
2560: 65 72 76 65 72 0a 74 6f 20 63 6c 69 65 6e 74 2e  erver.to client.
2570: 20 20 54 68 65 20 67 69 6d 6d 65 20 63 61 72 64    The gimme card
2580: 20 61 73 6b 73 20 74 68 65 20 72 65 63 65 69 76   asks the receiv
2590: 65 72 20 74 6f 20 73 65 6e 64 20 61 20 70 61 72  er to send a par
25a0: 74 69 63 75 6c 61 72 0a 66 69 6c 65 20 62 61 63  ticular.file bac
25b0: 6b 20 74 6f 20 74 68 65 20 73 65 6e 64 65 72 2e  k to the sender.
25c0: 20 20 54 68 65 20 66 6f 72 6d 61 74 20 6f 66 20    The format of 
25d0: 61 20 67 69 6d 6d 65 20 63 61 72 64 20 69 73 20  a gimme card is 
25e0: 74 68 69 73 3a 3c 2f 70 3e 0a 0a 3c 62 6c 6f 63  this:</p>..<bloc
25f0: 6b 71 75 6f 74 65 3e 0a 3c 62 3e 67 69 6d 6d 65  kquote>.<b>gimme
2600: 3c 2f 62 3e 20 3c 69 3e 75 75 69 64 3c 2f 69 3e  </b> <i>uuid</i>
2610: 0a 3c 2f 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 0a  .</blockquote>..
2620: 3c 70 3e 54 68 65 20 61 72 67 75 6d 65 6e 74 20  <p>The argument 
2630: 74 6f 20 74 68 65 20 67 69 6d 6d 65 20 63 61 72  to the gimme car
2640: 64 20 69 73 20 74 68 65 20 55 55 49 44 20 6f 66  d is the UUID of
2650: 20 74 68 65 20 66 69 6c 65 20 74 68 61 74 0a 74   the file that.t
2660: 68 65 20 73 65 6e 64 65 72 20 77 61 6e 74 73 2e  he sender wants.
2670: 20 20 54 68 65 20 72 65 63 65 69 76 65 72 20 77    The receiver w
2680: 69 6c 6c 20 74 79 70 69 63 61 6c 6c 79 20 72 65  ill typically re
2690: 73 70 6f 6e 64 20 74 6f 20 61 0a 67 69 6d 6d 65  spond to a.gimme
26a0: 20 63 61 72 64 20 62 79 20 73 65 6e 64 69 6e 67   card by sending
26b0: 20 61 20 66 69 6c 65 20 63 61 72 64 20 69 6e 20   a file card in 
26c0: 69 74 73 20 72 65 70 6c 79 20 6f 72 20 69 6e 20  its reply or in 
26d0: 74 68 65 20 6e 65 78 74 0a 6d 65 73 73 61 67 65  the next.message
26e0: 2e 3c 2f 70 3e 0a 0a 3c 68 33 3e 33 2e 38 20 43  .</p>..<h3>3.8 C
26f0: 6f 6f 6b 69 65 20 43 61 72 64 73 3c 2f 68 33 3e  ookie Cards</h3>
2700: 0a 0a 3c 70 3e 41 20 63 6f 6f 6b 69 65 20 63 61  ..<p>A cookie ca
2710: 72 64 20 63 61 6e 20 62 65 20 75 73 65 64 20 62  rd can be used b
2720: 79 20 61 20 73 65 72 76 65 72 20 74 6f 20 72 65  y a server to re
2730: 63 6f 72 64 20 61 20 73 6d 61 6c 6c 20 61 6d 6f  cord a small amo
2740: 75 6e 74 0a 6f 66 20 73 74 61 74 65 20 69 6e 66  unt.of state inf
2750: 6f 72 6d 61 74 69 6f 6e 20 6f 6e 20 61 20 63 6c  ormation on a cl
2760: 69 65 6e 74 2e 20 20 54 68 65 20 73 65 72 76 65  ient.  The serve
2770: 72 20 73 65 6e 64 73 20 61 20 63 6f 6f 6b 69 65  r sends a cookie
2780: 20 74 6f 20 74 68 65 0a 63 6c 69 65 6e 74 2e 20   to the.client. 
2790: 20 54 68 65 20 63 6c 69 65 6e 74 20 73 65 6e 64   The client send
27a0: 73 20 74 68 65 20 73 61 6d 65 20 63 6f 6f 6b 69  s the same cooki
27b0: 65 20 62 61 63 6b 20 74 6f 20 74 68 65 20 73 65  e back to the se
27c0: 72 76 65 72 20 6f 6e 0a 69 74 73 20 6e 65 78 74  rver on.its next
27d0: 20 72 65 71 75 65 73 74 2e 20 20 54 68 65 20 63   request.  The c
27e0: 6f 6f 6b 69 65 20 63 61 72 64 20 68 61 73 20 61  ookie card has a
27f0: 20 73 69 6e 67 6c 65 20 61 72 67 75 6d 65 6e 74   single argument
2800: 20 77 68 69 63 68 0a 69 73 20 69 74 73 20 70 61   which.is its pa
2810: 79 6c 6f 61 64 2e 3c 2f 70 3e 0a 0a 3c 62 6c 6f  yload.</p>..<blo
2820: 63 6b 71 75 6f 74 65 3e 0a 3c 62 3e 63 6f 6f 6b  ckquote>.<b>cook
2830: 69 65 3c 2f 62 3e 20 3c 69 3e 70 61 79 6c 6f 61  ie</b> <i>payloa
2840: 64 3c 2f 69 3e 0a 3c 2f 62 6c 6f 63 6b 71 75 6f  d</i>.</blockquo
2850: 74 65 3e 0a 0a 3c 70 3e 54 68 65 20 63 6c 69 65  te>..<p>The clie
2860: 6e 74 20 69 73 20 6e 6f 74 20 72 65 71 75 69 72  nt is not requir
2870: 65 64 20 74 6f 20 72 65 74 75 72 6e 20 74 68 65  ed to return the
2880: 20 63 6f 6f 6b 69 65 20 74 6f 20 74 68 65 20 73   cookie to the s
2890: 65 72 76 65 72 20 6f 6e 0a 69 74 73 20 6e 65 78  erver on.its nex
28a0: 74 20 72 65 71 75 65 73 74 2e 20 20 4f 72 20 74  t request.  Or t
28b0: 68 65 20 63 6c 69 65 6e 74 20 6d 69 67 68 74 20  he client might 
28c0: 73 65 6e 64 20 61 20 63 6f 6f 6b 69 65 20 66 72  send a cookie fr
28d0: 6f 6d 20 61 20 64 69 66 66 65 72 65 6e 74 0a 73  om a different.s
28e0: 65 72 76 65 72 20 6f 6e 20 74 68 65 20 6e 65 78  erver on the nex
28f0: 74 20 72 65 71 75 65 73 74 2e 20 20 53 6f 20 74  t request.  So t
2900: 68 65 20 73 65 72 76 65 72 20 6d 75 73 74 20 6e  he server must n
2910: 6f 74 20 64 65 70 65 6e 64 20 6f 6e 20 74 68 65  ot depend on the
2920: 0a 63 6f 6f 6b 69 65 20 61 6e 64 20 74 68 65 20  .cookie and the 
2930: 73 65 72 76 65 72 20 6d 75 73 74 20 73 74 72 75  server must stru
2940: 63 74 75 72 65 20 74 68 65 20 63 6f 6f 6b 69 65  cture the cookie
2950: 20 70 61 79 6c 6f 61 64 20 69 6e 20 73 75 63 68   payload in such
2960: 0a 61 20 77 61 79 20 74 68 61 74 20 69 74 20 63  .a way that it c
2970: 61 6e 20 74 65 6c 6c 20 69 66 20 74 68 65 20 63  an tell if the c
2980: 6f 6f 6b 69 65 20 69 74 20 73 65 65 73 20 69 73  ookie it sees is
2990: 20 69 74 73 20 6f 77 6e 20 63 6f 6f 6b 69 65 20   its own cookie 
29a0: 6f 72 0a 61 20 63 6f 6f 6b 69 65 20 66 72 6f 6d  or.a cookie from
29b0: 20 61 6e 6f 74 68 65 72 20 73 65 72 76 65 72 2e   another server.
29c0: 20 20 28 54 79 70 69 63 61 6c 6c 79 20 74 68 65    (Typically the
29d0: 20 73 65 72 76 65 72 20 77 69 6c 6c 20 65 6d 62   server will emb
29e0: 65 64 0a 69 74 73 20 73 65 72 76 65 72 63 6f 64  ed.its servercod
29f0: 65 20 61 73 20 70 61 72 74 20 6f 66 20 74 68 65  e as part of the
2a00: 20 63 6f 6f 6b 69 65 2e 29 3c 2f 70 3e 0a 0a 3c   cookie.)</p>..<
2a10: 68 33 3e 33 2e 39 20 45 72 72 6f 72 20 43 61 72  h3>3.9 Error Car
2a20: 64 73 3c 2f 68 33 3e 0a 0a 3c 70 3e 49 66 20 74  ds</h3>..<p>If t
2a30: 68 65 20 73 65 72 76 65 72 20 64 69 73 63 6f 76  he server discov
2a40: 65 72 73 20 61 6e 79 74 68 69 6e 67 20 77 72 6f  ers anything wro
2a50: 6e 67 20 77 69 74 68 20 61 20 72 65 71 75 65 73  ng with a reques
2a60: 74 2c 20 69 74 20 67 65 6e 65 72 61 74 65 73 0a  t, it generates.
2a70: 61 6e 20 65 72 72 6f 72 20 63 61 72 64 20 69 6e  an error card in
2a80: 20 69 74 73 20 72 65 70 6c 79 2e 20 20 57 68 65   its reply.  Whe
2a90: 6e 20 74 68 65 20 63 6c 69 65 6e 74 20 73 65 65  n the client see
2aa0: 73 20 74 68 65 20 65 72 72 6f 72 20 63 61 72 64  s the error card
2ab0: 2c 0a 69 74 20 64 69 73 70 6c 61 79 73 20 61 6e  ,.it displays an
2ac0: 20 65 72 72 6f 72 20 6d 65 73 73 61 67 65 20 74   error message t
2ad0: 6f 20 74 68 65 20 75 73 65 72 20 61 6e 64 20 61  o the user and a
2ae0: 62 6f 72 74 73 20 74 68 65 20 73 79 6e 63 0a 6f  borts the sync.o
2af0: 70 65 72 61 74 69 6f 6e 2e 20 20 41 6e 20 65 72  peration.  An er
2b00: 72 6f 72 20 63 61 72 64 20 6c 6f 6f 6b 73 20 6c  ror card looks l
2b10: 69 6b 65 20 74 68 69 73 3a 3c 2f 70 3e 0a 0a 3c  ike this:</p>..<
2b20: 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 3c 62 3e 65  blockquote>.<b>e
2b30: 72 72 6f 72 3c 2f 62 3e 20 3c 69 3e 65 72 72 6f  rror</b> <i>erro
2b40: 72 2d 6d 65 73 73 61 67 65 3c 2f 69 3e 0a 3c 2f  r-message</i>.</
2b50: 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 0a 3c 70 3e  blockquote>..<p>
2b60: 54 68 65 20 65 72 72 6f 72 20 6d 65 73 73 61 67  The error messag
2b70: 65 20 69 73 20 45 6e 67 6c 69 73 68 20 74 65 78  e is English tex
2b80: 74 20 74 68 61 74 20 69 73 20 65 6e 63 6f 64 65  t that is encode
2b90: 64 20 69 6e 20 6f 72 64 65 72 20 74 6f 0a 62 65  d in order to.be
2ba0: 20 61 20 73 69 6e 67 6c 65 20 74 6f 6b 65 6e 2e   a single token.
2bb0: 0a 41 20 73 70 61 63 65 20 28 41 53 43 49 49 20  .A space (ASCII 
2bc0: 30 78 32 30 29 20 69 73 20 72 65 70 72 65 73 65  0x20) is represe
2bd0: 6e 74 65 64 20 61 73 20 22 5c 73 22 20 28 41 53  nted as "\s" (AS
2be0: 43 49 49 20 30 78 35 43 2c 20 30 78 37 33 29 2e  CII 0x5C, 0x73).
2bf0: 20 20 41 0a 6e 65 77 6c 69 6e 65 20 28 41 53 43    A.newline (ASC
2c00: 49 49 20 30 78 30 61 29 20 69 73 20 22 5c 6e 22  II 0x0a) is "\n"
2c10: 20 28 41 53 43 49 49 20 30 78 36 43 2c 20 78 36   (ASCII 0x6C, x6
2c20: 45 29 2e 20 20 41 20 62 61 63 6b 73 6c 61 73 68  E).  A backslash
2c30: 20 0a 28 41 53 43 49 49 20 30 78 35 43 29 20 69   .(ASCII 0x5C) i
2c40: 73 20 72 65 70 72 65 73 65 6e 74 65 64 20 61 73  s represented as
2c50: 20 74 77 6f 20 62 61 63 6b 73 6c 61 73 68 65 73   two backslashes
2c60: 20 22 5c 5c 22 2e 20 20 41 70 61 72 74 20 66 72   "\\".  Apart fr
2c70: 6f 6d 0a 73 70 61 63 65 20 61 6e 64 20 6e 65 77  om.space and new
2c80: 6c 69 6e 65 2c 20 6e 6f 20 6f 74 68 65 72 20 77  line, no other w
2c90: 68 69 74 65 73 70 61 63 65 20 63 68 61 72 61 63  hitespace charac
2ca0: 74 65 72 73 20 6e 6f 72 20 61 6e 79 0a 75 6e 70  ters nor any.unp
2cb0: 72 69 6e 74 61 62 6c 65 20 63 68 61 72 61 63 74  rintable charact
2cc0: 65 72 73 20 61 72 65 20 61 6c 6c 6f 77 65 64 20  ers are allowed 
2cd0: 69 6e 0a 74 68 65 20 65 72 72 6f 72 20 6d 65 73  in.the error mes
2ce0: 73 61 67 65 2e 3c 2f 70 3e 0a 0a 3c 68 33 3e 33  sage.</p>..<h3>3
2cf0: 2e 31 30 20 55 6e 6b 6e 6f 77 6e 20 43 61 72 64  .10 Unknown Card
2d00: 73 3c 2f 68 33 3e 0a 0a 3c 70 3e 49 66 20 65 69  s</h3>..<p>If ei
2d10: 74 68 65 72 20 74 68 65 20 63 6c 69 65 6e 74 20  ther the client 
2d20: 6f 72 20 74 68 65 20 73 65 72 76 65 72 20 73 65  or the server se
2d30: 65 73 20 61 20 63 61 72 64 20 74 68 61 74 20 69  es a card that i
2d40: 73 20 6e 6f 74 0a 64 65 73 63 72 69 62 65 64 20  s not.described 
2d50: 61 62 6f 76 65 2c 20 74 68 65 6e 20 69 74 20 67  above, then it g
2d60: 65 6e 65 72 61 74 65 73 20 61 6e 20 65 72 72 6f  enerates an erro
2d70: 72 20 61 6e 64 20 61 62 6f 72 74 73 2e 3c 2f 70  r and aborts.</p
2d80: 3e 0a 0a 3c 68 32 3e 34 2e 30 20 50 68 61 6e 74  >..<h2>4.0 Phant
2d90: 6f 6d 73 20 41 6e 64 20 43 6c 75 73 74 65 72 73  oms And Clusters
2da0: 3c 2f 68 32 3e 0a 0a 3c 70 3e 57 68 65 6e 20 61  </h2>..<p>When a
2db0: 20 72 65 70 6f 73 69 74 6f 72 79 20 6b 6e 6f 77   repository know
2dc0: 73 20 74 68 61 74 20 61 20 66 69 6c 65 20 65 78  s that a file ex
2dd0: 69 73 74 73 20 61 6e 64 20 6b 6e 6f 77 73 20 74  ists and knows t
2de0: 68 65 20 55 55 49 44 20 6f 66 0a 74 68 61 74 20  he UUID of.that 
2df0: 66 69 6c 65 2c 20 62 75 74 20 69 74 20 64 6f 65  file, but it doe
2e00: 73 20 6e 6f 74 20 6b 6e 6f 77 20 74 68 65 20 66  s not know the f
2e10: 69 6c 65 20 63 6f 6e 74 65 6e 74 2c 20 74 68 65  ile content, the
2e20: 6e 20 69 74 20 73 74 6f 72 65 73 20 74 68 61 74  n it stores that
2e30: 0a 66 69 6c 65 20 61 73 20 61 20 22 70 68 61 6e  .file as a "phan
2e40: 74 6f 6d 22 2e 20 20 41 20 72 65 70 6f 73 69 74  tom".  A reposit
2e50: 6f 72 79 20 77 69 6c 6c 20 74 79 70 69 63 61 6c  ory will typical
2e60: 6c 79 20 63 72 65 61 74 65 20 61 20 70 68 61 6e  ly create a phan
2e70: 74 6f 6d 20 77 68 65 6e 0a 69 74 20 72 65 63 65  tom when.it rece
2e80: 69 76 65 73 20 61 6e 20 69 67 6f 74 20 63 61 72  ives an igot car
2e90: 64 20 66 6f 72 20 61 20 66 69 6c 65 20 74 68 61  d for a file tha
2ea0: 74 20 69 74 20 64 6f 65 73 20 6e 6f 74 20 68 6f  t it does not ho
2eb0: 6c 64 20 6f 72 20 77 68 65 6e 20 69 74 0a 72 65  ld or when it.re
2ec0: 63 65 69 76 65 73 20 61 20 66 69 6c 65 20 63 61  ceives a file ca
2ed0: 72 64 20 74 68 61 74 20 72 65 66 65 72 65 6e 63  rd that referenc
2ee0: 65 73 20 61 20 64 65 6c 74 61 20 73 6f 75 72 63  es a delta sourc
2ef0: 65 20 74 68 61 74 20 69 74 20 64 6f 65 73 20 6e  e that it does n
2f00: 6f 74 0a 68 6f 6c 64 2e 20 20 57 68 65 6e 20 61  ot.hold.  When a
2f10: 20 73 65 72 76 65 72 20 69 73 20 67 65 6e 65 72   server is gener
2f20: 61 74 69 6e 67 20 69 74 73 20 72 65 70 6c 79 20  ating its reply 
2f30: 6f 72 20 77 68 65 6e 20 61 20 63 6c 69 65 6e 74  or when a client
2f40: 20 69 73 0a 67 65 6e 65 72 61 74 69 6e 67 20 61   is.generating a
2f50: 20 6e 65 77 20 72 65 71 75 65 73 74 2c 20 69 74   new request, it
2f60: 20 77 69 6c 6c 20 75 73 75 61 6c 6c 79 20 73 65   will usually se
2f70: 6e 64 20 67 69 6d 6d 65 20 63 61 72 64 73 20 66  nd gimme cards f
2f80: 6f 72 20 65 76 65 72 79 0a 70 68 61 6e 74 6f 6d  or every.phantom
2f90: 20 74 68 61 74 20 69 74 20 68 6f 6c 64 73 2e 3c   that it holds.<
2fa0: 2f 70 3e 0a 0a 3c 70 3e 41 20 63 6c 75 73 74 65  /p>..<p>A cluste
2fb0: 72 20 69 73 20 61 20 73 70 65 63 69 61 6c 20 66  r is a special f
2fc0: 69 6c 65 20 74 68 61 74 20 74 65 6c 6c 73 20 6f  ile that tells o
2fd0: 66 20 74 68 65 20 65 78 69 73 74 65 6e 63 65 20  f the existence 
2fe0: 6f 66 20 6f 74 68 65 72 0a 66 69 6c 65 73 2e 20  of other.files. 
2ff0: 20 41 6e 79 20 66 69 6c 65 20 69 6e 20 74 68 65   Any file in the
3000: 20 72 65 70 6f 73 69 74 6f 72 79 20 74 68 61 74   repository that
3010: 20 66 6f 6c 6c 6f 77 73 20 74 68 65 20 73 79 6e   follows the syn
3020: 74 61 63 74 69 63 20 72 75 6c 65 73 0a 6f 66 20  tactic rules.of 
3030: 61 20 63 6c 75 73 74 65 72 20 69 73 20 63 6f 6e  a cluster is con
3040: 73 69 64 65 72 65 64 20 61 20 63 6c 75 73 74 65  sidered a cluste
3050: 72 2e 3c 2f 70 3e 0a 0a 3c 70 3e 41 20 63 6c 75  r.</p>..<p>A clu
3060: 73 74 65 72 20 69 73 20 61 20 6c 69 6e 65 20 6f  ster is a line o
3070: 72 69 65 6e 74 65 64 20 66 69 6c 65 2e 20 20 45  riented file.  E
3080: 61 63 68 20 6c 69 6e 65 20 6f 66 20 61 20 63 6c  ach line of a cl
3090: 75 73 74 65 72 0a 69 73 20 61 20 63 61 72 64 2e  uster.is a card.
30a0: 20 20 54 68 65 20 63 61 72 64 73 20 61 72 65 20    The cards are 
30b0: 73 65 70 61 72 61 74 65 64 20 62 79 20 74 68 65  separated by the
30c0: 20 6e 65 77 6c 69 6e 65 20 28 22 5c 6e 22 29 20   newline ("\n") 
30d0: 63 68 61 72 61 63 74 65 72 2e 0a 45 61 63 68 20  character..Each 
30e0: 63 61 72 64 20 63 6f 6e 73 69 73 74 73 20 6f 66  card consists of
30f0: 20 61 20 73 69 6e 67 6c 65 20 63 68 61 72 61 63   a single charac
3100: 74 65 72 20 63 61 72 64 20 74 79 70 65 2c 20 61  ter card type, a
3110: 20 73 70 61 63 65 2c 20 61 6e 64 20 61 0a 73 69   space, and a.si
3120: 6e 67 6c 65 20 61 72 67 75 6d 65 6e 74 2e 20 20  ngle argument.  
3130: 4e 6f 20 65 78 74 72 61 20 77 68 69 74 65 73 70  No extra whitesp
3140: 61 63 65 20 61 6e 64 20 6e 6f 20 74 72 61 69 6c  ace and no trail
3150: 69 6e 67 20 6f 72 20 6c 65 61 64 69 6e 67 0a 77  ing or leading.w
3160: 68 69 74 65 73 70 61 63 65 20 69 73 20 61 6c 6c  hitespace is all
3170: 6f 77 65 64 2e 20 20 41 6c 6c 20 63 61 72 64 73  owed.  All cards
3180: 20 69 6e 20 74 68 65 20 63 6c 75 73 74 65 72 20   in the cluster 
3190: 6d 75 73 74 20 6f 63 63 75 72 20 69 6e 0a 73 74  must occur in.st
31a0: 72 69 63 74 20 6c 65 78 69 63 6f 67 72 61 70 68  rict lexicograph
31b0: 69 63 61 6c 20 6f 72 64 65 72 2e 3c 2f 70 3e 0a  ical order.</p>.
31c0: 0a 3c 70 3e 41 20 63 6c 75 73 74 65 72 20 63 6f  .<p>A cluster co
31d0: 6e 73 69 73 74 73 20 6f 66 20 6f 6e 65 20 6f 72  nsists of one or
31e0: 20 6d 6f 72 65 20 22 4d 22 20 63 61 72 64 73 20   more "M" cards 
31f0: 66 6f 6c 6c 6f 77 65 64 20 62 79 20 61 20 73 69  followed by a si
3200: 6e 67 6c 65 0a 22 5a 22 20 63 61 72 64 2e 20 20  ngle."Z" card.  
3210: 45 61 63 68 20 4d 20 63 61 72 64 20 68 6f 6c 64  Each M card hold
3220: 73 20 61 6e 20 61 72 67 75 6d 65 6e 74 20 77 68  s an argument wh
3230: 69 63 68 20 69 73 20 61 20 55 55 49 44 20 66 6f  ich is a UUID fo
3240: 72 20 61 20 66 69 6c 65 0a 69 6e 20 74 68 65 20  r a file.in the 
3250: 72 65 70 6f 73 69 74 6f 72 79 2e 20 20 54 68 65  repository.  The
3260: 20 5a 20 63 61 72 64 20 68 61 73 20 61 20 73 69   Z card has a si
3270: 6e 67 6c 65 20 61 72 67 75 6d 65 6e 74 20 77 68  ngle argument wh
3280: 69 63 68 20 69 73 20 74 68 65 0a 6c 6f 77 65 72  ich is the.lower
3290: 2d 63 61 73 65 20 68 65 78 61 64 65 63 69 6d 61  -case hexadecima
32a0: 6c 20 72 65 70 72 65 73 65 6e 74 61 74 69 6f 6e  l representation
32b0: 20 6f 66 20 74 68 65 20 4d 44 35 20 63 68 65 63   of the MD5 chec
32c0: 6b 73 75 6d 20 6f 66 20 61 6c 6c 0a 70 72 65 63  ksum of all.prec
32d0: 65 64 69 6e 67 20 4d 20 63 61 72 64 73 20 75 70  eding M cards up
32e0: 20 74 6f 20 61 6e 64 20 69 6e 63 6c 75 64 65 64   to and included
32f0: 20 74 68 65 20 6e 65 77 6c 69 6e 65 20 63 68 61   the newline cha
3300: 72 61 63 74 65 72 20 74 68 61 74 0a 6f 63 63 75  racter that.occu
3310: 72 72 65 64 20 6a 75 73 74 20 62 65 66 6f 72 65  rred just before
3320: 20 74 68 65 20 5a 20 74 68 61 74 20 73 74 61 72   the Z that star
3330: 74 73 20 74 68 65 20 5a 20 63 61 72 64 2e 3c 2f  ts the Z card.</
3340: 70 3e 0a 0a 3c 70 3e 41 6e 79 20 66 69 6c 65 20  p>..<p>Any file 
3350: 74 68 61 74 20 64 6f 65 73 20 6e 6f 74 20 6d 61  that does not ma
3360: 74 63 68 20 74 68 65 20 73 70 65 63 69 66 69 63  tch the specific
3370: 61 74 69 6f 6e 73 20 6f 66 20 61 20 63 6c 75 73  ations of a clus
3380: 74 65 72 0a 65 78 61 63 74 6c 79 20 69 73 20 6e  ter.exactly is n
3390: 6f 74 20 61 20 63 6c 75 73 74 65 72 2e 20 20 54  ot a cluster.  T
33a0: 68 65 72 65 20 6d 75 73 74 20 62 65 20 6e 6f 20  here must be no 
33b0: 65 78 74 72 61 20 77 68 69 74 65 73 70 61 63 65  extra whitespace
33c0: 20 69 6e 0a 74 68 65 20 66 69 6c 65 2e 20 20 54   in.the file.  T
33d0: 68 65 72 65 20 6d 75 73 74 20 62 65 20 6f 6e 65  here must be one
33e0: 20 6f 72 20 6d 6f 72 65 20 4d 20 63 61 72 64 73   or more M cards
33f0: 2e 20 20 54 68 65 72 65 20 6d 75 73 74 20 62 65  .  There must be
3400: 20 61 0a 73 69 6e 67 6c 65 20 5a 20 63 61 72 64   a.single Z card
3410: 20 77 69 74 68 20 61 20 63 6f 72 72 65 63 74 20   with a correct 
3420: 4d 44 35 20 63 68 65 63 6b 73 75 6d 2e 20 20 41  MD5 checksum.  A
3430: 6e 64 20 61 6c 6c 20 63 61 72 64 73 20 6d 75 73  nd all cards mus
3440: 74 0a 62 65 20 69 6e 20 73 74 72 69 63 74 20 6c  t.be in strict l
3450: 65 78 69 63 6f 67 72 61 70 68 69 63 61 6c 20 6f  exicographical o
3460: 72 64 65 72 2e 3c 2f 70 3e 0a 0a 3c 68 33 3e 34  rder.</p>..<h3>4
3470: 2e 31 20 54 68 65 20 55 6e 63 6c 75 73 74 65 72  .1 The Uncluster
3480: 65 64 20 54 61 62 6c 65 3c 2f 68 33 3e 0a 0a 3c  ed Table</h3>..<
3490: 70 3e 45 76 65 72 79 20 72 65 70 6f 73 69 74 6f  p>Every reposito
34a0: 72 79 20 6d 61 69 6e 74 61 69 6e 73 20 61 20 74  ry maintains a t
34b0: 61 62 6c 65 20 6e 61 6d 65 64 20 22 3c 62 3e 75  able named "<b>u
34c0: 6e 63 6c 75 73 74 65 72 65 64 3c 2f 62 3e 22 0a  nclustered</b>".
34d0: 77 68 69 63 68 20 72 65 63 6f 72 64 73 20 74 68  which records th
34e0: 65 20 69 64 65 6e 74 69 74 79 20 6f 66 20 65 76  e identity of ev
34f0: 65 72 79 20 66 69 6c 65 20 61 6e 64 20 70 68 61  ery file and pha
3500: 6e 74 6f 6d 20 69 74 20 68 6f 6c 64 73 20 74 68  ntom it holds th
3510: 61 74 20 69 73 20 6e 6f 74 0a 6d 65 6e 74 69 6f  at is not.mentio
3520: 6e 65 64 20 69 6e 20 61 20 63 6c 75 73 74 65 72  ned in a cluster
3530: 2e 20 20 54 68 65 20 65 6e 74 72 69 65 73 20 69  .  The entries i
3540: 6e 20 74 68 65 20 75 6e 63 6c 75 73 74 65 72 65  n the unclustere
3550: 64 20 74 61 62 6c 65 20 63 61 6e 0a 62 65 20 74  d table can.be t
3560: 68 6f 75 67 68 74 20 6f 66 20 61 73 20 6c 65 61  hought of as lea
3570: 76 65 73 20 6f 6e 20 61 20 74 72 65 65 20 6f 66  ves on a tree of
3580: 20 66 69 6c 65 73 2e 20 20 53 6f 6d 65 20 6f 66   files.  Some of
3590: 20 74 68 65 20 75 6e 63 6c 75 73 74 65 72 65 64   the unclustered
35a0: 0a 66 69 6c 65 73 20 77 69 6c 6c 20 62 65 20 63  .files will be c
35b0: 6c 75 73 74 65 72 73 2e 20 20 54 68 6f 73 65 20  lusters.  Those 
35c0: 63 6c 75 73 74 65 72 73 20 6d 61 79 20 63 6f 6e  clusters may con
35d0: 74 61 69 6e 20 6f 74 68 65 72 20 63 6c 75 73 74  tain other clust
35e0: 65 72 73 2c 0a 77 68 69 63 68 20 6d 69 67 68 74  ers,.which might
35f0: 20 63 6f 6e 74 61 69 6e 20 73 74 69 6c 6c 20 6d   contain still m
3600: 6f 72 65 20 63 6c 75 73 74 65 72 73 2c 20 61 6e  ore clusters, an
3610: 64 20 73 6f 20 66 6f 72 74 68 2e 20 20 42 65 67  d so forth.  Beg
3620: 69 6e 6e 69 6e 67 0a 77 69 74 68 20 74 68 65 20  inning.with the 
3630: 66 69 6c 65 73 20 69 6e 20 74 68 65 20 75 6e 63  files in the unc
3640: 6c 75 73 74 65 72 65 64 20 74 61 62 6c 65 2c 20  lustered table, 
3650: 6f 6e 65 20 63 61 6e 20 66 6f 6c 6c 6f 77 20 74  one can follow t
3660: 68 65 20 63 68 61 69 6e 0a 6f 66 20 63 6c 75 73  he chain.of clus
3670: 74 65 72 73 20 74 6f 20 66 69 6e 64 20 65 76 65  ters to find eve
3680: 72 79 20 66 69 6c 65 20 69 6e 20 74 68 65 20 72  ry file in the r
3690: 65 70 6f 73 69 74 6f 72 79 2e 3c 2f 70 3e 0a 0a  epository.</p>..
36a0: 3c 68 32 3e 35 2e 30 20 53 79 6e 63 68 72 6f 6e  <h2>5.0 Synchron
36b0: 69 7a 61 74 69 6f 6e 20 53 74 72 61 74 65 67 69  ization Strategi
36c0: 65 73 3c 2f 68 32 3e 0a 0a 3c 68 33 3e 35 2e 31  es</h2>..<h3>5.1
36d0: 20 50 75 6c 6c 3c 2f 68 33 3e 0a 0a 3c 70 3e 41   Pull</h3>..<p>A
36e0: 20 74 79 70 69 63 61 6c 20 70 75 6c 6c 20 6f 70   typical pull op
36f0: 65 72 61 74 69 6f 6e 20 70 72 6f 63 65 65 64 73  eration proceeds
3700: 20 61 73 20 73 68 6f 77 6e 20 62 65 6c 6f 77 2e   as shown below.
3710: 20 20 44 65 74 61 69 6c 73 0a 6f 66 20 74 68 65    Details.of the
3720: 20 61 63 74 75 61 6c 20 69 6d 70 6c 65 6d 65 6e   actual implemen
3730: 74 61 74 69 6f 6e 20 6d 61 79 20 76 65 72 79 20  tation may very 
3740: 73 6c 69 67 68 74 6c 79 20 62 75 74 20 74 68 65  slightly but the
3750: 20 67 69 73 74 20 6f 66 0a 61 20 70 75 6c 6c 20   gist of.a pull 
3760: 69 73 20 63 61 70 74 75 72 65 64 20 69 6e 20 74  is captured in t
3770: 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 73 74 65  he following ste
3780: 70 73 3a 3c 2f 70 3e 0a 0a 3c 6f 6c 3e 0a 3c 6c  ps:</p>..<ol>.<l
3790: 69 3e 54 68 65 20 63 6c 69 65 6e 74 20 73 65 6e  i>The client sen
37a0: 64 73 20 6c 6f 67 69 6e 20 61 6e 64 20 70 75 6c  ds login and pul
37b0: 6c 20 63 61 72 64 73 2e 0a 3c 6c 69 3e 54 68 65  l cards..<li>The
37c0: 20 63 6c 69 65 6e 74 20 73 65 6e 64 73 20 61 20   client sends a 
37d0: 63 6f 6f 6b 69 65 20 63 61 72 64 20 69 66 20 69  cookie card if i
37e0: 74 20 68 61 73 20 70 72 65 76 69 6f 75 73 6c 79  t has previously
37f0: 20 72 65 63 65 69 76 65 64 20 61 20 63 6f 6f 6b   received a cook
3800: 69 65 2e 0a 3c 6c 69 3e 54 68 65 20 63 6c 69 65  ie..<li>The clie
3810: 6e 74 20 73 65 6e 64 73 20 67 69 6d 6d 65 20 63  nt sends gimme c
3820: 61 72 64 73 20 66 6f 72 20 65 76 65 72 79 20 70  ards for every p
3830: 68 61 6e 74 6f 6d 20 74 68 61 74 20 69 74 20 68  hantom that it h
3840: 6f 6c 64 73 2e 0a 3c 68 72 3e 0a 3c 6c 69 3e 54  olds..<hr>.<li>T
3850: 68 65 20 73 65 72 76 65 72 20 63 68 65 63 6b 73  he server checks
3860: 20 74 68 65 20 6c 6f 67 69 6e 20 70 61 73 73 77   the login passw
3870: 6f 72 64 20 61 6e 64 20 72 65 6a 65 63 74 73 20  ord and rejects 
3880: 74 68 65 20 73 65 73 73 69 6f 6e 20 69 66 0a 74  the session if.t
3890: 68 65 20 75 73 65 72 20 64 6f 65 73 20 6e 6f 74  he user does not
38a0: 20 68 61 76 65 20 70 65 72 6d 69 73 73 69 6f 6e   have permission
38b0: 20 74 6f 20 70 75 6c 6c 2e 0a 3c 6c 69 3e 49 66   to pull..<li>If
38c0: 20 74 68 65 20 6e 75 6d 62 65 72 20 65 6e 74 72   the number entr
38d0: 69 65 73 20 69 6e 20 74 68 65 20 75 6e 63 6c 75  ies in the unclu
38e0: 73 74 65 72 65 64 20 74 61 62 6c 65 20 6f 6e 20  stered table on 
38f0: 74 68 65 20 73 65 72 76 65 72 20 69 73 0a 67 72  the server is.gr
3900: 65 61 74 65 72 20 74 68 61 6e 20 31 30 30 2c 20  eater than 100, 
3910: 74 68 65 6e 20 74 68 65 20 73 65 72 76 65 72 20  then the server 
3920: 63 6f 6e 73 74 72 75 63 74 73 20 61 20 6e 65 77  constructs a new
3930: 20 63 6c 75 73 74 65 72 20 66 69 6c 65 20 74 6f   cluster file to
3940: 0a 63 6f 76 65 72 20 61 6c 6c 20 74 68 6f 73 65  .cover all those
3950: 20 75 6e 63 6c 75 73 74 65 72 65 64 20 65 6e 74   unclustered ent
3960: 72 69 65 73 2e 0a 3c 6c 69 3e 54 68 65 20 73 65  ries..<li>The se
3970: 72 76 65 72 20 73 65 6e 64 73 20 66 69 6c 65 20  rver sends file 
3980: 63 61 72 64 73 20 66 6f 72 20 65 76 65 72 79 20  cards for every 
3990: 67 69 6d 6d 65 20 63 61 72 64 20 69 74 20 72 65  gimme card it re
39a0: 63 65 69 76 65 64 0a 66 72 6f 6d 20 74 68 65 20  ceived.from the 
39b0: 63 6c 69 65 6e 74 2e 0a 3c 6c 69 3e 54 68 65 20  client..<li>The 
39c0: 73 65 72 76 65 72 20 73 65 6e 64 73 20 69 68 61  server sends iha
39d0: 76 65 20 63 61 72 64 73 20 66 6f 72 20 65 76 65  ve cards for eve
39e0: 72 79 20 66 69 6c 65 20 69 6e 20 69 74 73 20 75  ry file in its u
39f0: 6e 63 6c 75 73 74 65 72 65 64 0a 74 61 62 6c 65  nclustered.table
3a00: 20 74 68 61 74 20 69 73 20 6e 6f 74 20 61 20 70   that is not a p
3a10: 68 61 6e 74 6f 6d 2e 0a 3c 68 72 3e 0a 3c 6c 69  hantom..<hr>.<li
3a20: 3e 54 68 65 20 63 6c 69 65 6e 74 20 61 64 64 73  >The client adds
3a30: 20 74 68 65 20 63 6f 6e 74 65 6e 74 20 6f 66 20   the content of 
3a40: 66 69 6c 65 20 63 61 72 64 73 20 74 6f 20 69 74  file cards to it
3a50: 73 20 72 65 70 6f 73 69 74 6f 72 79 2e 0a 3c 6c  s repository..<l
3a60: 69 3e 54 68 65 20 63 6c 69 65 6e 74 20 63 72 65  i>The client cre
3a70: 61 74 65 73 20 61 20 70 68 61 6e 74 6f 6d 20 66  ates a phantom f
3a80: 6f 72 20 65 76 65 72 79 20 69 68 61 76 65 20 63  or every ihave c
3a90: 61 72 64 20 69 6e 20 74 68 65 20 73 65 72 76 65  ard in the serve
3aa0: 72 20 72 65 70 6c 79 0a 74 68 61 74 20 6d 65 6e  r reply.that men
3ab0: 74 69 6f 6e 73 20 61 20 66 69 6c 65 20 74 68 61  tions a file tha
3ac0: 74 20 74 68 65 20 63 6c 69 65 6e 74 20 64 6f 65  t the client doe
3ad0: 73 20 6e 6f 74 20 70 6f 73 73 65 73 73 2e 0a 3c  s not possess..<
3ae0: 6c 69 3e 54 68 65 20 63 6c 69 65 6e 74 20 63 72  li>The client cr
3af0: 65 61 74 65 73 20 61 20 70 68 61 6e 74 6f 6d 20  eates a phantom 
3b00: 66 6f 72 20 74 68 65 20 64 65 6c 74 61 20 73 6f  for the delta so
3b10: 75 72 63 65 20 6f 66 20 66 69 6c 65 20 63 61 72  urce of file car
3b20: 64 73 20 77 68 65 6e 0a 74 68 65 20 64 65 6c 74  ds when.the delt
3b30: 61 20 73 6f 75 72 63 65 20 69 73 20 61 20 66 69  a source is a fi
3b40: 6c 65 20 74 68 61 74 20 74 68 65 20 63 6c 69 65  le that the clie
3b50: 6e 74 20 64 6f 65 73 20 6e 6f 74 20 70 6f 73 73  nt does not poss
3b60: 65 73 73 2e 0a 3c 2f 6f 6c 3e 0a 0a 3c 70 3e 54  ess..</ol>..<p>T
3b70: 68 65 73 65 20 74 65 6e 20 73 74 65 70 73 20 72  hese ten steps r
3b80: 65 70 72 65 73 65 6e 74 20 61 20 73 69 6e 67 6c  epresent a singl
3b90: 65 20 48 54 54 50 20 72 6f 75 6e 64 2d 74 72 69  e HTTP round-tri
3ba0: 70 20 72 65 71 75 65 73 74 2e 0a 54 68 65 20 66  p request..The f
3bb0: 69 72 73 74 20 74 68 72 65 65 20 73 74 65 70 73  irst three steps
3bc0: 20 61 72 65 20 74 68 65 20 70 72 6f 63 65 73 73   are the process
3bd0: 69 6e 67 20 74 68 61 74 20 6f 63 63 75 72 73 20  ing that occurs 
3be0: 6f 6e 20 74 68 65 20 63 6c 69 65 6e 74 0a 74 6f  on the client.to
3bf0: 20 67 65 6e 65 72 61 74 65 20 74 68 65 20 72 65   generate the re
3c00: 71 75 65 73 74 2e 20 20 54 68 65 20 6d 69 64 64  quest.  The midd
3c10: 6c 65 20 66 6f 75 72 20 73 74 65 70 73 20 61 72  le four steps ar
3c20: 65 20 70 72 6f 63 65 73 73 69 6e 67 0a 74 68 61  e processing.tha
3c30: 74 20 6f 63 63 75 72 73 20 6f 6e 20 74 68 65 20  t occurs on the 
3c40: 73 65 72 76 65 72 20 74 6f 20 69 6e 74 65 72 70  server to interp
3c50: 72 65 74 20 74 68 65 20 72 65 71 75 65 73 74 20  ret the request 
3c60: 61 6e 64 20 67 65 6e 65 72 61 74 65 20 61 0a 72  and generate a.r
3c70: 65 70 6c 79 2e 20 20 41 6e 64 20 74 68 65 20 6c  eply.  And the l
3c80: 61 73 74 20 74 68 72 65 65 20 73 74 65 70 73 20  ast three steps 
3c90: 61 72 65 20 74 68 65 20 70 72 6f 63 65 73 73 69  are the processi
3ca0: 6e 67 20 74 68 61 74 20 74 68 65 0a 63 6c 69 65  ng that the.clie
3cb0: 6e 74 20 64 6f 65 73 20 74 6f 20 69 6e 74 65 72  nt does to inter
3cc0: 70 72 65 74 20 74 68 65 20 72 65 70 6c 79 2e 3c  pret the reply.<
3cd0: 2f 70 3e 0a 0a 3c 70 3e 44 75 72 69 6e 67 20 61  /p>..<p>During a
3ce0: 20 70 75 6c 6c 2c 20 74 68 65 20 63 6c 69 65 6e   pull, the clien
3cf0: 74 20 77 69 6c 6c 20 6b 65 65 70 20 73 65 6e 64  t will keep send
3d00: 69 6e 67 20 48 54 54 50 20 72 65 71 75 65 73 74  ing HTTP request
3d10: 73 0a 75 6e 74 69 6c 20 69 74 20 68 6f 6c 64 73  s.until it holds
3d20: 20 61 6c 6c 20 66 69 6c 65 73 20 74 68 61 74 20   all files that 
3d30: 65 78 69 73 74 20 6f 6e 20 74 68 65 20 73 65 72  exist on the ser
3d40: 76 65 72 2e 3c 2f 70 3e 0a 0a 3c 70 3e 4e 6f 74  ver.</p>..<p>Not
3d50: 65 20 74 68 61 74 20 74 68 65 20 73 65 72 76 65  e that the serve
3d60: 72 20 74 72 69 65 73 0a 74 6f 20 6c 69 6d 69 74  r tries.to limit
3d70: 20 74 68 65 20 73 69 7a 65 20 6f 66 20 69 74 73   the size of its
3d80: 20 72 65 70 6c 79 20 6d 65 73 73 61 67 65 20 74   reply message t
3d90: 6f 20 73 6f 6d 65 74 68 69 6e 67 20 72 65 61 73  o something reas
3da0: 6f 6e 61 62 6c 65 0a 28 75 73 75 61 6c 6c 79 20  onable.(usually 
3db0: 61 62 6f 75 74 20 31 4d 42 29 20 73 6f 20 74 68  about 1MB) so th
3dc0: 61 74 20 69 74 20 6d 69 67 68 74 20 73 74 6f 70  at it might stop
3dd0: 20 73 65 6e 64 69 6e 67 20 66 69 6c 65 20 63 61   sending file ca
3de0: 72 64 73 20 61 73 0a 64 65 73 63 72 69 62 65 64  rds as.described
3df0: 20 69 6e 20 73 74 65 70 20 28 36 29 20 69 66 20   in step (6) if 
3e00: 74 68 65 20 72 65 70 6c 79 20 62 65 63 6f 6d 65  the reply become
3e10: 73 20 74 6f 6f 20 6c 61 72 67 65 2e 3c 2f 70 3e  s too large.</p>
3e20: 0a 0a 3c 70 3e 53 74 65 70 20 28 35 29 20 69 73  ..<p>Step (5) is
3e30: 20 74 68 65 20 6f 6e 6c 79 20 77 61 79 20 69 6e   the only way in
3e40: 20 77 68 69 63 68 20 6e 65 77 20 63 6c 75 73 74   which new clust
3e50: 65 72 73 20 63 61 6e 20 62 65 20 63 72 65 61 74  ers can be creat
3e60: 65 64 2e 0a 42 79 20 6f 6e 6c 79 20 63 72 65 61  ed..By only crea
3e70: 74 69 6e 67 20 63 6c 75 73 74 65 72 73 20 6f 6e  ting clusters on
3e80: 20 74 68 65 20 73 65 72 76 65 72 2c 20 77 65 20   the server, we 
3e90: 68 6f 70 65 20 74 6f 20 6d 69 6e 69 6d 69 7a 65  hope to minimize
3ea0: 20 74 68 65 0a 61 6d 6f 75 6e 74 20 6f 66 20 6f   the.amount of o
3eb0: 76 65 72 6c 61 70 20 62 65 74 77 65 65 6e 20 63  verlap between c
3ec0: 6c 75 73 74 65 72 73 20 69 6e 20 74 68 65 20 63  lusters in the c
3ed0: 6f 6d 6d 6f 6e 20 63 6f 6e 66 69 67 75 72 61 74  ommon configurat
3ee0: 69 6f 6e 20 77 68 65 72 65 0a 74 68 65 72 65 20  ion where.there 
3ef0: 69 73 20 61 20 73 69 6e 67 6c 65 20 73 65 72 76  is a single serv
3f00: 65 72 20 61 6e 64 20 6d 61 6e 79 20 63 6c 69 65  er and many clie
3f10: 6e 74 73 2e 20 20 54 68 65 20 73 61 6d 65 20 73  nts.  The same s
3f20: 79 6e 63 68 72 6f 6e 69 7a 61 74 69 6f 6e 0a 70  ynchronization.p
3f30: 72 6f 74 6f 63 6f 6c 20 77 69 6c 6c 20 63 6f 6e  rotocol will con
3f40: 74 69 6e 75 65 20 74 6f 20 77 6f 72 6b 20 65 76  tinue to work ev
3f50: 65 6e 20 69 66 20 74 68 65 72 65 20 61 72 65 20  en if there are 
3f60: 6d 75 6c 74 69 70 6c 65 20 73 65 72 76 65 72 73  multiple servers
3f70: 0a 6f 72 20 69 66 20 73 65 72 76 65 72 73 20 61  .or if servers a
3f80: 6e 64 20 63 6c 69 65 6e 74 73 20 73 6f 6d 65 74  nd clients somet
3f90: 69 6d 65 73 20 63 68 61 6e 67 65 20 72 6f 6c 65  imes change role
3fa0: 73 2e 20 20 54 68 65 20 6f 6e 6c 79 20 6e 65 67  s.  The only neg
3fb0: 61 74 69 76 65 0a 65 66 66 65 63 74 73 20 6f 66  ative.effects of
3fc0: 20 74 68 65 73 65 20 75 6e 75 73 75 61 6c 20 61   these unusual a
3fd0: 72 72 61 6e 67 65 6d 65 6e 74 73 20 69 73 20 74  rrangements is t
3fe0: 68 61 74 20 6d 6f 72 65 20 74 68 61 6e 20 74 68  hat more than th
3ff0: 65 20 6d 69 6e 69 6d 75 6d 0a 6e 75 6d 62 65 72  e minimum.number
4000: 20 6f 66 20 63 6c 75 73 74 65 72 73 20 6d 69 67   of clusters mig
4010: 68 74 20 62 65 20 67 65 6e 65 72 61 74 65 64 2e  ht be generated.
4020: 3c 2f 70 3e 0a 0a 3c 68 33 3e 35 2e 32 20 50 75  </p>..<h3>5.2 Pu
4030: 73 68 3c 2f 68 33 3e 0a 0a 3c 70 3e 41 20 74 79  sh</h3>..<p>A ty
4040: 70 69 63 61 6c 20 70 75 73 68 20 6f 70 65 72 61  pical push opera
4050: 74 69 6f 6e 20 70 72 6f 63 65 65 64 73 20 72 6f  tion proceeds ro
4060: 75 67 68 6c 79 20 61 73 20 73 68 6f 77 6e 20 62  ughly as shown b
4070: 65 6c 6f 77 2e 20 20 41 73 0a 77 69 74 68 20 61  elow.  As.with a
4080: 20 70 75 6c 6c 2c 20 74 68 65 20 61 63 74 75 61   pull, the actua
4090: 6c 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e  l implementation
40a0: 20 6d 61 79 20 76 61 72 79 20 73 6c 69 67 68 74   may vary slight
40b0: 6c 79 2e 3c 2f 70 3e 0a 0a 3c 6f 6c 3e 0a 3c 6c  ly.</p>..<ol>.<l
40c0: 69 3e 54 68 65 20 63 6c 69 65 6e 74 20 73 65 6e  i>The client sen
40d0: 64 73 20 6c 6f 67 69 6e 20 61 6e 64 20 70 75 73  ds login and pus
40e0: 68 20 63 61 72 64 73 2e 0a 3c 6c 69 3e 54 68 65  h cards..<li>The
40f0: 20 63 6c 69 65 6e 74 20 73 65 6e 64 73 20 66 69   client sends fi
4100: 6c 65 20 63 61 72 64 73 20 66 6f 72 20 61 6e 79  le cards for any
4110: 20 66 69 6c 65 73 20 74 68 61 74 20 69 74 20 68   files that it h
4120: 6f 6c 64 73 20 74 68 61 74 20 68 61 76 65 0a 6e  olds that have.n
4130: 65 76 65 72 20 62 65 66 6f 72 65 20 62 65 65 6e  ever before been
4140: 20 70 75 73 68 65 64 20 2d 20 66 69 6c 65 73 20   pushed - files 
4150: 74 68 61 74 20 63 6f 6d 65 20 66 72 6f 6d 20 6c  that come from l
4160: 6f 63 61 6c 20 63 68 65 63 6b 2d 69 6e 73 2e 0a  ocal check-ins..
4170: 3c 6c 69 3e 49 66 20 74 68 69 73 20 69 73 20 74  <li>If this is t
4180: 68 65 20 73 65 63 6f 6e 64 20 6f 72 20 6c 61 74  he second or lat
4190: 65 72 20 63 79 63 6c 65 20 69 6e 20 61 20 70 75  er cycle in a pu
41a0: 73 68 2c 20 74 68 65 6e 20 74 68 65 0a 63 6c 69  sh, then the.cli
41b0: 65 6e 74 20 73 65 6e 64 73 20 66 69 6c 65 20 63  ent sends file c
41c0: 61 72 64 73 20 66 6f 72 20 61 6e 79 20 67 69 6d  ards for any gim
41d0: 6d 65 20 63 61 72 64 73 20 74 68 61 74 20 74 68  me cards that th
41e0: 65 20 73 65 72 76 65 72 20 73 65 6e 74 0a 69 6e  e server sent.in
41f0: 20 74 68 65 20 70 72 65 76 69 6f 75 73 20 63 79   the previous cy
4200: 63 6c 65 2e 0a 3c 6c 69 3e 54 68 65 20 63 6c 69  cle..<li>The cli
4210: 65 6e 74 20 73 65 6e 64 73 20 69 67 6f 74 20 63  ent sends igot c
4220: 61 72 64 73 20 66 6f 72 20 65 76 65 72 79 20 66  ards for every f
4230: 69 6c 65 20 69 6e 20 69 74 73 20 75 6e 63 6c 75  ile in its unclu
4240: 73 74 65 72 65 64 20 74 61 62 6c 65 0a 74 68 61  stered table.tha
4250: 74 20 69 73 20 6e 6f 74 20 61 20 70 68 61 6e 74  t is not a phant
4260: 6f 6d 2e 0a 3c 68 72 3e 0a 3c 6c 69 3e 54 68 65  om..<hr>.<li>The
4270: 20 73 65 72 76 65 72 20 63 68 65 63 6b 73 20 74   server checks t
4280: 68 65 20 6c 6f 67 69 6e 20 61 6e 64 20 70 75 73  he login and pus
4290: 68 20 63 61 72 64 73 20 61 6e 64 20 69 73 73 75  h cards and issu
42a0: 65 73 20 61 6e 20 65 72 72 6f 72 20 69 66 0a 61  es an error if.a
42b0: 6e 79 74 68 69 6e 67 20 69 73 20 61 6d 69 73 73  nything is amiss
42c0: 2e 0a 3c 6c 69 3e 54 68 65 20 73 65 72 76 65 72  ..<li>The server
42d0: 20 61 63 63 65 70 74 73 20 66 69 6c 65 20 63 61   accepts file ca
42e0: 72 64 73 20 66 72 6f 6d 20 74 68 65 20 63 6c 69  rds from the cli
42f0: 65 6e 74 20 61 6e 64 20 61 64 64 73 20 74 68 6f  ent and adds tho
4300: 73 65 20 66 69 6c 65 73 0a 74 6f 20 69 74 73 20  se files.to its 
4310: 72 65 70 6f 73 69 74 6f 72 79 2e 0a 3c 6c 69 3e  repository..<li>
4320: 54 68 65 20 73 65 72 76 65 72 20 63 72 65 61 74  The server creat
4330: 65 73 20 70 68 61 6e 74 6f 6d 73 20 66 6f 72 20  es phantoms for 
4340: 69 67 6f 74 20 63 61 72 64 73 20 74 68 61 74 20  igot cards that 
4350: 6d 65 6e 74 69 6f 6e 20 66 69 6c 65 73 20 69 74  mention files it
4360: 0a 64 6f 65 73 20 6e 6f 74 20 70 6f 73 73 65 73  .does not posses
4370: 73 20 6f 72 20 66 6f 72 20 66 69 6c 65 20 63 61  s or for file ca
4380: 72 64 73 20 74 68 61 74 20 6d 65 6e 74 69 6f 6e  rds that mention
4390: 20 64 65 6c 74 61 20 73 6f 75 72 63 65 20 66 69   delta source fi
43a0: 6c 65 73 20 74 68 61 74 0a 69 74 20 64 6f 65 73  les that.it does
43b0: 20 6e 6f 74 20 70 6f 73 73 65 73 73 2e 0a 3c 6c   not possess..<l
43c0: 69 3e 54 68 65 20 73 65 72 76 65 72 20 69 73 73  i>The server iss
43d0: 75 65 73 20 67 69 6d 6d 65 20 63 61 72 64 73 20  ues gimme cards 
43e0: 66 6f 72 20 61 6c 6c 20 70 68 61 6e 74 6f 6d 73  for all phantoms
43f0: 2e 0a 3c 68 72 3e 0a 3c 6c 69 3e 54 68 65 20 63  ..<hr>.<li>The c
4400: 6c 69 65 6e 74 20 72 65 6d 65 6d 62 65 72 73 20  lient remembers 
4410: 74 68 65 20 67 69 6d 6d 65 20 63 61 72 64 73 20  the gimme cards 
4420: 66 72 6f 6d 20 74 68 65 20 73 65 72 76 65 72 20  from the server 
4430: 73 6f 20 74 68 61 74 20 69 74 0a 63 61 6e 20 67  so that it.can g
4440: 65 6e 65 72 61 74 65 20 66 69 6c 65 20 63 61 72  enerate file car
4450: 64 73 20 69 6e 20 72 65 70 6c 79 20 6f 6e 20 74  ds in reply on t
4460: 68 65 20 6e 65 78 74 20 63 79 63 6c 65 2e 0a 3c  he next cycle..<
4470: 2f 6f 6c 3e 0a 0a 3c 70 3e 41 73 20 77 69 74 68  /ol>..<p>As with
4480: 20 61 20 70 75 6c 6c 2c 20 74 68 65 20 73 74 65   a pull, the ste
4490: 70 73 20 6f 66 20 61 20 70 75 73 68 20 6f 70 65  ps of a push ope
44a0: 72 61 74 69 6f 6e 20 72 65 70 65 61 74 20 75 6e  ration repeat un
44b0: 74 69 6c 20 74 68 65 0a 73 65 72 76 65 72 20 6b  til the.server k
44c0: 6e 6f 77 73 20 61 6c 6c 20 66 69 6c 65 73 20 74  nows all files t
44d0: 68 61 74 20 65 78 69 73 74 20 6f 6e 20 74 68 65  hat exist on the
44e0: 20 63 6c 69 65 6e 74 2e 20 20 41 6c 73 6f 2c 20   client.  Also, 
44f0: 61 73 20 77 69 74 68 0a 70 75 6c 6c 2c 20 74 68  as with.pull, th
4500: 65 20 63 6c 69 65 6e 74 20 61 74 74 65 6d 70 74  e client attempt
4510: 73 20 74 6f 20 6b 65 65 70 20 74 68 65 20 73 69  s to keep the si
4520: 7a 65 20 6f 66 20 74 68 65 20 72 65 71 75 65 73  ze of the reques
4530: 74 20 66 72 6f 6d 0a 67 72 6f 77 69 6e 67 20 74  t from.growing t
4540: 6f 6f 20 6c 61 72 67 65 20 62 79 20 73 75 70 70  oo large by supp
4550: 72 65 73 73 69 6e 67 20 66 69 6c 65 20 63 61 72  ressing file car
4560: 64 73 20 6f 6e 63 65 20 74 68 65 0a 73 69 7a 65  ds once the.size
4570: 20 6f 66 20 74 68 65 20 72 65 71 75 65 73 74 20   of the request 
4580: 72 65 61 63 68 65 73 20 31 4d 42 2e 3c 2f 70 3e  reaches 1MB.</p>
4590: 0a 0a 3c 68 33 3e 35 2e 33 20 53 79 6e 63 3c 2f  ..<h3>5.3 Sync</
45a0: 68 33 3e 0a 0a 3c 70 3e 41 20 73 79 6e 63 20 69  h3>..<p>A sync i
45b0: 73 20 6a 75 73 74 20 61 20 70 75 6c 6c 20 61 6e  s just a pull an
45c0: 64 20 61 20 70 75 73 68 20 74 68 61 74 20 68 61  d a push that ha
45d0: 70 70 65 6e 20 61 74 20 74 68 65 20 73 61 6d 65  ppen at the same
45e0: 20 74 69 6d 65 2e 0a 54 68 65 20 66 69 72 73 74   time..The first
45f0: 20 74 68 72 65 65 20 73 74 65 70 73 20 6f 66 20   three steps of 
4600: 61 20 70 75 6c 6c 20 61 72 65 20 63 6f 6d 62 69  a pull are combi
4610: 6e 65 64 20 77 69 74 68 20 74 68 65 20 66 69 72  ned with the fir
4620: 73 74 20 66 69 76 65 20 73 74 65 70 73 0a 6f 66  st five steps.of
4630: 20 61 20 70 75 73 68 2e 20 20 53 74 65 70 73 20   a push.  Steps 
4640: 28 34 29 20 74 68 72 6f 75 67 68 20 28 37 29 20  (4) through (7) 
4650: 6f 66 20 61 20 70 75 6c 6c 20 61 72 65 20 63 6f  of a pull are co
4660: 6d 62 69 6e 65 64 20 77 69 74 68 20 73 74 65 70  mbined with step
4670: 73 0a 28 35 29 20 74 68 72 6f 75 67 68 20 28 38  s.(5) through (8
4680: 29 20 6f 66 20 61 20 70 75 73 68 2e 20 20 41 6e  ) of a push.  An
4690: 64 20 73 74 65 70 73 20 28 38 29 20 74 68 72 6f  d steps (8) thro
46a0: 75 67 68 20 28 31 30 29 20 6f 66 20 61 20 70 75  ugh (10) of a pu
46b0: 6c 6c 0a 61 72 65 20 63 6f 6d 62 69 6e 65 64 20  ll.are combined 
46c0: 77 69 74 68 20 73 74 65 70 20 28 39 29 20 6f 66  with step (9) of
46d0: 20 61 20 70 75 73 68 2e 3c 2f 70 3e 0a 0a 3c 68   a push.</p>..<h
46e0: 32 3e 36 2e 30 20 53 75 6d 6d 61 72 79 3c 2f 68  2>6.0 Summary</h
46f0: 32 3e 0a 0a 3c 70 3e 48 65 72 65 20 61 72 65 20  2>..<p>Here are 
4700: 74 68 65 20 6b 65 79 20 70 6f 69 6e 74 73 20 6f  the key points o
4710: 66 20 74 68 65 20 73 79 6e 63 68 72 6f 6e 69 7a  f the synchroniz
4720: 61 74 69 6f 6e 20 70 72 6f 74 6f 63 6f 6c 3a 3c  ation protocol:<
4730: 2f 70 3e 0a 0a 3c 6f 6c 3e 0a 3c 6c 69 3e 54 68  /p>..<ol>.<li>Th
4740: 65 20 63 6c 69 65 6e 74 20 73 65 6e 64 73 20 6f  e client sends o
4750: 6e 65 20 6f 72 20 6d 6f 72 65 20 50 55 53 48 20  ne or more PUSH 
4760: 48 54 54 50 20 72 65 71 75 65 73 74 73 20 74 6f  HTTP requests to
4770: 20 74 68 65 20 73 65 72 76 65 72 2e 0a 20 20 20   the server..   
4780: 20 54 68 65 20 72 65 71 75 65 73 74 20 61 6e 64   The request and
4790: 20 72 65 70 6c 79 20 63 6f 6e 74 65 6e 74 20 74   reply content t
47a0: 79 70 65 20 69 73 20 22 61 70 70 6c 69 63 61 74  ype is "applicat
47b0: 69 6f 6e 2f 78 2d 66 6f 73 73 69 6c 22 2e 0a 3c  ion/x-fossil"..<
47c0: 6c 69 3e 48 54 54 50 20 72 65 71 75 65 73 74 20  li>HTTP request 
47d0: 63 6f 6e 74 65 6e 74 20 69 73 20 63 6f 6d 70 72  content is compr
47e0: 65 73 73 65 64 20 75 73 69 6e 67 20 7a 6c 69 62  essed using zlib
47f0: 2e 0a 3c 6c 69 3e 54 68 65 20 63 6f 6e 74 65 6e  ..<li>The conten
4800: 74 20 6f 66 20 72 65 71 75 65 73 74 20 61 6e 64  t of request and
4810: 20 72 65 70 6c 79 20 63 6f 6e 73 69 73 74 73 20   reply consists 
4820: 6f 66 20 63 61 72 64 73 20 77 69 74 68 20 6f 6e  of cards with on
4830: 65 0a 20 20 20 20 63 61 72 64 20 70 65 72 20 6c  e.    card per l
4840: 69 6e 65 2e 20 20 0a 3c 6c 69 3e 43 61 72 64 20  ine.  .<li>Card 
4850: 66 6f 72 6d 61 74 73 20 61 72 65 3a 0a 20 20 20  formats are:.   
4860: 20 3c 75 6c 3e 0a 20 20 20 20 3c 6c 69 3e 20 3c   <ul>.    <li> <
4870: 62 3e 6c 6f 67 69 6e 3c 2f 62 3e 20 3c 69 3e 75  b>login</b> <i>u
4880: 73 65 72 69 64 20 6e 6f 6e 63 65 20 73 69 67 6e  serid nonce sign
4890: 61 74 75 72 65 3c 2f 69 3e 0a 20 20 20 20 3c 6c  ature</i>.    <l
48a0: 69 3e 20 3c 62 3e 70 75 73 68 3c 2f 62 3e 20 3c  i> <b>push</b> <
48b0: 69 3e 73 65 72 76 65 72 63 6f 64 65 20 70 72 6f  i>servercode pro
48c0: 6a 65 63 74 63 6f 64 65 3c 2f 69 3e 0a 20 20 20  jectcode</i>.   
48d0: 20 3c 6c 69 3e 20 3c 62 3e 70 75 6c 6c 3c 2f 62   <li> <b>pull</b
48e0: 3e 20 3c 69 3e 73 65 72 76 65 72 63 6f 64 65 20  > <i>servercode 
48f0: 70 72 6f 6a 65 63 74 63 6f 64 65 3c 2f 69 3e 0a  projectcode</i>.
4900: 20 20 20 20 3c 6c 69 3e 20 3c 62 3e 63 6c 6f 6e      <li> <b>clon
4910: 65 3c 2f 62 3e 0a 20 20 20 20 3c 6c 69 3e 20 3c  e</b>.    <li> <
4920: 62 3e 66 69 6c 65 3c 2f 62 3e 20 3c 69 3e 75 75  b>file</b> <i>uu
4930: 69 64 20 73 69 7a 65 3c 2f 69 3e 20 3c 62 3e 5c  id size</i> <b>\
4940: 6e 3c 2f 62 3e 20 3c 69 3e 63 6f 6e 74 65 6e 74  n</b> <i>content
4950: 3c 2f 69 3e 0a 20 20 20 20 3c 6c 69 3e 20 3c 62  </i>.    <li> <b
4960: 3e 66 69 6c 65 3c 2f 62 3e 20 3c 69 3e 75 75 69  >file</b> <i>uui
4970: 64 20 64 65 6c 74 61 2d 75 75 69 64 20 73 69 7a  d delta-uuid siz
4980: 65 3c 2f 69 3e 20 3c 62 3e 5c 6e 3c 2f 62 3e 20  e</i> <b>\n</b> 
4990: 3c 69 3e 63 6f 6e 74 65 6e 74 3c 2f 69 3e 0a 20  <i>content</i>. 
49a0: 20 20 20 3c 6c 69 3e 20 3c 62 3e 69 67 6f 74 3c     <li> <b>igot<
49b0: 2f 62 3e 20 3c 69 3e 75 75 69 64 3c 2f 69 3e 0a  /b> <i>uuid</i>.
49c0: 20 20 20 20 3c 6c 69 3e 20 3c 62 3e 67 69 6d 6d      <li> <b>gimm
49d0: 65 3c 2f 62 3e 20 3c 69 3e 75 75 69 64 3c 2f 69  e</b> <i>uuid</i
49e0: 3e 0a 20 20 20 20 3c 6c 69 3e 20 3c 62 3e 63 6f  >.    <li> <b>co
49f0: 6f 6b 69 65 3c 2f 62 3e 20 20 3c 69 3e 63 6f 6f  okie</b>  <i>coo
4a00: 6b 69 65 2d 74 65 78 74 3c 2f 69 3e 0a 20 20 20  kie-text</i>.   
4a10: 20 3c 6c 69 3e 20 3c 62 3e 65 72 72 6f 72 3c 2f   <li> <b>error</
4a20: 62 3e 20 3c 69 3e 65 72 72 6f 72 2d 6d 65 73 73  b> <i>error-mess
4a30: 61 67 65 3c 2f 69 3e 0a 20 20 20 20 3c 2f 75 6c  age</i>.    </ul
4a40: 3e 0a 3c 6c 69 3e 50 68 61 6e 74 6f 6d 73 20 61  >.<li>Phantoms a
4a50: 72 65 20 66 69 6c 65 73 20 74 68 61 74 20 61 20  re files that a 
4a60: 72 65 70 6f 73 69 74 6f 72 79 20 6b 6e 6f 77 73  repository knows
4a70: 20 65 78 69 73 74 20 62 75 74 20 64 6f 65 73 20   exist but does 
4a80: 6e 6f 74 20 70 6f 73 73 65 73 73 2e 0a 3c 6c 69  not possess..<li
4a90: 3e 43 6c 75 73 74 65 72 73 20 61 72 65 20 66 69  >Clusters are fi
4aa0: 6c 65 73 20 74 68 61 74 20 63 6f 6e 74 61 69 6e  les that contain
4ab0: 20 74 68 65 20 55 55 49 44 73 20 6f 66 20 6f 74   the UUIDs of ot
4ac0: 68 65 72 20 66 69 6c 65 73 2e 0a 3c 6c 69 3e 43  her files..<li>C
4ad0: 6c 75 73 74 65 72 73 20 61 72 65 20 63 72 65 61  lusters are crea
4ae0: 74 65 64 20 61 75 74 6f 6d 61 74 69 63 61 6c 6c  ted automaticall
4af0: 79 20 6f 6e 20 74 68 65 20 73 65 72 76 65 72 20  y on the server 
4b00: 64 75 72 69 6e 67 20 61 20 70 75 6c 6c 2e 0a 3c  during a pull..<
4b10: 6c 69 3e 52 65 70 6f 73 69 74 6f 72 69 65 73 20  li>Repositories 
4b20: 6b 65 65 70 20 74 72 61 63 6b 20 6f 66 20 61 6c  keep track of al
4b30: 6c 20 66 69 6c 65 73 20 74 68 61 74 20 61 72 65  l files that are
4b40: 20 6e 6f 74 20 6e 61 6d 65 64 20 69 6e 20 61 6e   not named in an
4b50: 79 0a 63 6c 75 73 74 65 72 20 61 6e 64 20 73 65  y.cluster and se
4b60: 6e 64 20 69 67 6f 74 20 6d 65 73 73 61 67 65 73  nd igot messages
4b70: 20 66 6f 72 20 74 68 6f 73 65 20 66 69 6c 65 73   for those files
4b80: 2e 0a 3c 6c 69 3e 52 65 70 6f 73 69 74 6f 72 69  ..<li>Repositori
4b90: 65 73 20 6b 65 65 70 20 74 72 61 63 6b 20 6f 66  es keep track of
4ba0: 20 61 6c 6c 20 74 68 65 20 70 68 61 6e 74 6f 6d   all the phantom
4bb0: 73 20 74 68 65 79 20 68 6f 6c 64 20 61 6e 64 20  s they hold and 
4bc0: 73 65 6e 64 0a 67 69 6d 6d 65 20 6d 65 73 73 61  send.gimme messa
4bd0: 67 65 73 20 66 6f 72 20 74 68 6f 73 65 20 66 69  ges for those fi
4be0: 6c 65 73 2e 0a 3c 2f 6f 6c 3e 0a                 les..</ol>.