#!/usr/bin/python

# Test the bflist (bfls) command.

import os
import common

hgt = common.BfilesTester()
hgt.announce('setup')
hgt.updaterc()
hgt.hg(['clone', '-q', '-U', hgt.tjoin('test-repo1.bundle'), 'repo1'],
       stdout=hgt.ANYTHING)
os.chdir('repo1')

hgt.announce('rev 0 (no big files)')
hgt.hg(['update', '0'],
       stdout='2 files updated, 0 files merged, 0 files removed, 0 files unresolved\n')
hgt.hg(['bflist'],
       stdout='')

hgt.announce('rev 1')
hgt.hg(['update', '-q', '1'])
hgt.hg(['bfls'],
       stdout=('big1\n'
               'big2\n'))

hgt.announce('rev 4 (with -r)')
hgt.hg(['bflist', '-r', '4'],
       stdout=('big1\n'
               'big2\n'
               'space dir/blah\n'
               'sub/big3\n'
               'sub/space file\n'))

hgt.announce('rev 3 (subdir)')
hgt.hg(['update', '-q', '3'])
hgt.hg(['bflist', 'sub'],
       stdout='sub/big3\n')
os.chdir('sub')
hgt.hg(['bflist', '.'],
       stdout='big3\n')
os.chdir('..')

hgt.announce('-0 option')
hgt.hg(['bflist', '-0'],
       stdout='big1\0big2\0sub/big3\0')

hgt.announce('bflist shows working copy (includes bfadd\'ed files)')
hgt.writefile('sub/newbie', '')
hgt.hg(['bfadd', '-q', 'sub/newbie'])
hgt.hg(['bflist'],
       stdout=('big1\n'
               'big2\n'
               'sub/big3\n'
               'sub/newbie\n'))
