Merge lp:~jelmer/brz/git-empty-dirs into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/git-empty-dirs
Merge into: lp:brz
Diff against target: 124 lines (+42/-16)
3 files modified
breezy/git/tests/test_blackbox.py (+13/-0)
breezy/git/tree.py (+18/-8)
breezy/status.py (+11/-8)
To merge this branch: bzr merge lp:~jelmer/brz/git-empty-dirs
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+359479@code.launchpad.net

Commit message

Don't list directories without versioned files as 'added'.

Description of the change

Don't list directories without versioned files as 'added'.

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

Changes here look reasonable but are on top of the 3.7 branch so be careful in landing.

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/tests/test_blackbox.py'
2--- breezy/git/tests/test_blackbox.py 2018-11-24 15:44:03 +0000
3+++ breezy/git/tests/test_blackbox.py 2018-12-11 17:32:57 +0000
4@@ -390,6 +390,19 @@
5 self.assertEqual(error, '')
6
7
8+class StatusTests(ExternalBase):
9+
10+ def test_empty_dir(self):
11+ tree = self.make_branch_and_tree('.', format='git')
12+ self.build_tree(['a/', 'a/foo'])
13+ self.build_tree_contents([('.gitignore', 'foo\n')])
14+ tree.add(['.gitignore'])
15+ tree.commit('add ignore')
16+ output, error = self.run_bzr('st')
17+ self.assertEqual(output, '')
18+ self.assertEqual(error, '')
19+
20+
21 class StatsTests(ExternalBase):
22
23 def test_simple_stats(self):
24
25=== modified file 'breezy/git/tree.py'
26--- breezy/git/tree.py 2018-11-22 03:51:03 +0000
27+++ breezy/git/tree.py 2018-12-11 17:32:57 +0000
28@@ -679,6 +679,7 @@
29 if target_extras is None:
30 target_extras = set()
31 ret = delta.TreeDelta()
32+ added = []
33 for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
34 if newpath == b'' and not include_root:
35 continue
36@@ -705,14 +706,7 @@
37 if oldpath is None and newpath is None:
38 continue
39 if oldpath is None:
40- if newpath in target_extras:
41- ret.unversioned.append(
42- (osutils.normalized_filename(newpath)[0], None,
43- mode_kind(newmode)))
44- else:
45- file_id = new_fileid_map.lookup_file_id(newpath_decoded)
46- ret.added.append(
47- (newpath_decoded, file_id, mode_kind(newmode)))
48+ added.append((newpath, mode_kind(newmode)))
49 elif newpath is None or newmode == 0:
50 file_id = old_fileid_map.lookup_file_id(oldpath_decoded)
51 ret.removed.append((oldpath_decoded, file_id, mode_kind(oldmode)))
52@@ -739,6 +733,22 @@
53 ret.unchanged.append(
54 (newpath_decoded, file_id, mode_kind(newmode)))
55
56+ implicit_dirs = {b''}
57+ for path, kind in added:
58+ if kind == 'directory' or path in target_extras:
59+ continue
60+ implicit_dirs.update(osutils.parent_directories(path))
61+
62+ for path, kind in added:
63+ if kind == 'directory' and path not in implicit_dirs:
64+ continue
65+ path_decoded = osutils.normalized_filename(path)[0]
66+ if path in target_extras:
67+ ret.unversioned.append((path_decoded, None, kind))
68+ else:
69+ file_id = new_fileid_map.lookup_file_id(path_decoded)
70+ ret.added.append((path_decoded, file_id, kind))
71+
72 return ret
73
74
75
76=== modified file 'breezy/status.py'
77--- breezy/status.py 2018-11-17 16:53:10 +0000
78+++ breezy/status.py 2018-12-11 17:32:57 +0000
79@@ -150,16 +150,18 @@
80 new = wt
81 with old.lock_read(), new.lock_read():
82 for hook in hooks['pre_status']:
83- hook(StatusHookParams(old, new, to_file, versioned,
84- show_ids, short, verbose, specific_files=specific_files))
85+ hook(StatusHookParams(
86+ old, new, to_file, versioned, show_ids, short, verbose,
87+ specific_files=specific_files))
88
89 specific_files, nonexistents \
90 = _filter_nonexistent(specific_files, old, new)
91 want_unversioned = not versioned
92
93 # Reporter used for short outputs
94- reporter = _mod_delta._ChangeReporter(output_file=to_file,
95- unversioned_filter=new.is_ignored, classify=classify)
96+ reporter = _mod_delta._ChangeReporter(
97+ output_file=to_file, unversioned_filter=new.is_ignored,
98+ classify=classify)
99 report_changes(to_file, old, new, specific_files,
100 reporter, show_long_callback,
101 short=short, want_unversioned=want_unversioned,
102@@ -183,8 +185,8 @@
103 # delta.
104 conflicts = new.conflicts()
105 if specific_files is not None:
106- conflicts = conflicts.select_conflicts(new, specific_files,
107- ignore_misses=True, recurse=True)[1]
108+ conflicts = conflicts.select_conflicts(
109+ new, specific_files, ignore_misses=True, recurse=True)[1]
110 if len(conflicts) > 0 and not short:
111 to_file.write("conflicts:\n")
112 for conflict in conflicts:
113@@ -214,8 +216,9 @@
114 if nonexistents:
115 raise errors.PathsDoNotExist(nonexistents)
116 for hook in hooks['post_status']:
117- hook(StatusHookParams(old, new, to_file, versioned,
118- show_ids, short, verbose, specific_files=specific_files))
119+ hook(StatusHookParams(
120+ old, new, to_file, versioned, show_ids, short, verbose,
121+ specific_files=specific_files))
122
123
124 def _get_sorted_revisions(tip_revision, revision_ids, parent_map):

Subscribers

People subscribed via source and target branches