[PATCH 1 of 2] Optionally display chains of empty directories in hgweb manifest view

Dirkjan Ochtman dirkjan at ochtman.nl
Tue Oct 21 04:16:38 CDT 2008


Ry4an Brase <ry4an-hg <at> ry4an.org> writes:
> +      self.decendempties = self.configbool("web", "decendempties", False)

As Matt mentioned, let's not make it optional. I think we can make it efficient
enough that the performance cost is not that important.

> +        elements = remain.split('/')
> +        if len(elements) == 1:
> +            files[remain] = (f, n)
> +        elif not web.decendempties:
> +            dirs[elements[0]] = {}
> +        else:
> +            h = dirs
> +            for index in range(0, len(elements)-1):
> +                if elements[index] not in h:
> +                    h[elements[index]] = {}
> +                h = h[elements[index]]
> +            h[None] = 1

I have a feeling we might be able to do this a little more efficiently. As we
walk the entries from the manifest, we can keep a dict with dir paths (of
arbitrary depth) that have only one file in them. As soon as we encounter
another file in the same (arbitrary depth) dir, we prune that dir from our
list. Does that sound sensible? (I still have to take a good look at our
manifest-walking code in webcommands to see if this would work.)

Also, this is strictly a UI thing, right? HTTP requests to
/file/tip/some/intermediate/dir/ would still work?

Cheers,

Dirkjan



More information about the Mercurial-devel mailing list