Skip to content

Commit 651d23f

Browse files
committed
Merge branch 'more-misc-refactorings'
This commit merges in a *lot* of refactoring work done to the tree, details, and grid-details views. The main one is that the concept of a “table” has been completely separated from the details view. Previously, if you wanted to use the long view without drawing the table (such as with --tree), exa used a “table” with 0 columns in it behind the scenes. This is now reversed: the table is now the optional component in the details view, and a tree-only view is just a details view without a table! Doing this has paved the way for all sorts of code cleanups: now, we only calculate values needed for the table if one’s going to be displayed. Some of these were rather expensive to compute (such as the user’s time zone, or locale) This refactoring is not fully complete; there are still several things that can be done, including having the errors and xattrs in the tree view use the same TreeParams constructor as the others, and separating the column widths from the table so fewer mutable values need to be passed around. Finally, this also merges in a lot of debuffering. There were at least two places in the code where values were collected into a vector before immediately being iterated over, instead of just using those values as they were generated! For example, when displaying the table, each row was rendered into a set of cells for displaying: but then it all went into a vector, and was only displayed at the very end, because that was what I needed for the grid-details view. Now, exa is smart enough to not do that. Basically, even if exa doesn’t actually *get* that much faster, it should at least display its first line of output quicker. Fixes ogham#90, but also see ogham#82.
2 parents 22c6fb0 + f4ddbf3 commit 651d23f

File tree

11 files changed

+744
-473
lines changed

11 files changed

+744
-473
lines changed

Vagrantfile

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -295,45 +295,73 @@ Vagrant.configure(2) do |config|
295295
296296
EOF
297297

298+
old = '200303030000.00'
299+
med = '200606152314.29'
300+
new = '200907221038.53'
301+
302+
# Awkward date and time testcases.
303+
config.vm.provision :shell, privileged: false, inline: <<-EOF
304+
set -xe
305+
mkdir "#{test_dir}/dates"
306+
307+
# there's no way to touch the created date of a file...
308+
# so we have to do this the old-fashioned way!
309+
# (and make sure these don't actually get listed)
310+
touch -t #{old} "#{test_dir}/dates/peach"; sleep 1
311+
touch -t #{med} "#{test_dir}/dates/plum"; sleep 1
312+
touch -t #{new} "#{test_dir}/dates/pear"
313+
314+
# modified dates
315+
touch -t #{old} -m "#{test_dir}/dates/pear"
316+
touch -t #{med} -m "#{test_dir}/dates/peach"
317+
touch -t #{new} -m "#{test_dir}/dates/plum"
318+
319+
# accessed dates
320+
touch -t #{old} -a "#{test_dir}/dates/plum"
321+
touch -t #{med} -a "#{test_dir}/dates/pear"
322+
touch -t #{new} -a "#{test_dir}/dates/peach"
323+
EOF
324+
298325

299326
# Awkward extended attribute testcases.
327+
# We need to test combinations of various numbers of files *and*
328+
# extended attributes in directories. Turns out, the easiest way to
329+
# do this is to generate all combinations of files with “one-xattr”
330+
# or “two-xattrs” in their name and directories with “empty” or
331+
# “one-file” in their name, then just give the right number of
332+
# xattrs and children to those.
300333
config.vm.provision :shell, privileged: false, inline: <<-EOF
301334
set -xe
302335
mkdir "#{test_dir}/attributes"
303336
304-
touch "#{test_dir}/attributes/none"
305-
306-
touch "#{test_dir}/attributes/one"
307-
setfattr -n user.greeting -v hello "#{test_dir}/attributes/one"
308-
309-
touch "#{test_dir}/attributes/two"
310-
setfattr -n user.greeting -v hello "#{test_dir}/attributes/two"
311-
setfattr -n user.another_greeting -v hi "#{test_dir}/attributes/two"
312-
313-
#touch "#{test_dir}/attributes/forbidden"
314-
#setfattr -n user.greeting -v hello "#{test_dir}/attributes/forbidden"
315-
#chmod +a "$YOU deny readextattr" "#{test_dir}/attributes/forbidden"
337+
mkdir "#{test_dir}/attributes/files"
338+
touch "#{test_dir}/attributes/files/"{no-xattrs,one-xattr,two-xattrs}{,_forbidden}
316339
317340
mkdir "#{test_dir}/attributes/dirs"
341+
mkdir "#{test_dir}/attributes/dirs/"{no-xattrs,one-xattr,two-xattrs}_{empty,one-file,two-files}{,_forbidden}
318342
319-
mkdir "#{test_dir}/attributes/dirs/empty-with-attribute"
320-
setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/empty-with-attribute"
343+
setfattr -n user.greeting -v hello "#{test_dir}/attributes"/**/*{one-xattr,two-xattrs}*
344+
setfattr -n user.another_greeting -v hi "#{test_dir}/attributes"/**/*two-xattrs*
321345
322-
mkdir "#{test_dir}/attributes/dirs/full-with-attribute"
323-
touch "#{test_dir}/attributes/dirs/full-with-attribute/file"
324-
setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/full-with-attribute"
346+
for dir in "#{test_dir}/attributes/dirs/"*one-file*; do
347+
touch $dir/file-in-question
348+
done
349+
350+
for dir in "#{test_dir}/attributes/dirs/"*two-files*; do
351+
touch $dir/this-file
352+
touch $dir/that-file
353+
done
325354
326-
mkdir "#{test_dir}/attributes/dirs/full-but-forbidden"
327-
touch "#{test_dir}/attributes/dirs/full-but-forbidden/file"
328-
#setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/full-but-forbidden"
329-
#chmod 000 "#{test_dir}/attributes/dirs/full-but-forbidden"
330-
#chmod +a "$YOU deny readextattr" "#{test_dir}/attributes/dirs/full-but-forbidden"
355+
touch -t #{some_date} "#{test_dir}/attributes" # there's probably
356+
touch -t #{some_date} "#{test_dir}/attributes"/* # a better
357+
touch -t #{some_date} "#{test_dir}/attributes"/*/* # way to
358+
touch -t #{some_date} "#{test_dir}/attributes"/*/*/* # do this
331359
332-
touch -t #{some_date} "#{test_dir}/attributes"
333-
touch -t #{some_date} "#{test_dir}/attributes/"*
334-
touch -t #{some_date} "#{test_dir}/attributes/dirs/"*
335-
touch -t #{some_date} "#{test_dir}/attributes/dirs/"*/*
360+
# I want to use the following to test,
361+
# but it only works on macos:
362+
#chmod +a "#{user} deny readextattr" "#{test_dir}/attributes"/**/*_forbidden
336363
364+
sudo chmod 000 "#{test_dir}/attributes"/**/*_forbidden
337365
sudo chown #{user}:#{user} -R "#{test_dir}/attributes"
338366
EOF
339367

src/exa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'w, W: Write + 'w> Exa<'w, W> {
174174
Mode::Lines => lines::Render { files, colours, classify }.render(self.writer),
175175
Mode::Grid(ref opts) => grid::Render { files, colours, classify, opts }.render(self.writer),
176176
Mode::Details(ref opts) => details::Render { dir, files, colours, classify, opts, filter: &self.options.filter, recurse: self.options.dir_action.recurse_options() }.render(self.writer),
177-
Mode::GridDetails(ref grid, ref details) => grid_details::Render { dir, files, colours, classify, grid, details }.render(self.writer),
177+
Mode::GridDetails(ref grid, ref details) => grid_details::Render { dir, files, colours, classify, grid, details, filter: &self.options.filter }.render(self.writer),
178178
}
179179
}
180180
else {

0 commit comments

Comments
 (0)