<s> import py <EOL> import sys <EOL> from py . __ . path . svn . testing . svntestbase import CommonSvnTests , getrepowc , getsvnbin <EOL> from py . __ . path . svn . wccommand import InfoSvnWCCommand , XMLWCStatus <EOL> from py . __ . path . svn . wccommand import parse_wcinfotime <EOL> from py . __ . path . svn import svncommon <EOL> if sys . platform != '<STR_LIT:win32>' : <EOL> def normpath ( p ) : <EOL> return p <EOL> else : <EOL> try : <EOL> import win32api <EOL> except ImportError : <EOL> def normpath ( p ) : <EOL> py . test . skip ( '<STR_LIT>' ) <EOL> else : <EOL> import os <EOL> def normpath ( p ) : <EOL> p = win32api . GetShortPathName ( p ) <EOL> return os . path . normpath ( os . path . normcase ( p ) ) <EOL> def setup_module ( mod ) : <EOL> getsvnbin ( ) <EOL> class TestWCSvnCommandPath ( CommonSvnTests ) : <EOL> def setup_class ( cls ) : <EOL> repo , cls . root = getrepowc ( ) <EOL> def test_move_file ( self ) : <EOL> try : <EOL> super ( TestWCSvnCommandPath , self ) . test_move_file ( ) <EOL> finally : <EOL> self . root . revert ( rec = <NUM_LIT:1> ) <EOL> def test_move_directory ( self ) : <EOL> try : <EOL> super ( TestWCSvnCommandPath , self ) . test_move_directory ( ) <EOL> finally : <EOL> self . root . revert ( rec = <NUM_LIT:1> ) <EOL> def test_status_attributes_simple ( self ) : <EOL> def assert_nochange ( p ) : <EOL> s = p . status ( ) <EOL> assert not s . modified <EOL> assert not s . prop_modified <EOL> assert not s . added <EOL> assert not s . deleted <EOL> assert not s . replaced <EOL> dpath = self . root . join ( '<STR_LIT>' ) <EOL> assert_nochange ( self . root . join ( '<STR_LIT>' ) ) <EOL> assert_nochange ( self . root . join ( '<STR_LIT>' ) ) <EOL> def test_status_added ( self ) : <EOL> nf = self . root . join ( '<STR_LIT>' ) <EOL> nf . write ( '<STR_LIT:hello>' ) <EOL> nf . add ( ) <EOL> try : <EOL> s = nf . status ( ) <EOL> assert s . added <EOL> assert not s . modified <EOL> assert not s . prop_modified <EOL> assert not s . replaced <EOL> finally : <EOL> nf . revert ( ) <EOL> def test_status_change ( self ) : <EOL> nf = self . root . join ( '<STR_LIT>' ) <EOL> try : <EOL> nf . write ( nf . read ( ) + '<STR_LIT>' ) <EOL> s = nf . status ( ) <EOL> assert not s . added <EOL> assert s . modified <EOL> assert not s . prop_modified <EOL> assert not s . replaced <EOL> finally : <EOL> nf . revert ( ) <EOL> def test_status_added_ondirectory ( self ) : <EOL> sampledir = self . root . join ( '<STR_LIT>' ) <EOL> try : <EOL> t2 = sampledir . mkdir ( '<STR_LIT>' ) <EOL> t1 = t2 . join ( '<STR_LIT>' ) <EOL> t1 . write ( '<STR_LIT:test>' ) <EOL> t1 . add ( ) <EOL> s = sampledir . status ( rec = <NUM_LIT:1> ) <EOL> assert t1 . basename in [ item . basename for item in s . added ] <EOL> assert t2 . basename in [ item . basename for item in s . added ] <EOL> finally : <EOL> t2 . revert ( rec = <NUM_LIT:1> ) <EOL> t2 . localpath . remove ( rec = <NUM_LIT:1> ) <EOL> def test_status_unknown ( self ) : <EOL> t1 = self . root . join ( '<STR_LIT>' ) <EOL> try : <EOL> t1 . write ( '<STR_LIT:test>' ) <EOL> s = self . root . status ( ) <EOL> assert t1 . basename in [ item . basename for item in s . unknown ] <EOL> finally : <EOL> t1 . localpath . remove ( ) <EOL> def test_status_unchanged ( self ) : <EOL> r = self . root <EOL> s = self . root . status ( rec = <NUM_LIT:1> ) <EOL> assert r . join ( '<STR_LIT>' ) . basename in [ item . basename <EOL> for item in s . unchanged ] <EOL> assert r . join ( '<STR_LIT>' ) . basename in [ item . basename <EOL> for item in s . unchanged ] <EOL> assert r . join ( '<STR_LIT>' ) . basename in [ item . basename <EOL> for item in s . unchanged ] <EOL> def test_status_update ( self ) : <EOL> r = self . root <EOL> try : <EOL> r . update ( rev = <NUM_LIT:1> ) <EOL> s = r . status ( updates = <NUM_LIT:1> , rec = <NUM_LIT:1> ) <EOL> assert r . join ( '<STR_LIT>' ) . basename in [ item . basename for <EOL> item in s . update_available ] <EOL> finally : <EOL> r . update ( ) <EOL> def test_status_replaced ( self ) : <EOL> p = self . root . join ( "<STR_LIT>" ) <EOL> p . remove ( ) <EOL> p . ensure ( dir = <NUM_LIT:0> ) <EOL> p . add ( ) <EOL> try : <EOL> s = self . root . status ( ) <EOL> assert p . basename in [ item . basename for item in s . replaced ] <EOL> finally : <EOL> self . root . revert ( rec = <NUM_LIT:1> ) <EOL> def test_status_ignored ( self ) : <EOL> try : <EOL> d = self . root . join ( '<STR_LIT>' ) <EOL> p = py . path . local ( d ) . join ( '<STR_LIT>' ) <EOL> p . ensure ( file = True ) <EOL> s = d . status ( ) <EOL> assert [ x . basename for x in s . unknown ] == [ '<STR_LIT>' ] <EOL> assert [ x . basename for x in s . ignored ] == [ ] <EOL> d . propset ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s = d . status ( ) <EOL> assert [ x . basename for x in s . unknown ] == [ ] <EOL> assert [ x . basename for x in s . ignored ] == [ '<STR_LIT>' ] <EOL> finally : <EOL> self . root . revert ( rec = <NUM_LIT:1> ) <EOL> def test_status_conflict ( self ) : <EOL> if not py . test . config . option . runslowtests : <EOL> py . test . skip ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> wc = self . root <EOL> wccopy = py . path . svnwc ( <EOL> py . test . ensuretemp ( '<STR_LIT>' ) ) <EOL> wccopy . checkout ( wc . url ) <EOL> p = wc . ensure ( '<STR_LIT>' , file = <NUM_LIT:1> ) <EOL> p . write ( '<STR_LIT:foo>' ) <EOL> wc . commit ( '<STR_LIT>' ) <EOL> wccopy . update ( ) <EOL> assert wccopy . join ( '<STR_LIT>' ) . check ( ) <EOL> p . write ( '<STR_LIT:bar>' ) <EOL> wc . commit ( '<STR_LIT>' ) <EOL> wccopy . join ( '<STR_LIT>' ) . write ( '<STR_LIT>' ) <EOL> wccopy . update ( ) <EOL> s = wccopy . status ( ) <EOL> assert [ x . basename for x in s . conflict ] == [ '<STR_LIT>' ] <EOL> def test_status_external ( self ) : <EOL> if not py . test . config . option . runslowtests : <EOL> py . test . skip ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> otherrepo , otherwc = getrepowc ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> d = self . root . ensure ( '<STR_LIT>' , dir = <NUM_LIT:1> ) <EOL> try : <EOL> d . remove ( ) <EOL> d . add ( ) <EOL> d . update ( ) <EOL> d . propset ( '<STR_LIT>' , '<STR_LIT>' % ( otherwc . url , ) ) <EOL> d . update ( ) <EOL> s = d . status ( ) <EOL> assert [ x . basename for x in s . external ] == [ '<STR_LIT>' ] <EOL> assert '<STR_LIT>' not in [ x . basename for x in s . unchanged ] <EOL> s = d . status ( rec = <NUM_LIT:1> ) <EOL> assert [ x . basename for x in s . external ] == [ '<STR_LIT>' ] <EOL> assert '<STR_LIT>' in [ x . basename for x in s . unchanged ] <EOL> finally : <EOL> self . root . revert ( rec = <NUM_LIT:1> ) <EOL> def test_status_deleted ( self ) : <EOL> d = self . root . ensure ( '<STR_LIT>' , dir = <NUM_LIT:1> ) <EOL> d . remove ( ) <EOL> d . add ( ) <EOL> self . root . commit ( ) <EOL> d . ensure ( '<STR_LIT>' , dir = <NUM_LIT:0> ) <EOL> d . commit ( ) <EOL> s = d . status ( ) <EOL> assert '<STR_LIT>' in [ x . basename for x in s . unchanged ] <EOL> assert not s . deleted <EOL> p = d . join ( '<STR_LIT>' ) <EOL> p . remove ( ) <EOL> s = d . status ( ) <EOL> assert '<STR_LIT>' not in s . unchanged <EOL> assert [ x . basename for x in s . deleted ] == [ '<STR_LIT>' ] <EOL> def test_status_noauthor ( self ) : <EOL> xml = '''<STR_LIT>''' <EOL> XMLWCStatus . fromstring ( xml , self . root ) <EOL> def test_status_wrong_xml ( self ) : <EOL> xml = u'<STR_LIT>' <EOL> st = XMLWCStatus . fromstring ( xml , self . root ) <EOL> assert len ( st . incomplete ) == <NUM_LIT:1> <EOL> def test_diff ( self ) : <EOL> p = self . root / '<STR_LIT>' <EOL> out = p . diff ( rev = <NUM_LIT:2> ) <EOL> assert out . find ( '<STR_LIT:hello>' ) != - <NUM_LIT:1> <EOL> def test_blame ( self ) : <EOL> p = self . root . join ( '<STR_LIT>' ) <EOL> lines = p . blame ( ) <EOL> assert sum ( [ l [ <NUM_LIT:0> ] for l in lines ] ) == len ( lines ) <EOL> for l1 , l2 in zip ( p . readlines ( ) , [ l [ <NUM_LIT:2> ] for l in lines ] ) : <EOL> assert l1 == l2 <EOL> assert [ l [ <NUM_LIT:1> ] for l in lines ] == [ '<STR_LIT>' ] * len ( lines ) <EOL> p = self . root . join ( '<STR_LIT>' ) <EOL> lines = p . blame ( ) <EOL> assert sum ( [ l [ <NUM_LIT:0> ] for l in lines ] ) == len ( lines ) <EOL> for l1 , l2 in zip ( p . readlines ( ) , [ l [ <NUM_LIT:2> ] for l in lines ] ) : <EOL> assert l1 == l2 <EOL> assert [ l [ <NUM_LIT:1> ] for l in lines ] == [ '<STR_LIT>' ] * len ( lines ) <EOL> def test_join_abs ( self ) : <EOL> s = str ( self . root . localpath ) <EOL> n = self . root . join ( s , abs = <NUM_LIT:1> ) <EOL> assert self . root == n <EOL> def test_join_abs2 ( self ) : <EOL> assert self . root . join ( '<STR_LIT>' , abs = <NUM_LIT:1> ) == self . root . join ( '<STR_LIT>' ) <EOL> def test_str_gives_localpath ( self ) : <EOL> assert str ( self . root ) == str ( self . root . localpath ) <EOL> def test_versioned ( self ) : <EOL> assert self . root . check ( versioned = <NUM_LIT:1> ) <EOL> assert self . root . join ( '<STR_LIT>' ) . check ( versioned = <NUM_LIT:1> ) <EOL> assert not self . root . join ( '<STR_LIT>' ) . check ( versioned = <NUM_LIT:1> ) <EOL> notexisting = self . root . join ( '<STR_LIT:hello>' ) . localpath <EOL> try : <EOL> notexisting . write ( "<STR_LIT>" ) <EOL> assert self . root . join ( '<STR_LIT:hello>' ) . check ( versioned = <NUM_LIT:0> ) <EOL> finally : <EOL> notexisting . remove ( ) <EOL> def test_nonversioned_remove ( self ) : <EOL> assert self . root . check ( versioned = <NUM_LIT:1> ) <EOL> somefile = self . root . join ( '<STR_LIT>' ) <EOL> nonwc = py . path . local ( somefile ) <EOL> nonwc . ensure ( ) <EOL> assert somefile . check ( ) <EOL> assert not somefile . check ( versioned = True ) <EOL> somefile . remove ( ) <EOL> def test_properties ( self ) : <EOL> try : <EOL> self . root . propset ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert self . root . propget ( '<STR_LIT>' ) == '<STR_LIT>' <EOL> assert self . root . basename in [ item . basename for item in <EOL> self . root . status ( ) . prop_modified ] <EOL> assert '<STR_LIT>' in self . root . proplist ( ) <EOL> assert self . root . proplist ( ) [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> finally : <EOL> self . root . propdel ( '<STR_LIT>' ) <EOL> def test_proplist_recursive ( self ) : <EOL> s = self . root . join ( '<STR_LIT>' ) <EOL> s . propset ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> try : <EOL> p = self . root . proplist ( rec = <NUM_LIT:1> ) <EOL> assert ( self . root / '<STR_LIT>' ) . basename in [ item . basename <EOL> for item in p ] <EOL> finally : <EOL> s . propdel ( '<STR_LIT>' ) <EOL> def test_long_properties ( self ) : <EOL> value = """<STR_LIT>""" <EOL> try : <EOL> self . root . propset ( '<STR_LIT>' , value ) <EOL> backvalue = self . root . propget ( '<STR_LIT>' ) <EOL> assert backvalue == value <EOL> finally : <EOL> self . root . propdel ( '<STR_LIT>' ) <EOL> def test_ensure ( self ) : <EOL> newpath = self . root . ensure ( '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ) <EOL> try : <EOL> assert newpath . check ( exists = <NUM_LIT:1> , versioned = <NUM_LIT:1> ) <EOL> newpath . write ( "<STR_LIT:hello>" ) <EOL> newpath . ensure ( ) <EOL> assert newpath . read ( ) == "<STR_LIT:hello>" <EOL> finally : <EOL> self . root . join ( '<STR_LIT:a>' ) . remove ( force = <NUM_LIT:1> ) <EOL> def test_not_versioned ( self ) : <EOL> p = self . root . localpath . mkdir ( '<STR_LIT>' ) <EOL> f = self . root . localpath . ensure ( '<STR_LIT>' ) <EOL> try : <EOL> assert self . root . join ( '<STR_LIT>' ) . check ( versioned = <NUM_LIT:0> ) <EOL> assert self . root . join ( '<STR_LIT>' ) . check ( versioned = <NUM_LIT:0> ) <EOL> assert not self . root . join ( '<STR_LIT>' ) . check ( versioned = <NUM_LIT:1> ) <EOL> finally : <EOL> p . remove ( rec = <NUM_LIT:1> ) <EOL> f . remove ( ) <EOL> def test_lock_unlock ( self ) : <EOL> root = self . root <EOL> somefile = root . join ( '<STR_LIT>' ) <EOL> somefile . ensure ( file = True ) <EOL> py . test . raises ( py . process . cmdexec . Error , '<STR_LIT>' ) <EOL> somefile . write ( '<STR_LIT:foo>' ) <EOL> somefile . commit ( '<STR_LIT:test>' ) <EOL> assert somefile . check ( versioned = True ) <EOL> somefile . lock ( ) <EOL> try : <EOL> locked = root . status ( ) . locked <EOL> assert len ( locked ) == <NUM_LIT:1> <EOL> assert normpath ( str ( locked [ <NUM_LIT:0> ] ) ) == normpath ( str ( somefile ) ) <EOL> py . test . raises ( Exception , '<STR_LIT>' ) <EOL> finally : <EOL> somefile . unlock ( ) <EOL> locked = root . status ( ) . locked <EOL> assert locked == [ ] <EOL> py . test . raises ( Exception , '<STR_LIT>' ) <EOL> somefile . remove ( ) <EOL> def test_commit_nonrecursive ( self ) : <EOL> root = self . root <EOL> somedir = root . join ( '<STR_LIT>' ) <EOL> somedir . mkdir ( "<STR_LIT>" ) <EOL> somedir . propset ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) <EOL> status = somedir . status ( ) <EOL> assert len ( status . prop_modified ) == <NUM_LIT:1> <EOL> assert len ( status . added ) == <NUM_LIT:1> <EOL> somedir . commit ( '<STR_LIT>' , rec = <NUM_LIT:0> ) <EOL> status = somedir . status ( ) <EOL> assert len ( status . prop_modified ) == <NUM_LIT:0> <EOL> assert len ( status . added ) == <NUM_LIT:1> <EOL> somedir . commit ( '<STR_LIT>' ) <EOL> status = somedir . status ( ) <EOL> assert len ( status . prop_modified ) == <NUM_LIT:0> <EOL> assert len ( status . added ) == <NUM_LIT:0> <EOL> def test_commit_return_value ( self ) : <EOL> root = self . root <EOL> testfile = root . join ( '<STR_LIT>' ) . ensure ( file = True ) <EOL> testfile . write ( '<STR_LIT:test>' ) <EOL> rev = root . commit ( '<STR_LIT>' ) <EOL> assert type ( rev ) == int <EOL> anotherfile = root . join ( '<STR_LIT>' ) . ensure ( file = True ) <EOL> anotherfile . write ( '<STR_LIT:test>' ) <EOL> rev2 = root . commit ( '<STR_LIT>' ) <EOL> assert type ( rev2 ) == int <EOL> assert rev2 == rev + <NUM_LIT:1> <EOL> class XTestWCSvnCommandPathSpecial : <EOL> rooturl = '<STR_LIT>' <EOL> def test_parse_wcinfotime ( ) : <EOL> assert ( parse_wcinfotime ( '<STR_LIT>' ) == <EOL> <NUM_LIT> ) <EOL> assert ( parse_wcinfotime ( '<STR_LIT>' ) == <EOL> <NUM_LIT> ) <EOL> class TestInfoSvnWCCommand : <EOL> def test_svn_1_2 ( self ) : <EOL> output = """<STR_LIT>""" <EOL> path = py . magic . autopath ( ) . dirpath ( ) . chdir ( ) <EOL> info = InfoSvnWCCommand ( output ) <EOL> path . chdir ( ) <EOL> assert info . last_author == '<STR_LIT>' <EOL> assert info . kind == '<STR_LIT:file>' <EOL> assert info . mtime == <NUM_LIT> <EOL> assert info . url == '<STR_LIT>' <EOL> assert info . time == <NUM_LIT> <EOL> assert info . rev == <NUM_LIT> <EOL> def test_svn_1_3 ( self ) : <EOL> output = """<STR_LIT>""" <EOL> path = py . magic . autopath ( ) . dirpath ( ) . chdir ( ) <EOL> info = InfoSvnWCCommand ( output ) <EOL> path . chdir ( ) <EOL> assert info . last_author == '<STR_LIT>' <EOL> assert info . kind == '<STR_LIT:file>' <EOL> assert info . mtime == <NUM_LIT> <EOL> assert info . url == '<STR_LIT>' <EOL> assert info . rev == <NUM_LIT> <EOL> assert info . time == <NUM_LIT> <EOL> class TestWCSvnCommandPathEmptyRepo ( object ) : <EOL> def setup_class ( cls ) : <EOL> repo = py . test . ensuretemp ( "<STR_LIT>" ) <EOL> wcdir = py . test . ensuretemp ( "<STR_LIT>" ) <EOL> py . process . cmdexec ( '<STR_LIT>' % <EOL> svncommon . _escape_helper ( repo ) ) <EOL> wc = py . path . svnwc ( wcdir ) <EOL> repopath = repo . strpath <EOL> if py . std . sys . platform . startswith ( '<STR_LIT:win32>' ) : <EOL> repourl = '<STR_LIT>' % ( repopath . replace ( '<STR_LIT:\\>' , '<STR_LIT:/>' ) , ) <EOL> else : <EOL> repourl = '<STR_LIT>' % ( repopath , ) <EOL> wc . checkout ( url = repourl ) <EOL> cls . wc = wc <EOL> def test_info ( self ) : <EOL> self . wc . info ( ) . rev = <NUM_LIT:0> <EOL> def test_characters_at ( ) : <EOL> py . test . raises ( ValueError , "<STR_LIT>" ) <EOL> def test_characters_tilde ( ) : <EOL> py . path . svnwc ( '<STR_LIT>' ) </s>
