Fix files from other changelists shown under "No Changelist" when filtering#45
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When filtering
git cl stby changelist name with--include-no-cl, files belonging to other (filtered-out) changelists were incorrectly listed under "No Changelist".For example, with
leak-a.txtinlist1andleak-b.txtinlist2:showed
leak-b.txtunder "No Changelist", even though it is assigned tolist2.Cause
clutil_show_active_changelistsonly recorded a file as assigned when its changelist was actually displayed. The bookkeeping that populatesassigned_filessat after theselected_namesfilter, so files in changelists that weren't shown never got recorded — and the "No Changelist" section, which lists everything not inassigned_files, then treated them as unassigned.The bug was not specific to untracked files: a tracked modification (
[ M]) in a filtered-out changelist leaked the same way. Untracked files just made it more noticeable.Fix
Move the
assigned_filesbookkeeping ahead of the display filter, so all assignments are recorded regardless of which changelists are shown. Display remains filtered; only the accounting is now complete.Test
Adds a regression test in
test_basic_add_status.pythat sets up two changelists, filters by one with--include-no-cl, and asserts that:[ M]and an untracked[??]) do not leak in.Verified failing against the previous code and passing with the fix.