Merge lp:~ryorke/bzr/134168-status-wont-show-missing-files into lp:bzr

Proposed by Rory Yorke
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 5519
Proposed branch: lp:~ryorke/bzr/134168-status-wont-show-missing-files
Merge into: lp:bzr
Diff against target: 172 lines (+48/-3)
4 files modified
bzrlib/delta.py (+9/-2)
bzrlib/tests/blackbox/test_status.py (+22/-1)
bzrlib/tests/test_delta.py (+14/-0)
doc/en/release-notes/bzr-2.3.txt (+3/-0)
To merge this branch: bzr merge lp:~ryorke/bzr/134168-status-wont-show-missing-files
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+38942@code.launchpad.net

Commit message

status shows missing newly-added files

Description of the change

bzr status now shows missing files.

The particular manifestation of this bug that got me was:

  rory@rory-laptop:~/tmp/bzr/g$ bzr push
  Working tree "/home/rory/tmp/bzr/g/" has uncommitted changes (See bzr status). Uncommitted changes will not be pushed.
  Using saved push location: /home/rory/tmp/bzr/f/
  No new revisions to push.
  rory@rory-laptop:~/tmp/bzr/g$ bzr st
  rory@rory-laptop:~/tmp/bzr/g$

i.e., push told me to see status, and status told me nothing.

The changes have been made in bzrlib.delta, which seems to do the actual work
of status reporting. In particular I changed delta.report_changes and
delta.report_delta; the former's used short reporting, the latter in long
reports, though there seems to be overlap in them.

I've added tests to blackbox.test_status and test_delta.

It looks to me like there's room for more tests of delta.report_delta, as
marked at TODO.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

That looks really nice. Thanks, and sorry for the review delay.

review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/delta.py'
--- bzrlib/delta.py 2010-04-30 11:35:43 +0000
+++ bzrlib/delta.py 2010-10-20 15:03:47 +0000
@@ -61,6 +61,7 @@
61 self.modified = []61 self.modified = []
62 self.unchanged = []62 self.unchanged = []
63 self.unversioned = []63 self.unversioned = []
64 self.missing = []
6465
65 def __eq__(self, other):66 def __eq__(self, other):
66 if not isinstance(other, TreeDelta):67 if not isinstance(other, TreeDelta):
@@ -137,7 +138,7 @@
137 else:138 else:
138 delta.removed.append((path[0], file_id, kind[0]))139 delta.removed.append((path[0], file_id, kind[0]))
139 elif fully_present[0] is False:140 elif fully_present[0] is False:
140 continue141 delta.missing.append((path[1], file_id, kind[1]))
141 elif name[0] != name[1] or parent_id[0] != parent_id[1]:142 elif name[0] != name[1] or parent_id[0] != parent_id[1]:
142 # If the name changes, or the parent_id changes, we have a rename143 # If the name changes, or the parent_id changes, we have a rename
143 # (if we move a parent, that doesn't count as a rename for the144 # (if we move a parent, that doesn't count as a rename for the
@@ -160,6 +161,7 @@
160 delta.removed.sort()161 delta.removed.sort()
161 delta.added.sort()162 delta.added.sort()
162 delta.renamed.sort()163 delta.renamed.sort()
164 delta.missing.sort()
163 # TODO: jam 20060529 These lists shouldn't need to be sorted165 # TODO: jam 20060529 These lists shouldn't need to be sorted
164 # since we added them in alphabetical order.166 # since we added them in alphabetical order.
165 delta.modified.sort()167 delta.modified.sort()
@@ -202,7 +204,9 @@
202 'unchanged': ' ',204 'unchanged': ' ',
203 'created': 'N',205 'created': 'N',
204 'modified': 'M',206 'modified': 'M',
205 'deleted': 'D'}207 'deleted': 'D',
208 'missing': '!',
209 }
206 self.versioned_map = {'added': '+', # versioned target210 self.versioned_map = {'added': '+', # versioned target
207 'unchanged': ' ', # versioned in both211 'unchanged': ' ', # versioned in both
208 'removed': '-', # versioned in source212 'removed': '-', # versioned in source
@@ -325,6 +329,8 @@
325 else:329 else:
326 if content_change:330 if content_change:
327 modified = "modified"331 modified = "modified"
332 elif kind[0] is None:
333 modified = "missing"
328 else:334 else:
329 modified = "unchanged"335 modified = "unchanged"
330 if kind[1] == "file":336 if kind[1] == "file":
@@ -417,6 +423,7 @@
417423
418 show_list(delta.removed, 'removed', 'D')424 show_list(delta.removed, 'removed', 'D')
419 show_list(delta.added, 'added', 'A')425 show_list(delta.added, 'added', 'A')
426 show_list(delta.missing, 'missing', '!')
420 extra_modified = []427 extra_modified = []
421 # Reorder delta.renamed tuples so that all lists share the same428 # Reorder delta.renamed tuples so that all lists share the same
422 # order for their 3 first fields and that they also begin like429 # order for their 3 first fields and that they also begin like
423430
=== modified file 'bzrlib/tests/blackbox/test_status.py'
--- bzrlib/tests/blackbox/test_status.py 2010-10-18 21:34:05 +0000
+++ bzrlib/tests/blackbox/test_status.py 2010-10-20 15:03:47 +0000
@@ -211,12 +211,18 @@
211 wt = self.make_branch_and_tree('.')211 wt = self.make_branch_and_tree('.')
212 b = wt.branch212 b = wt.branch
213213
214 self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])214 self.build_tree(['directory/','directory/hello.c',
215 'bye.c','test.c','dir2/',
216 'missing.c'])
215 wt.add('directory')217 wt.add('directory')
216 wt.add('test.c')218 wt.add('test.c')
217 wt.commit('testing')219 wt.commit('testing')
220 wt.add('missing.c')
221 unlink('missing.c')
218222
219 self.assertStatus([223 self.assertStatus([
224 'missing:\n',
225 ' missing.c\n',
220 'unknown:\n',226 'unknown:\n',
221 ' bye.c\n',227 ' bye.c\n',
222 ' dir2/\n',228 ' dir2/\n',
@@ -227,6 +233,7 @@
227 self.assertStatus([233 self.assertStatus([
228 '? bye.c\n',234 '? bye.c\n',
229 '? dir2/\n',235 '? dir2/\n',
236 '+! missing.c\n',
230 '? directory/hello.c\n'237 '? directory/hello.c\n'
231 ],238 ],
232 wt, short=True)239 wt, short=True)
@@ -269,6 +276,20 @@
269 tof.seek(0)276 tof.seek(0)
270 self.assertEquals(tof.readlines(), ['+N test.c\n'])277 self.assertEquals(tof.readlines(), ['+N test.c\n'])
271278
279 tof = StringIO()
280 show_tree_status(wt, specific_files=['missing.c'], to_file=tof)
281 tof.seek(0)
282 self.assertEquals(tof.readlines(),
283 ['missing:\n',
284 ' missing.c\n'])
285
286 tof = StringIO()
287 show_tree_status(wt, specific_files=['missing.c'], to_file=tof,
288 short=True)
289 tof.seek(0)
290 self.assertEquals(tof.readlines(),
291 ['+! missing.c\n'])
292
272 def test_specific_files_conflicts(self):293 def test_specific_files_conflicts(self):
273 tree = self.make_branch_and_tree('.')294 tree = self.make_branch_and_tree('.')
274 self.build_tree(['dir2/'])295 self.build_tree(['dir2/'])
275296
=== modified file 'bzrlib/tests/test_delta.py'
--- bzrlib/tests/test_delta.py 2010-10-08 05:36:17 +0000
+++ bzrlib/tests/test_delta.py 2010-10-20 15:03:47 +0000
@@ -122,6 +122,12 @@
122 renamed=False, modified='created', exe_change=False,122 renamed=False, modified='created', exe_change=False,
123 kind=(None, 'file'), unversioned_filter=lambda x:True)123 kind=(None, 'file'), unversioned_filter=lambda x:True)
124124
125 def test_missing(self):
126 self.assertReport('+! missing.c', file_id=None, path='missing.c',
127 old_path=None, versioned_change='added',
128 renamed=False, modified='missing', exe_change=False,
129 kind=(None, None))
130
125 def test_view_filtering(self):131 def test_view_filtering(self):
126 # If a file in within the view, it should appear in the output132 # If a file in within the view, it should appear in the output
127 expected_lines = [133 expected_lines = [
@@ -279,24 +285,32 @@
279 ('branch/f2', '2\n'),285 ('branch/f2', '2\n'),
280 ('branch/f3', '3\n'),286 ('branch/f3', '3\n'),
281 ('branch/f4', '4\n'),287 ('branch/f4', '4\n'),
288 ('branch/f5', '5\n'),
282 ('branch/dir/',),289 ('branch/dir/',),
283 ])290 ])
284 wt.add(['f1', 'f2', 'f3', 'f4', 'dir'],291 wt.add(['f1', 'f2', 'f3', 'f4', 'dir'],
285 ['f1-id', 'f2-id', 'f3-id', 'f4-id', 'dir-id'])292 ['f1-id', 'f2-id', 'f3-id', 'f4-id', 'dir-id'])
286 wt.commit('commit one', rev_id='1')293 wt.commit('commit one', rev_id='1')
287294
295 # TODO add rename,removed,etc. here?
296 wt.add('f5')
297 os.unlink('branch/f5')
298
288 long_status = """added:299 long_status = """added:
289 dir/300 dir/
290 f1301 f1
291 f2302 f2
292 f3303 f3
293 f4304 f4
305missing:
306 f5
294"""307"""
295 short_status = """A dir/308 short_status = """A dir/
296A f1309A f1
297A f2310A f2
298A f3311A f3
299A f4312A f4
313! f5
300"""314"""
301315
302 repo = wt.branch.repository316 repo = wt.branch.repository
303317
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- doc/en/release-notes/bzr-2.3.txt 2010-10-18 21:34:05 +0000
+++ doc/en/release-notes/bzr-2.3.txt 2010-10-20 15:03:47 +0000
@@ -58,6 +58,9 @@
5858
59* Make ``bzr tag --quiet`` really quiet. (Neil Martinsen-Burrell, #239523)59* Make ``bzr tag --quiet`` really quiet. (Neil Martinsen-Burrell, #239523)
6060
61* Missing files (files bzr add'ed and then OS deleted) are now shown in ``bzr
62 status`` output. (Rory Yorke, #134168)
63
61Documentation64Documentation
62*************65*************
6366