repoman / tests / output / cloneconfig.py

import os
import subprocess

from tests.pytest import run, Quiet

with Quiet():
    run('clone ../forest1 -M * -b core/dev -d cloneconfig1')
    os.makedirs(os.path.join('cloneconfig1', '.root', 'config', 'scripts'))
    with open(os.path.join('cloneconfig1', '.root', 'config', 'a'), 'wb') as fh:
        fh.write('[hooks]\npretxncommit.foo=python:{GMD}\\config\\scripts\\test.py:hook\n')
    with open(os.path.join('cloneconfig1', '.root', 'config', 'scripts', 'test.py'), 'wb') as fh:
        fh.write('def hook(*args, **kwargs):\n  print "hook", args, kwargs\n')
    os.system('hg --quiet -R cloneconfig1/.root ci -A -m "New configuration" -d "0 0"')

    run('clone cloneconfig1 -M * -b core/dev -d cloneconfig2')

print
print '% checking configuration'
p = subprocess.Popen(['hg', '-R', 'cloneconfig2/a', 'showconfig', 'hooks'], stdout=subprocess.PIPE)
data = p.stdout.read()
p.wait()
print len(data.splitlines()) == 1

print
print '% pulling changes'
with open(os.path.join('cloneconfig1', '.root', 'config', 'a'), 'wb') as fh:
    fh.write('[ui]\nusername = foobar\n')
os.system('hg --quiet -R cloneconfig1/.root ci -m "Changed configuration" -d "0 0"')
run('-R cloneconfig2 pull -M a')

print
print '% showing configuration'
os.system('hg -R cloneconfig2/a showconfig hooks')
os.system('hg -R cloneconfig2/a showconfig ui')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.