Source

repoman / tests / output / archive.py

import os
import shutil
import subprocess

from mercurial.util import unlink
from tests.pytest import run, Quiet

with Quiet() as _:
    run('clone ../forest1 sol1 -b core/dev -d archivetest')
os.chdir('archivetest')

try:
    print 'Archive to forest root, failure'
    run('--config "repo-extensions.archive=" archive .')

    print
    with open('archive','w') as f:
        f.write('\n')
    print 'Archive to existing file, failure'
    run('--config "repo-extensions.archive=" archive ./archive')
    #clean up
    unlink('archive')

    print
    print 'Archive to non-empty directory, failure'
    os.mkdir('archive')
    with open('archive/file', 'w') as f:
        f.write('\n')
    run('--config "repo-extensions.archive=" archive ./archive')
    #clean up
    shutil.rmtree('archive')

    print
    print 'Archive to valid existing directory'
    os.mkdir('archive')
    run('--config "repo-extensions.archive=" archive ./archive')
    with open('archive/.repo_archival.txt', 'r') as f:
        print f.read()
    #clean up
    shutil.rmtree('archive')

    print
    print 'Archive to valid new directory'
    run('--config "repo-extensions.archive=" archive ./archive')
    with open('archive/.repo_archival.txt', 'r') as f:
        print f.read()
    #clean up
    shutil.rmtree('archive')


finally:
    os.chdir('..')