Source

repoman / tests / output / in.py

Full commit
import os
import shutil
from tests.support import write_text

from repoman.ui import SimpleUi as ui
from repoman import forest, cmdutil

from tests.pytest import run, Quiet

def hg_add_file(repo, module, filename, content = 'Some content'):
    modulepath = '%s/%s' % (repo, module)
    filepath = '%s/%s' % (modulepath, filename)
    write_text('%s' % filepath, content)
    os.system('hg add -R %s %s' % (modulepath, filepath))

def hg_commit(repo, module, message = '"Dummy message"'):
    os.system('hg commit -R %s/%s -d "0 0" -m %s' % (repo, module, message))

def get_commit_message(forest, text=[''], extra=[]):
    return '\n'.join([e for e in text if not e.startswith('HG:')]).strip()

orig_gcm = cmdutil.get_commit_message
cmdutil.get_commit_message = get_commit_message

print('Cloning forest1 to incoming_forest2')
with Quiet():
    run('clone ../forest1 -M * -b core/dev -d incoming_forest2')

print('test on clean clone - i.e., without incoming changes')
run('in -R incoming_forest2')

print('clone incoming_forest2 to incoming_forest3')
with Quiet():
    run('clone incoming_forest2 -M * -b core/dev -d incoming_forest3')

print('add and commit changeset in incoming_forest2')
hg_add_file('incoming_forest2', 'c', 'baz')
hg_commit('incoming_forest2', 'c')

print('check incoming on working branch (implicit)')
run('in -R incoming_forest3')

print('check incoming on working branch (explicit, with repeats)')
run('in -R incoming_forest3 -b . -b .')

print('check incoming with quiet option')
run('in -q -R incoming_forest3')

print('check incoming in cloned dir on working branch - using explicit --current arg')
run('in -R incoming_forest3 --current')

print('check incoming in cloned dir on another branch (i.e., using arg)')
run('in -R incoming_forest3 --branch core/stable')

print('check incoming in cloned dir on an unknown branch')
run('in -R incoming_forest3 --branch unknownbranch')

print('create a new branch in incoming_forest2')
run('branch --create --root newbranch -R incoming_forest2 -M a -M b -M c --date "0 0"')
run('-R incoming_forest2 up core/dev')

print('check incoming in cloned dir on an unknown branch and a known branch')
run('in -R incoming_forest3 -b unknownbranch -b core/dev')

print('check incoming on working branch (implicit)')
run('in -R incoming_forest3')

print('check incoming in cloned dir on branches core/dev and core/stable (i.e., using args)')
run('in -R incoming_forest3 -b core/dev -b core/stable')

print('check incoming in cloned dir on branches with repeats')
run('in -R incoming_forest3 -b core/dev -b core/stable -b core/dev')

print('check incoming in cloned dir on branches * (i.e., using arg)')
run('in -R incoming_forest3 -b *')

print('check incoming in cloned dir on branches * with redundancy (i.e., using arg)')
run('in -R incoming_forest3 -b core/dev -b * -b core/stable')

print('Test fast-forwarding...')

print('Setting up test-situation')
print('--update to core/stable in incoming_forest2')
run('up core/stable -R incoming_forest2')
print('--create a new branch core/new on top of core/stable in incoming_forest2')
run('branch --create core/new -R incoming_forest2 -M a -M b -M c --date "0 0"')
run('-R incoming_forest2 up core/stable')

print('--pull core/new to incoming_forest3')
run('pull -R incoming_forest3 -b core/new')

print('--merge core/dev into core/stable in incoming_forest2')
run('merge core/dev -R incoming_forest2')
run('commit -d "0 0" -R incoming_forest2')
print('--update to core/new in incoming_forest2')
run('up core/new -R incoming_forest2')
print('--merge core/stable into core/new in incoming_forest2')
print('  (as core/new has no updates and core/stable has been updated (via the merge) core/new is fast-forwarded)')
run('merge core/stable -R incoming_forest2')
run('commit --date "0 0" -R incoming_forest2')
print('Done setting up.\n')

print('now check incoming (on all branches) from incoming_forest3')
print('we expect messages that core/new has been fast-forwarded')
run('in -R incoming_forest3 -b core/dev -b core/stable -b core/new')

try:
    shutil.rmtree('incoming_forest2')
    shutil.rmtree('incoming_forest3')
except Exception:
    pass

cmdutil.get_commit_message = orig_gcm