Artifact [5f9da2a9ff]
Not logged in

Artifact 5f9da2a9ff12bc9028d3c5ae05b06f57a28f6f2b:

Ticket change [5f9da2a9ff] - Ticket [77de516a1f] Post-push patch status still Open with 1 other change by wolfgang 2010-10-19 08:03:24.
D 2010-10-19T08:03:24
J comment Please\ssee\sthe\smailing\slist\sarchives,\ssubject\sthread:\s"autobuild".\r\n\r\nTo\ssum\sit\sup,\ssomeone\sposted\sthat\she'd\slike\sto\ssee\sa\spost-push\shook\sin\sFossil's\sserver\sside.\sA\slot\sof\squestions\swere\sasked\swhich\sno\sone\scared\sto\sanswer.\r\n\r\nThen\sI\scame\salong,\sanswered\sthe\squestions\sand\scame\sup\swith\sa\ssmall\spatch\sto\simplement\sa\sminimal\spost-push\shook.\sPosted\sthe\spatch\sback\sto\sthe\smailing\slist\swith\sa\srequest\sfor\ssuggestions\sand\scomments,\swhich\severyone\signored.\s:D\s\r\n\r\nSo,\shere\sis\smy\sdiff\s(to\srun\sagainst\ssrc/xfer.c).\sBe\saware\sit's\snot\scomplete,\sas\snoted\sin\sthe\scode.\sDiscussion,\sanyone?\r\n\r\n[https://dreamtrack.dnsalias.com/downloads/post-push-patch.diff|patch\s1]\r\n\r\n<hr\s/><i>wolfgang\sadded\son\s2010-10-15\s21:08:35:</i><br\s/>\r\nI've\sused\syour\spatch\sand\safter\sadding\s\r\n<pre>\r\n\s\s\s\shttp_exchange(&send,\s&recv,\scloneFlag==0\s||\snCycle>0);\r\n\s\s\s\sblob_reset(&send);\r\n</pre>\r\nto\sthe\sclient\scode\sand\smaking\sthe\scmd\sarray\sin\sthe\shook\sfunction\slarger,\sit\sworks.\s\r\n\r\nBut\ssome\sremarks:\r\n\s\s*\s\sThe\sserver\sprocess\swaits\suntil\sthe\send\sof\sthe\shook.\sI\sdon't\sthink,\sthat\sis\sis\sreally\sa\sgood\sthing\r\n\s\s*\s\ssimply\sappending\soutputs\sto\sa\sfile\smay\sbecome\stricky,\sif\smultiple\sclient\srequest\scome\sin\sat\sthe\ssame\stime.\sThe\sparallel\srunning\shook\sjobs\swill\sappend\stheir\sdata\sat\sthe\ssame\stime\sand\swill\smess\sup\sthe\slogs\r\n\r\nThe\sidea\sof\ssending\sa\sspecial\s'do-it'-line\sfrom\sthe\sclient\sis\snice.\sThe\swhole\sthing\smight\sbe\sextended\s-\si\sknow,\syour\spatch\sis\snot\sfinished\s:-)\s-\swith:\r\n\s\s*\s\sthe\shook\scommand\sshould\sbe\sconfigured\sby\sa\ssetting\s(gui\sand/or\scommand\sline\ssetting)\r\n\s\s*\s\sredirects\sof\sstdin/stderr\sshould\sbe\spart\sof\sthe\scommand\sconfiguration\r\n\s\s*\s\sthe\sclient\scould\suse\sa\sspecial\ssettings\sstring,\swhich\swould\sbe\sappended\sto\sthe\s'do-it'-line.\sThis\ssetting\scould\sbe\sread\sby\sthe\sserver\sand\sadded\sto\sthe\scommand\sline\sof\sthe\sserver.\sThis\sway,\sthe\susers\sof\ssuch\shooks\scan\sconfigure\sthe\smessage\spassing\sduring\sthe\ssync.\sGiven\syour\spatch,\sthe\sclient\smight\ssend\s<kbd>#FAT\sbuild</kbd>\sand\sthe\sserver\swould\scall\s<kbd>targetcmd\sbuild</kbd>\r\n\s\s*\s\sif\sboth\ssides\sof\sthe\sline\suse\sa\ssetting\sfor\sthe\s'do-it'\sstring\s(FAT\sin\syour\spatch),\sit\swould\sbe\sfully\sconfigurable,\sif\sthe\sclients\swants\sto\ssend\sa\s'do-it'\sline\sand/or\sthe\sserver\srecognizes\sthese\srequests.\r\n\r\nbest\sregards<br>Wolfgang\r\n\r\nThe\sresults\sof\smy\stests:\r\n<nowiki><pre>\r\nIndex:\ssrc/xfer.c\r\n===================================================================\r\n---\ssrc/xfer.c\r\n+++\ssrc/xfer.c\r\n@@\s-40,10\s+40,26\s@@\r\n\s\s\sint\snDeltaRcvd;\s\s\s\s\s/*\sNumber\sof\sdeltas\sreceived\s*/\r\n\s\s\sint\snDanglingFile;\s\s/*\sNumber\sof\sdangling\sdeltas\sreceived\s*/\r\n\s\s\sint\smxSend;\s\s\s\s\s\s\s\s\s/*\sStop\ssending\s"file"\swith\spOut\sreaches\sthis\ssize\s*/\r\n\s};\r\n\r\n+/*\r\n+**\sLet\sa\sserver-side\sexternal\sagent\sknow\sthat\sa\spush\shas\scompleted.\s/fatman\r\n+*/\r\n+void\spost_push_hook()\s{\r\n+\s\s/*\r\n+\s\s**\sTO\sDO:\sget\sthe\sstring\scmd\sfrom\sa\sconfig\sfile?\sOr\sthe\sdatabase\slocal\r\n+\s\s**\ssettings,\sas\ssomeone\ssuggested?\sDitto\soutput\sand\serror\slogs.\s/fatman\r\n+\s\s*/\r\n+\s\schar\scmd[1024]\s=\s"targetcmd";\r\n+\s\sstrcat(cmd,\s"\s>target.out\s2>target.err");\r\n+\s\sconst\schar\s*ptr\s=\scmd;\r\n+\s\sint\src\s=\ssystem(ptr);\r\n+\s\sif\s(rc\s!=\s0)\s{\r\n+\s\s\s\sfossil_print("The\spost-push-hook\scommand\s\\"%s\\"\sfailed.",\sptr);\r\n+\s\s}\r\n+}\r\n\r\n\s/*\r\n\s**\sThe\sinput\sblob\scontains\sa\sUUID.\s\sConvert\sit\sinto\sa\srecord\sID.\r\n\s**\sCreate\sa\sphantom\srecord\sif\sno\sprior\srecord\sexists\sand\r\n\s**\sphantomize\sis\strue.\r\n@@\s-617,11\s+633,17\s@@\r\n\s\s\s);\r\n\s\s\szNow\s=\sdb_text(0,\s"SELECT\sstrftime('%%Y-%%m-%%dT%%H:%%M:%%S',\s'now')");\r\n\s\s\s@\s#\stimestamp\s%s(zNow)\r\n\s\s\smanifest_crosslink_begin();\r\n\s\s\swhile(\sblob_line(xfer.pIn,\s&xfer.line)\s){\r\n-\s\s\s\sif(\sblob_buffer(&xfer.line)[0]=='#'\s)\scontinue;\r\n+\s\s\s\sif(\sblob_buffer(&xfer.line)[0]=='#'\s){\r\n+\s\s\s\s\s\sif\s(\s0\s==\smemcmp(blob_buffer(&xfer.line),\s"#FAT",\s4)\s){\r\n+\s\s\s\s\s\s\s\sfprintf(stderr,"HOOK\\n");\r\n+\s\s\s\s\s\s\spost_push_hook();\r\n+\s\s\s\s\s\s}\r\n+\s\s\s\s\s\scontinue;\r\n+\s\s\s\s}\r\n\s\s\s\s\sxfer.nToken\s=\sblob_tokenize(&xfer.line,\sxfer.aToken,\scount(xfer.aToken));\r\n\r\n\s\s\s\s\s/*\s\s\sfile\sUUID\sSIZE\s\\n\sCONTENT\r\n\s\s\s\s\s**\s\s\sfile\sUUID\sDELTASRC\sSIZE\s\\n\sCONTENT\r\n\s\s\s\s\s**\r\n@@\s-1330,14\s+1352,20\s@@\r\n\s\s\s\s\s}\r\n\r\n\s\s\s\s\s/*\sIf\sthis\sis\sa\sclone,\sthe\sgo\sat\sleast\stwo\srounds\s*/\r\n\s\s\s\s\sif(\scloneFlag\s&&\snCycle==1\s)\sgo\s=\s1;\r\n\s\s\s};\r\n+\s\sif\s(pushFlag\s&&\snFileSend\s>\s0)\s{\r\n+\s\s\s\sblob_appendf(&send,\s"#FAT\\n");\r\n+\s\s\s\shttp_exchange(&send,\s&recv,\scloneFlag==0\s||\snCycle>0);\r\n+\s\s\s\sblob_reset(&send);\r\n+\s\s\s\snCardSent++;\r\n+\s\s}\r\n\s\s\stransport_stats(&nSent,\s&nRcvd,\s1);\r\n\s\s\sfossil_print("Total\snetwork\straffic:\s%d\sbytes\ssent,\s%d\sbytes\sreceived\\n",\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\snSent,\snRcvd);\r\n\s\s\stransport_close();\r\n\s\s\stransport_global_shutdown();\r\n\s\s\sdb_multi_exec("DROP\sTABLE\sonremote");\r\n\s\s\smanifest_crosslink_end();\r\n\s\s\sdb_end_transaction(0);\r\n\s}\r\n</pre></nowiki>\r\n\r\n<hr\s/><i>wolfgang\sadded\son\s2010-10-16\s15:12:59:</i><br\s/>\r\nI've\sattached\sa\spatch\sfile,\swhich\sadds\sa\sworking\spush-hook\sto\sfossil.\sIt's\sconfigured\susing\sthe\ssettings\scommand/gui-page.\r\n\r\nThe\sclient\sand\sserver\scan\sbe\sconfigured:\r\n\r\n\s\s*\s\sclient\spattern:\sthe\spattern,\swhich\swill\sbe\ssent\sto\sthe\sserver\scan\sbe\sconfigured\son\sclient\sside\r\n\s\s*\s\sserver\spattern:\sthe\sprefix\sof\sthe\sclient\spattern,\swhich\swill\sbe\saccepted\sto\sstart\sthe\shook\scan\sbe\sconfigured\son\sserver\sside\r\n\s\s*\s\sthe\sexecuted\scommand\scan\sbe\sconfigured\son\sserver\sside.\sThe\spattern,\ssent\sby\sthe\sclient\swill\sbe\sadded\sto\sthe\scommand\sline\r\n\r\n<hr\s/><i>anonymous\sclaiming\sto\sbe\sarichardson\sadded\son\s2010-10-18\s13:04:03:</i><br\s/>\r\n>\sThe\sserver\sprocess\swaits\suntil\sthe\send\sof\sthe\shook.\sI\sdon't\sthink,\sthat\sis\sis\sreally\sa\sgood\sthing\r\n\r\nAgreed,\sthis\swould\sbe\sa\sbad\sthing.\sCould\swe\ssimply\sappend\s"\s&"\sto\sthe\shook\scommand?\sThat\sdetaches\sthe\sprocess\sfrom\sthe\scommand\sline,\sso\sit\scan\scomplete\sin\sits\sown\stime.\sIt\sworks\sin\s*nix\sand\sI\sthink\sit\swould\swork\sin\sWindows,\sthough\sthat\spoint\sneeds\schecking.\sOne\stechnique\sI\sknow\sworks\sin\sWindows\sis\sto\sprepend\s"start\s"\sto\sthe\scommand,\sbut\sthat\sdoesn't\swork\sin\s*nix.\r\n\r\n>\ssimply\sappending\soutputs\sto\sa\sfile\smay\sbecome\stricky,\sif\smultiple\sclient\srequest\scome\sin\sat\sthe\ssame\stime\r\n\r\nHow\sabout\sappending\sto\sa\sfile\snamed\sfor\sthe\sremote\sFossil?\sThat\sdata\scould\sbe\sincluded\sin\sthe\scomment\scard,\seg.\s#FAT[12345678]\ssaves\soutput\sto\s12345678.err.log.\r\n\r\n>\sThe\swhole\sthing\smight\sbe\sextended\s-\si\sknow,\syour\spatch\sis\snot\sfinished\s:-)\r\n\r\nGreat\s-\sexactly\swhat\sI\swas\safter.\sI\sdon't\swant\sthe\sboss\scatching\sme\sat\sthis\sas\sit\swould\sbe\ssomewhat\shard\sto\sexplain.\s;)\s\r\n\r\n>\sthe\shook\scommand\sshould\sbe\sconfigured\sby\sa\ssetting\r\n\r\nAgreed.\r\n\r\n>\sredirects\sof\sstdin/stderr\sshould\sbe\spart\sof\sthe\scommand\sconfiguration\r\n\r\nI\slike\sit.\r\n\r\n>\sthe\sclient\scould\suse\sa\sspecial\ssettings\sstring,\swhich\swould\sbe\sappended\sto\sthe\s'do-it'-line\r\n\r\nInteresting.\sDoes\sthis\snot\sraise\sthe\sspectre\sof\spotential\sabuse,\sthough?\sPerhaps\sthe\sremote\suser\scould\sbe\sgranted\sa\sspecial\s"allow\scustom\shook"\sprivilege.\r\n\r\n>\sif\sboth\ssides\sof\sthe\sline\suse\sa\ssetting\sfor\sthe\s'do-it'\sstring\r\n\r\nI\scan\ssee\spossibilities\sthere.\r\n\r\n\r\n<hr\s/><i>wolfgang\sadded\son\s2010-10-18\s14:07:39:</i><br\s/>\r\nTake\sa\slook\sat\s[9cf288de27],\sit's\sa\scomplete\simplementation\sof\sa\sconfigurable\spost\spush\shook.\s\r\n\r\n<blockquote>Agreed,\sthis\swould\sbe\sa\sbad\sthing.\sCould\swe\ssimply\sappend\s"\s&"\sto\sthe\shook\scommand?\sThat\sdetaches\sthe\sprocess\sfrom\sthe\scommand\sline,\sso\sit\scan\scomplete\sin\sits\sown\stime.\sIt\sworks\sin\s*nix\sand\sI\sthink\sit\swould\swork\sin\sWindows,\sthough\sthat\spoint\sneeds\schecking.\sOne\stechnique\sI\sknow\sworks\sin\sWindows\sis\sto\sprepend\s"start\s"\sto\sthe\scommand,\sbut\sthat\sdoesn't\swork\sin\s*nix.</blockquote>\r\nOK,\si\ssee\s\sthe\spoint.\sWe\sshouldn't\sadd\sto\smuch\s(OS-specific!)\scode\sto\sfossil.\sUsing\ssynchronous/asynchronous\shooks\sshould\sbe\spart\sof\sthe\sstarted\sscripts/programms.\r\n\r\n<blockquote>How\sabout\sappending\sto\sa\sfile\snamed\sfor\sthe\sremote\sFossil?\sThat\sdata\scould\sbe\sincluded\sin\sthe\scomment\scard,\seg.\s#FAT12345678\s\ssaves\soutput\sto\s12345678.err.log.</blockquote>\r\nThe\shook\scan\sbe\striggered\ssimultaneously\sfrom\sdifferent\ssides.\sI\sthink,\si'll\sadd\sa\sstdin/stderr\sredirect\sto\sa\sfile\swith\sa\stimestamp/random\snumber\spart.\sThis\sfallback\sredirection\sis\sin\saddition\sto\sthe\sredirect,\sdefined\sin\sthe\sprogram/script.\r\n\r\n<blockquote>Interesting.\sDoes\sthis\snot\sraise\sthe\sspectre\sof\spotential\sabuse,\sthough?\sPerhaps\sthe\sremote\suser\scould\sbe\sgranted\sa\sspecial\s"allow\scustom\shook"\sprivilege.</blockquote>\r\nThe\sserver\shas\sits\sown\ssetting\swhich\scontrols,\swhich\sarguments\s\sare\saccepted.\sSo\si\sthink,\swe\sdon't\sneed\sa\snew\suser\spermission.\sChecking\suser\spermissions\swould\sonly\scheck\sthe\spermission\sof\sthe\ssync\suser,\snot\sthe\spermissions\sof\sthe\scommit\susers.\sIf\sneeded,\sthe\scalled\shook\scould\scheck\sthe\stimeline(rss?)\sto\sdo\sa\smore\squalified\spermission\scheck.\r\n\r\nIn\saddition\sto\smy\sfirst\sremarks,\si\sadded\sa\sserver\sside\scommand\slineoption,\sto\sactivate\sthe\shook\scommand\swithout\sthe\sneed\sof\sa\spush.\r\n\r\nSome\sideas\s-\simplemented\sin\s[a94ef5c00d]:\r\n\s\s*\s\sI'll\sadd\sa\snew\sclient\sand\sserver\sside\soption,\sto\strigger\sthe\sthe\shook\son\sall\ssync,\snot\sonly,\sif\sfiles\sare\spushed.\s\sThe\sclient\swill\ssend\sa\smark,\sif\sfiles\swhere\spushed\son\sthe\spush\shook\spattern\smessage.\r\n\s\s*\s\sThe\sname\sof\sthe\sfallback\slog\sfile\swill\sbe\sadded\sas\sfirst\sargument\sto\sthe\scommand\sline.\sThe\spush\shook\spattern\swill\sbe\sthe\ssecond\sargument.
K 77de516a1f2bfc1bd996a8520d0ce59b1b324e77
U wolfgang
Z dc7a4da6f42333ee6b150cf9a0e2025a