[PATCH 2 of 3 V4 RFC] model (1): c-hglib: hg_log() level 1 function

Giovanni Gherdovich g.gherdovich at gmail.com
Sun Sep 1 16:33:28 CDT 2013


2013/9/1 Iulian Stana <julian.stana at gmail.com>

> # HG changeset patch
> # User Iulian Stana <julian.stana at gmail.com>
> # Date 1378056765 -10800
> #      Sun Sep 01 20:32:45 2013 +0300
> # Node ID 0d7faa1c7ad6bc680fe2bc2cdad0c3becaabd603
> # Parent  301aad54936be170f1915a034893911f4e742c93
> model (1): c-hglib: hg_log() level 1 function
>
> This mechanism could be called model (1):
>
> [...]
> +
> +/* The cbuf next step. Getting the next changeset. */
> +int hg_fetch_cset_entry(hg_csetstream_buffer *cbuf, hg_cset_entry *centry)
> +{
>


I am not sure that this function behaves as it is suppose to.
In particular, I am afraid you assume that changeset boundaries and
'o' writes boundaries coincide (and they don't, in the general case).
You should assume that boundaries of 'o' chunks and
changeset delimiters (null bytes \0) are totally unrelated events in the
data stream.

Could you please test it against the python script below, which is supposed
to emulate the command server? You run it giving as argument the name
of the test function you want to execute (eg 'python testserv t1').

GGhh

-- -- >8 -- -- >8 -- -- >8 -- -- cut here -- -- >8 -- -- >8 -- -- >8
import sys
import struct
import os

"""
memo: the template is
"\0{rev}\n{node}\n{tags}\n{branch}\n{author}\n{date|isodate}\n{desc}"

The test changeset data:

\00\nXoooooo\nfoo\ndefault\nBabar\nJan 1st, 1970\nI am the King of
Celesteville.
\01\noXooooo\nboo\ndefault\nCeleste\nJan 2nd, 1970\nI am the Queen of
Celesteville.
\02\nooXoooo\nwoo\ndefault\nArthur\nJan 3rd, 1970\nI am Celeste's brother.
\03\noooXooo\nhoo\ndefault\nPom\nJan 4th, 1970\nI am the oldest of the kids.
\04\nooooXoo\ndoo\ndefault\nFlora\nJan 5th, 1970\nPom and Alexander make
fun of me.
\05\noooooXo\nmoo\ndefault\nAlexander\nJan 6th, 1970\nI love playing with
Pom.
\06\nooooooX\npoo\ndefault\nIsabelle\nJan 7th, 1970\nI am the yungest, but
I'm very smart.
\07\nooooooo\nyoo\ndefault\nLord Rataxes\nJan 8th, 1970\nI am the king of
Rhinoland.

The docstring of each test function describes the output.
"""

def t1():
    """
    \0aaaaaa
    """
    chunk1 = ("\00\nXoooooo\nfoo\ndefault\nBabar\n" +
              "Jan 1st, 1970\nI am the King of Celesteville.")
    sys.stdout.write(struct.pack('>cI', 'o', len(chunk1)))
    sys.stdout.write(chunk1)
    sys.stdout.write(struct.pack('>cI', 'r', 4))
    sys.stdout.write('\0\0\0\0')
    sys.stdout.flush()

def t2():
    """
    \0aaaaaa\0bbbb
    """
    chunk1 = ("\01\noXooooo\nboo\ndefault\nCeleste\n" +
              "Jan 2nd, 1970\nI am the Queen of Celesteville." +
              "\02\nooXoooo\nwoo\ndefault\nArthur\n" +
              "Jan 3rd, 1970\nI am Celeste's brother.")
    sys.stdout.write(struct.pack('>cI', 'o', len(chunk1)))
    sys.stdout.write(chunk1)
    sys.stdout.write(struct.pack('>cI', 'r', 4))
    sys.stdout.write('\0\0\0\0')
    sys.stdout.flush()

def t3():
    """
    \0aaaa
    aaaaaa
    aa
    """
    chunk1 = "\03\noooXooo\nhoo\ndef"
    chunk2 = "ault\nPom\nJan 4th, 19"
    chunk3 = "70\nI am the oldest of the kids."
    sys.stdout.write(struct.pack('>cI', 'o', len(chunk1)))
    sys.stdout.write(chunk1)
    sys.stdout.write(struct.pack('>cI', 'o', len(chunk2)))
    sys.stdout.write(chunk2)
    sys.stdout.write(struct.pack('>cI', 'o', len(chunk3)))
    sys.stdout.write(chunk3)
    sys.stdout.write(struct.pack('>cI', 'r', 4))
    sys.stdout.write('\0\0\0\0')
    sys.stdout.flush()

def t4():
    """
    \0aaaaa
    aaa\0bbbb\0ccc\0ddd
    ddd
    """
    chunk1 = "\04\nooooXoo\ndoo\ndefault\nFlora\nJan 5th, "
    chunk2 = ("1970\nPom and Alexander make fun of me." +
              "\05\noooooXo\nmoo\ndefault\nAlexander\nJan 6th, "
              "1970\nI love playing with Pom." +
              "\06\nooooooX\npoo\ndefault\nIsabe" +
              " lle\nJan 7th, 1970\nI am the yungest, " +
              "but I'm very smart." +
              "\07\nooooooo\nyoo\ndefault\nLord ")
    chunk3 = "Rataxes\nJan 8th, 1970\nI am the king of Rhinoland."
    sys.stdout.write(struct.pack('>cI', 'o', len(chunk1)))
    sys.stdout.write(chunk1)
    sys.stdout.write(struct.pack('>cI', 'o', len(chunk2)))
    sys.stdout.write(chunk2)
    sys.stdout.write(struct.pack('>cI', 'o', len(chunk3)))
    sys.stdout.write(chunk3)
    sys.stdout.write(struct.pack('>cI', 'r', 4))
    sys.stdout.write('\0\0\0\0')
    sys.stdout.flush()

test = {'t1': t1, 't2': t2, 't3': t3, 't4': t4}

if __name__ == '__main__':
    test[sys.argv[1]]()
    os.read(0, 1)
-- -- >8 -- -- >8 -- -- >8 -- -- cut here -- -- >8 -- -- >8 -- -- >8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130901/19d01f58/attachment.html>


More information about the Mercurial-devel mailing list