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
1=== modified file 'bzrlib/delta.py'
2--- bzrlib/delta.py 2010-04-30 11:35:43 +0000
3+++ bzrlib/delta.py 2010-10-20 15:03:47 +0000
4@@ -61,6 +61,7 @@
5 self.modified = []
6 self.unchanged = []
7 self.unversioned = []
8+ self.missing = []
9
10 def __eq__(self, other):
11 if not isinstance(other, TreeDelta):
12@@ -137,7 +138,7 @@
13 else:
14 delta.removed.append((path[0], file_id, kind[0]))
15 elif fully_present[0] is False:
16- continue
17+ delta.missing.append((path[1], file_id, kind[1]))
18 elif name[0] != name[1] or parent_id[0] != parent_id[1]:
19 # If the name changes, or the parent_id changes, we have a rename
20 # (if we move a parent, that doesn't count as a rename for the
21@@ -160,6 +161,7 @@
22 delta.removed.sort()
23 delta.added.sort()
24 delta.renamed.sort()
25+ delta.missing.sort()
26 # TODO: jam 20060529 These lists shouldn't need to be sorted
27 # since we added them in alphabetical order.
28 delta.modified.sort()
29@@ -202,7 +204,9 @@
30 'unchanged': ' ',
31 'created': 'N',
32 'modified': 'M',
33- 'deleted': 'D'}
34+ 'deleted': 'D',
35+ 'missing': '!',
36+ }
37 self.versioned_map = {'added': '+', # versioned target
38 'unchanged': ' ', # versioned in both
39 'removed': '-', # versioned in source
40@@ -325,6 +329,8 @@
41 else:
42 if content_change:
43 modified = "modified"
44+ elif kind[0] is None:
45+ modified = "missing"
46 else:
47 modified = "unchanged"
48 if kind[1] == "file":
49@@ -417,6 +423,7 @@
50
51 show_list(delta.removed, 'removed', 'D')
52 show_list(delta.added, 'added', 'A')
53+ show_list(delta.missing, 'missing', '!')
54 extra_modified = []
55 # Reorder delta.renamed tuples so that all lists share the same
56 # order for their 3 first fields and that they also begin like
57
58=== modified file 'bzrlib/tests/blackbox/test_status.py'
59--- bzrlib/tests/blackbox/test_status.py 2010-10-18 21:34:05 +0000
60+++ bzrlib/tests/blackbox/test_status.py 2010-10-20 15:03:47 +0000
61@@ -211,12 +211,18 @@
62 wt = self.make_branch_and_tree('.')
63 b = wt.branch
64
65- self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
66+ self.build_tree(['directory/','directory/hello.c',
67+ 'bye.c','test.c','dir2/',
68+ 'missing.c'])
69 wt.add('directory')
70 wt.add('test.c')
71 wt.commit('testing')
72+ wt.add('missing.c')
73+ unlink('missing.c')
74
75 self.assertStatus([
76+ 'missing:\n',
77+ ' missing.c\n',
78 'unknown:\n',
79 ' bye.c\n',
80 ' dir2/\n',
81@@ -227,6 +233,7 @@
82 self.assertStatus([
83 '? bye.c\n',
84 '? dir2/\n',
85+ '+! missing.c\n',
86 '? directory/hello.c\n'
87 ],
88 wt, short=True)
89@@ -269,6 +276,20 @@
90 tof.seek(0)
91 self.assertEquals(tof.readlines(), ['+N test.c\n'])
92
93+ tof = StringIO()
94+ show_tree_status(wt, specific_files=['missing.c'], to_file=tof)
95+ tof.seek(0)
96+ self.assertEquals(tof.readlines(),
97+ ['missing:\n',
98+ ' missing.c\n'])
99+
100+ tof = StringIO()
101+ show_tree_status(wt, specific_files=['missing.c'], to_file=tof,
102+ short=True)
103+ tof.seek(0)
104+ self.assertEquals(tof.readlines(),
105+ ['+! missing.c\n'])
106+
107 def test_specific_files_conflicts(self):
108 tree = self.make_branch_and_tree('.')
109 self.build_tree(['dir2/'])
110
111=== modified file 'bzrlib/tests/test_delta.py'
112--- bzrlib/tests/test_delta.py 2010-10-08 05:36:17 +0000
113+++ bzrlib/tests/test_delta.py 2010-10-20 15:03:47 +0000
114@@ -122,6 +122,12 @@
115 renamed=False, modified='created', exe_change=False,
116 kind=(None, 'file'), unversioned_filter=lambda x:True)
117
118+ def test_missing(self):
119+ self.assertReport('+! missing.c', file_id=None, path='missing.c',
120+ old_path=None, versioned_change='added',
121+ renamed=False, modified='missing', exe_change=False,
122+ kind=(None, None))
123+
124 def test_view_filtering(self):
125 # If a file in within the view, it should appear in the output
126 expected_lines = [
127@@ -279,24 +285,32 @@
128 ('branch/f2', '2\n'),
129 ('branch/f3', '3\n'),
130 ('branch/f4', '4\n'),
131+ ('branch/f5', '5\n'),
132 ('branch/dir/',),
133 ])
134 wt.add(['f1', 'f2', 'f3', 'f4', 'dir'],
135 ['f1-id', 'f2-id', 'f3-id', 'f4-id', 'dir-id'])
136 wt.commit('commit one', rev_id='1')
137
138+ # TODO add rename,removed,etc. here?
139+ wt.add('f5')
140+ os.unlink('branch/f5')
141+
142 long_status = """added:
143 dir/
144 f1
145 f2
146 f3
147 f4
148+missing:
149+ f5
150 """
151 short_status = """A dir/
152 A f1
153 A f2
154 A f3
155 A f4
156+! f5
157 """
158
159 repo = wt.branch.repository
160
161=== modified file 'doc/en/release-notes/bzr-2.3.txt'
162--- doc/en/release-notes/bzr-2.3.txt 2010-10-18 21:34:05 +0000
163+++ doc/en/release-notes/bzr-2.3.txt 2010-10-20 15:03:47 +0000
164@@ -58,6 +58,9 @@
165
166 * Make ``bzr tag --quiet`` really quiet. (Neil Martinsen-Burrell, #239523)
167
168+* Missing files (files bzr add'ed and then OS deleted) are now shown in ``bzr
169+ status`` output. (Rory Yorke, #134168)
170+
171 Documentation
172 *************
173