~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-09 06:44:53 UTC
  • Revision ID: mbp@sourcefrog.net-20050309064453-60be0ae479d019b8
store committer's timezone in revision and show 
in changelog

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
These are run by ``bzr.doctest``.
29
29
 
30
 
>>> import bzrlib, os
31
 
>>> from bzrlib import ScratchBranch
32
 
>>> from bzrlib.osutils import isdir, isfile
33
 
>>> bzrlib.commands.cmd_rocks()
 
30
>>> import bzr, bzrlib, os
 
31
>>> bzr.cmd_rocks()
34
32
it sure does!
35
33
 
36
34
Hey, nice place to begin.
41
39
 
42
40
ScratchBranches are initially empty:
43
41
 
44
 
>>> b = bzrlib.ScratchBranch()
 
42
>>> b = bzr.ScratchBranch()
45
43
>>> b.show_status()
46
44
 
47
45
New files in that directory are, it is initially unknown:
105
103
  >>> r = b.get_revision(b.lookup_revision(1))
106
104
  >>> r.message
107
105
  'start hello world'
108
 
  >>> b.write_log(show_timezone='utc')
 
106
  >>> b.write_log(utc=True)
109
107
  ----------------------------------------
110
108
  revno: 1
111
109
  committer: foo@nowhere
112
 
  timestamp: Thu 1970-01-01 00:00:00 +0000
 
110
  timestamp: Thu 1970-01-01 00:00:00 UTC +0000
113
111
  message:
114
112
    start hello world
115
113
 
141
139
Tests for adding subdirectories, etc.
142
140
 
143
141
    >>> b = bzrlib.branch.ScratchBranch()
144
 
    >>> os.mkdir(b.abspath('d1'))
145
 
    >>> os.mkdir(b.abspath('d2'))
146
 
    >>> 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'))
147
145
    >>> list(b.working_tree().unknowns())
148
146
    ['d1', 'd2']
149
147
 
150
148
Create some files, but they're not seen as unknown yet:
151
149
 
152
 
    >>> file(b.abspath('d1/f1'), 'w').close()
153
 
    >>> file(b.abspath('d2/f2'), 'w').close()
154
 
    >>> 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()
155
153
    >>> [v[0] for v in b.inventory.directories()]
156
154
    ['']
157
155
    >>> list(b.working_tree().unknowns())
163
161
    >>> [v[0] for v in b.inventory.directories()]
164
162
    ['', 'd1']
165
163
    >>> list(b.working_tree().unknowns())
166
 
    ['d2', 'd1/f1']
 
164
    ['d1/f1', 'd2']
167
165
    >>> # d2 comes first because it's in the top directory
168
166
 
169
167
    >>> b.add('d2')
171
169
    >>> list(b.working_tree().unknowns())
172
170
    ['d1/f1', 'd2/d3', 'd2/f2', 'd2/f3']
173
171
 
174
 
    >>> b.add('d1/f1')
175
 
    >>> list(b.working_tree().unknowns())
176
 
    ['d2/d3', 'd2/f2', 'd2/f3']
177
 
 
178
 
Tests for ignored files and patterns:
179
 
 
180
 
    >>> b = ScratchBranch(dirs=['src', 'doc'],
181
 
    ...                   files=['configure.in', 'configure',
182
 
    ...                          'doc/configure', 'foo.c',
183
 
    ...                          'foo'])
184
 
    >>> list(b.unknowns())
185
 
    ['configure', 'configure.in', 'doc', 'foo', 'foo.c', 'src']
186
 
    >>> b.add(['doc', 'foo.c', 'src', 'configure.in'])
187
 
    >>> list(b.unknowns())
188
 
    ['configure', 'foo', 'doc/configure']
189
 
    >>> f = file(b.abspath('.bzrignore'), 'w')
190
 
    >>> f.write('./configure\n'
191
 
    ...         './foo\n')
192
 
    >>> f.close()
193
 
    >>> b.add('.bzrignore')
194
 
    >>> list(b.unknowns())
195
 
    ['doc/configure']
196
 
    >>> b.commit("commit 1")
197
 
    >>> list(b.unknowns())
198
 
    ['doc/configure']
199
 
    >>> b.add("doc/configure")
200
 
    >>> b.commit("commit more")
201
 
    >>> del b
202
 
 
203
 
Renames, etc:
204
 
 
205
 
    >>> b = ScratchBranch(files=['foo'], dirs=['subdir'])
206
 
    >>> b.add(['foo', 'subdir'])
207
 
    >>> b.commit('add foo')
208
 
    >>> list(b.unknowns())
209
 
    []
210
 
    >>> b.move(['foo'], 'subdir')
211
 
    foo => subdir/foo
212
 
    >>> b.show_status()
213
 
    R       foo => subdir/foo
214
 
    >>> bzrlib.commands.cmd_renames(b.base)
215
 
    foo => subdir/foo
216
 
    >>> b.commit("move foo to subdir")
217
 
    >>> isfile(b.abspath('foo'))
218
 
    False
219
 
    >>> isfile(b.abspath('subdir/foo'))
220
 
    True
221
 
 
222
172
"""