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
=== modified file 'breezy/git/tests/test_blackbox.py'
--- breezy/git/tests/test_blackbox.py 2018-11-24 15:44:03 +0000
+++ breezy/git/tests/test_blackbox.py 2018-12-11 17:32:57 +0000
@@ -390,6 +390,19 @@
390 self.assertEqual(error, '')390 self.assertEqual(error, '')
391391
392392
393class StatusTests(ExternalBase):
394
395 def test_empty_dir(self):
396 tree = self.make_branch_and_tree('.', format='git')
397 self.build_tree(['a/', 'a/foo'])
398 self.build_tree_contents([('.gitignore', 'foo\n')])
399 tree.add(['.gitignore'])
400 tree.commit('add ignore')
401 output, error = self.run_bzr('st')
402 self.assertEqual(output, '')
403 self.assertEqual(error, '')
404
405
393class StatsTests(ExternalBase):406class StatsTests(ExternalBase):
394407
395 def test_simple_stats(self):408 def test_simple_stats(self):
396409
=== modified file 'breezy/git/tree.py'
--- breezy/git/tree.py 2018-11-22 03:51:03 +0000
+++ breezy/git/tree.py 2018-12-11 17:32:57 +0000
@@ -679,6 +679,7 @@
679 if target_extras is None:679 if target_extras is None:
680 target_extras = set()680 target_extras = set()
681 ret = delta.TreeDelta()681 ret = delta.TreeDelta()
682 added = []
682 for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:683 for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
683 if newpath == b'' and not include_root:684 if newpath == b'' and not include_root:
684 continue685 continue
@@ -705,14 +706,7 @@
705 if oldpath is None and newpath is None:706 if oldpath is None and newpath is None:
706 continue707 continue
707 if oldpath is None:708 if oldpath is None:
708 if newpath in target_extras:709 added.append((newpath, mode_kind(newmode)))
709 ret.unversioned.append(
710 (osutils.normalized_filename(newpath)[0], None,
711 mode_kind(newmode)))
712 else:
713 file_id = new_fileid_map.lookup_file_id(newpath_decoded)
714 ret.added.append(
715 (newpath_decoded, file_id, mode_kind(newmode)))
716 elif newpath is None or newmode == 0:710 elif newpath is None or newmode == 0:
717 file_id = old_fileid_map.lookup_file_id(oldpath_decoded)711 file_id = old_fileid_map.lookup_file_id(oldpath_decoded)
718 ret.removed.append((oldpath_decoded, file_id, mode_kind(oldmode)))712 ret.removed.append((oldpath_decoded, file_id, mode_kind(oldmode)))
@@ -739,6 +733,22 @@
739 ret.unchanged.append(733 ret.unchanged.append(
740 (newpath_decoded, file_id, mode_kind(newmode)))734 (newpath_decoded, file_id, mode_kind(newmode)))
741735
736 implicit_dirs = {b''}
737 for path, kind in added:
738 if kind == 'directory' or path in target_extras:
739 continue
740 implicit_dirs.update(osutils.parent_directories(path))
741
742 for path, kind in added:
743 if kind == 'directory' and path not in implicit_dirs:
744 continue
745 path_decoded = osutils.normalized_filename(path)[0]
746 if path in target_extras:
747 ret.unversioned.append((path_decoded, None, kind))
748 else:
749 file_id = new_fileid_map.lookup_file_id(path_decoded)
750 ret.added.append((path_decoded, file_id, kind))
751
742 return ret752 return ret
743753
744754
745755
=== modified file 'breezy/status.py'
--- breezy/status.py 2018-11-17 16:53:10 +0000
+++ breezy/status.py 2018-12-11 17:32:57 +0000
@@ -150,16 +150,18 @@
150 new = wt150 new = wt
151 with old.lock_read(), new.lock_read():151 with old.lock_read(), new.lock_read():
152 for hook in hooks['pre_status']:152 for hook in hooks['pre_status']:
153 hook(StatusHookParams(old, new, to_file, versioned,153 hook(StatusHookParams(
154 show_ids, short, verbose, specific_files=specific_files))154 old, new, to_file, versioned, show_ids, short, verbose,
155 specific_files=specific_files))
155156
156 specific_files, nonexistents \157 specific_files, nonexistents \
157 = _filter_nonexistent(specific_files, old, new)158 = _filter_nonexistent(specific_files, old, new)
158 want_unversioned = not versioned159 want_unversioned = not versioned
159160
160 # Reporter used for short outputs161 # Reporter used for short outputs
161 reporter = _mod_delta._ChangeReporter(output_file=to_file,162 reporter = _mod_delta._ChangeReporter(
162 unversioned_filter=new.is_ignored, classify=classify)163 output_file=to_file, unversioned_filter=new.is_ignored,
164 classify=classify)
163 report_changes(to_file, old, new, specific_files,165 report_changes(to_file, old, new, specific_files,
164 reporter, show_long_callback,166 reporter, show_long_callback,
165 short=short, want_unversioned=want_unversioned,167 short=short, want_unversioned=want_unversioned,
@@ -183,8 +185,8 @@
183 # delta.185 # delta.
184 conflicts = new.conflicts()186 conflicts = new.conflicts()
185 if specific_files is not None:187 if specific_files is not None:
186 conflicts = conflicts.select_conflicts(new, specific_files,188 conflicts = conflicts.select_conflicts(
187 ignore_misses=True, recurse=True)[1]189 new, specific_files, ignore_misses=True, recurse=True)[1]
188 if len(conflicts) > 0 and not short:190 if len(conflicts) > 0 and not short:
189 to_file.write("conflicts:\n")191 to_file.write("conflicts:\n")
190 for conflict in conflicts:192 for conflict in conflicts:
@@ -214,8 +216,9 @@
214 if nonexistents:216 if nonexistents:
215 raise errors.PathsDoNotExist(nonexistents)217 raise errors.PathsDoNotExist(nonexistents)
216 for hook in hooks['post_status']:218 for hook in hooks['post_status']:
217 hook(StatusHookParams(old, new, to_file, versioned,219 hook(StatusHookParams(
218 show_ids, short, verbose, specific_files=specific_files))220 old, new, to_file, versioned, show_ids, short, verbose,
221 specific_files=specific_files))
219222
220223
221def _get_sorted_revisions(tip_revision, revision_ids, parent_map):224def _get_sorted_revisions(tip_revision, revision_ids, parent_map):

Subscribers

People subscribed via source and target branches