Quantcast

List files in a directory

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

List files in a directory

guigouz
Hi everybody,

I'm looking for an equivalent command to svn list on mercurial.

The aim is to list the files and directories in a repository at a given revision or branch for a given directory.
I tried to do a hg update 123 and a hg status --all my-folder but the latter is recursive and poses performance problems.

Basically, I search an equivalent to svn list --non-recursive -r 123 my-folder

Is it possible in command line? If not, is the mercurial python API can do that easily?

For information, I'm working on a forge in Java and I have to implement source code browsing (as in bitbucket).

Thank you in advance for any information ;)
Guigouz
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: List files in a directory

François Gannaz-2
Le 2010-07-07, guigouz <[hidden email]> a écrit :
>
> Hi everybody,
>
> I'm looking for an equivalent command to svn list on mercurial.

hg help manifest

Then I think you'll have to filter the manifest if you just want to list files
in one directory.

Greets
--
François
_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: List files in a directory

Nicolas Dumazet
In reply to this post by guigouz
Hello!

2010/7/7 guigouz <[hidden email]>:

>
> Hi everybody,
>
> I'm looking for an equivalent command to svn list on mercurial.
>
> The aim is to list the files and directories in a repository at a given
> revision or branch for a given directory.
> I tried to do a hg update 123 and a hg status --all my-folder but the latter
> is recursive and poses performance problems.
>
> Basically, I search an equivalent to svn list --non-recursive -r 123
> my-folder

I think that:
    hg locate -r 123 "glob:*"
should do what you need.

But on the other hand, the recursive version
    hg locate -r 123
should not be *this* slow.
I understand that status could be slow, as it's checking for each file
if contents have changed. But locate only reads the manifest for
revision 123, and that should be quite fast.


>
> Is it possible in command line? If not, is the mercurial python API can do
> that easily?

The walk() method of a changectx is what you want:

    m = cmdutil.match(repo, ["glob:*"])
    return list(repo[rev].walk(m))

Regards,

>
> For information, I'm working on a forge in Java and I have to implement
> source code browsing (as in bitbucket).
>
> Thank you in advance for any information ;)
> Guigouz
> --
> View this message in context: http://mercurial.808500.n3.nabble.com/List-files-in-a-directory-tp949176p949176.html
> Sent from the General mailing list archive at Nabble.com.
> _______________________________________________
> Mercurial mailing list
> [hidden email]
> http://selenic.com/mailman/listinfo/mercurial
>



--
Nicolas Dumazet — NicDumZ
_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: List files in a directory

guigouz
In reply to this post by guigouz
Thank you for your help, it's almost perfect!

The command hg locate -r 123 "glob:my-directory/*" gives me the list of files without recursion.

However I did not list subdirectories available because hg locate only returns files.

For hg manifest, same problem, even if I filter the output. Moreover, used on 10000 files projects on a forge used by 2,000 people at the same time, it would become problematic...

At worst, if hg locate does not list the files, is it possible to request a one-level recursion ? I could then start a process on the output and identify the directories...

What do you think about that ?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: List files in a directory

wsmind
Using the glob: syntax allows you to leverage the power of standard python glob.

Thus you can use glob:*/* in order to retrieve every file present exactly one level under the parent directory specified (empty dirs won't show up).

It seems that cumulating glob: patterns makes the results to add up :
hg locate -r 123 "glob:my-directory/*" "glob:my-directory/*/*"
will show files in my directory and all its children directories (non-recursive).
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: List files in a directory

Greg Ward
In reply to this post by guigouz
On Wed, Jul 7, 2010 at 10:12 AM, guigouz <[hidden email]> wrote:
> I'm looking for an equivalent command to svn list on mercurial.
>
> The aim is to list the files and directories in a repository at a given
> revision or branch for a given directory.
> I tried to do a hg update 123 and a hg status --all my-folder but the latter
> is recursive and poses performance problems.
>
> Basically, I search an equivalent to svn list --non-recursive -r 123
> my-folder

You're looking for hg locate.  It's not *quite* an ls-like command,
but it's close enough.  Examples:

  hg locate "foo/bar/**"

recursively lists everything under foo/bar, i.e. all filenames that
match the given pattern.

And

  hg locate "foo/bar/*"

is the non-recursive version, i.e. only lists files directly in
foo/bar.  And yes, it supports -r.

Greg
_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial
Loading...