28
28
These are run by ``bzr.doctest``.
31
>>> from bzrlib import ScratchBranch
32
>>> from bzrlib.osutils import isdir, isfile
30
>>> import bzr, bzrlib, os
31
>>> bzrlib.commands.cmd_rocks()
34
Hey, nice place to begin.
34
36
The basic object is a Branch. We have a special helper class
35
37
ScratchBranch that automatically makes a directory and cleans itself
101
103
>>> r = b.get_revision(b.lookup_revision(1))
103
105
'start hello world'
104
>>> bzrlib.show_log(b, show_timezone='utc')
106
>>> b.write_log(show_timezone='utc')
105
107
----------------------------------------
107
109
committer: foo@nowhere
137
139
Tests for adding subdirectories, etc.
139
141
>>> b = bzrlib.branch.ScratchBranch()
140
>>> os.mkdir(b.abspath('d1'))
141
>>> os.mkdir(b.abspath('d2'))
142
>>> os.mkdir(b.abspath('d2/d3'))
142
>>> os.mkdir(b._rel('d1'))
143
>>> os.mkdir(b._rel('d2'))
144
>>> os.mkdir(b._rel('d2/d3'))
143
145
>>> list(b.working_tree().unknowns())
146
148
Create some files, but they're not seen as unknown yet:
148
>>> file(b.abspath('d1/f1'), 'w').close()
149
>>> file(b.abspath('d2/f2'), 'w').close()
150
>>> file(b.abspath('d2/f3'), 'w').close()
150
>>> file(b._rel('d1/f1'), 'w').close()
151
>>> file(b._rel('d2/f2'), 'w').close()
152
>>> file(b._rel('d2/f3'), 'w').close()
151
153
>>> [v[0] for v in b.inventory.directories()]
153
155
>>> list(b.working_tree().unknowns())
167
169
>>> list(b.working_tree().unknowns())
168
170
['d1/f1', 'd2/d3', 'd2/f2', 'd2/f3']
171
>>> list(b.working_tree().unknowns())
172
['d2/d3', 'd2/f2', 'd2/f3']
174
Tests for ignored files and patterns:
176
>>> b = ScratchBranch(dirs=['src', 'doc'],
177
... files=['configure.in', 'configure',
178
... 'doc/configure', 'foo.c',
180
>>> list(b.unknowns())
181
['configure', 'configure.in', 'doc', 'foo', 'foo.c', 'src']
182
>>> b.add(['doc', 'foo.c', 'src', 'configure.in'])
183
>>> list(b.unknowns())
184
['configure', 'foo', 'doc/configure']
185
>>> f = file(b.abspath('.bzrignore'), 'w')
186
>>> f.write('./configure\n'
189
>>> b.add('.bzrignore')
190
>>> list(b.unknowns())
192
>>> b.commit("commit 1")
193
>>> list(b.unknowns())
195
>>> b.add("doc/configure")
196
>>> b.commit("commit more")
201
>>> b = ScratchBranch(files=['foo'], dirs=['subdir'])
202
>>> b.add(['foo', 'subdir'])
203
>>> b.commit('add foo')
204
>>> list(b.unknowns())
206
>>> b.move(['foo'], 'subdir')
210
>>> b.commit("move foo to subdir")
211
>>> isfile(b.abspath('foo'))
213
>>> isfile(b.abspath('subdir/foo'))