view tests/test-filelog @ 16224:d52a6b542db1

bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface Some of the formatting details required for bug submission via email changed between Bugzilla 3.4 and 3.6. Bugzilla 3.4 requires lines of the form '@fieldname = value', while 3.6 wants '@fieldname value'. Also the field @bug_id in 3.4 becomes @id in 3.6. Bugzilla up to and including 4.0 also recognises the 3.4 format. To save surprises in the future, check the Bugzilla version and use the 3.6 format from all major versions >= 4. At some point we will drop support for Bugzilla prior to 3.6 and support the new format only.
author Jim Hague <jim.hague@acm.org>
date Thu, 01 Mar 2012 14:50:31 +0000
parents 2de1244361aa
children
line wrap: on
line source

#!/usr/bin/env python
"""
Tests the behaviour of filelog w.r.t. data starting with '\1\n'
"""
from mercurial import ui, hg
from mercurial.node import nullid, hex

myui = ui.ui()
repo = hg.repository(myui, path='.', create=True)

fl = repo.file('foobar')

def addrev(text, renamed=False):
    if renamed:
        # data doesnt matter. Just make sure filelog.renamed() returns True
        meta = dict(copyrev=hex(nullid), copy='bar')
    else:
        meta = {}

    lock = t = None
    try:
        lock = repo.lock()
        t = repo.transaction('commit')
        node = fl.add(text, meta, t, 0, nullid, nullid)
        return node
    finally:
        if t:
            t.close()
        if lock:
            lock.release()

def error(text):
    print 'ERROR: ' + text

textwith = '\1\nfoo'
without = 'foo'

node = addrev(textwith)
if not textwith == fl.read(node):
    error('filelog.read for data starting with \\1\\n')
if fl.cmp(node, textwith) or not fl.cmp(node, without):
    error('filelog.cmp for data starting with \\1\\n')
if fl.size(0) != len(textwith):
    error('FIXME: This is a known failure of filelog.size for data starting '
        'with \\1\\n')

node = addrev(textwith, renamed=True)
if not textwith == fl.read(node):
    error('filelog.read for a renaming + data starting with \\1\\n')
if fl.cmp(node, textwith) or not fl.cmp(node, without):
    error('filelog.cmp for a renaming + data starting with \\1\\n')
if fl.size(1) != len(textwith):
    error('filelog.size for a renaming + data starting with \\1\\n')

print 'OK.'