/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/git/tree.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-12-18 19:51:52 UTC
  • mfrom: (7211.10.7 git-empty-dirs)
  • Revision ID: breezy.the.bot@gmail.com-20181218195152-h5q44t19jzlhqnl5
Don't list directories without versioned files as 'added'.

Merged from https://code.launchpad.net/~jelmer/brz/git-empty-dirs/+merge/359479

Show diffs side-by-side

added added

removed removed

Lines of Context:
679
679
    if target_extras is None:
680
680
        target_extras = set()
681
681
    ret = delta.TreeDelta()
 
682
    added = []
682
683
    for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
683
684
        if newpath == b'' and not include_root:
684
685
            continue
705
706
        if oldpath is None and newpath is None:
706
707
            continue
707
708
        if oldpath is None:
708
 
            if newpath in target_extras:
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)))
 
709
            added.append((newpath, mode_kind(newmode)))
716
710
        elif newpath is None or newmode == 0:
717
711
            file_id = old_fileid_map.lookup_file_id(oldpath_decoded)
718
712
            ret.removed.append((oldpath_decoded, file_id, mode_kind(oldmode)))
739
733
            ret.unchanged.append(
740
734
                (newpath_decoded, file_id, mode_kind(newmode)))
741
735
 
 
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
752
    return ret
743
753
 
744
754