Integration of Mercurial into LXR

paul_nathan at selinc.com paul_nathan at selinc.com
Thu Dec 13 19:46:49 CST 2012


mercurial-devel-bounces at selenic.com wrote on 12/13/2012 05:07:26 AM:

> From: andre-littoz <page74010-sf at yahoo.fr>
> To: "mercurial-devel at selenic.com" <mercurial-devel at selenic.com>, 
> Date: 12/13/2012 05:58 AM
> Subject: Integration of Mercurial into LXR
> Sent by: mercurial-devel-bounces at selenic.com
> 
> Hello,
> 
> I am the present LXR (Linux Cross-Referencer - see 
http://lxr/sourceforge.net
> ) administrator/developer and trying to extend LXR beyond plain 
> files/CVS/Git/svn storage engine.
> 
> I succeeded in implementing an experimental backend storage engine 
> to work with local Mercurial repositories. Unhappily, it runs 
> horribly slow (approximately 10 times slower than git or Subversion 
> on the same test case). Certainly because that's my first contact with 
hg.
> 
> One of the first LXR tasks is to display a directory view, same as 
> hgweb does. To retrieve directory content, I found nothing else than
> the following command:
> hg locate -r "revision of interest" a_directory/**
> 
> This implies to traverse the full repository, where I only want the 
> present directory, without its subdirectories. I can't use * pattern
> because I want to build a list of the subdirectories. The command 
> reports the complete sub-tree rooted at the requested directory. I 
> must then filter out the sublevels. This is a double waste: first 
> inside Mercurial to report the tree, next inside LXR to prune 
> unwanted information.
> 
> When it comes to compute file size, I had to
> hg cat -r "revision of interest" "a_file" | wc
> 
> which means extract the file and throw it away for every line in the
> directory list.
> 
> This is really inefficient.
> 
> I had a look at the source of hgweb to discover it used internal 
> templates names fentries and dentries which contain apparently the 
> information needed by LXR.
> 
> 
> Is there a simple and efficient command line to
> 1- get a "standard" directory list like ls or ls -F
> 2- retrieve a file size
> or
> 3- have access to information supplied by {fentries} and {dentries} 
templates?
> 
> Thanks for your help
> André Littoz
> LXR administrator_______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Hi,

FYI, your email came through in a font that was hard to read. Also, you 
sent to the Mercurial developers list...

I would advise that hg locate has --include PATTERN and --exclude PATTERN 
parameters. This may help you out. Further help might be found with hg 
manifest. 

However, I would take this tack:

With respect to file size, I would advise something similar to the 
following algorithm:

for changeset in list_of_changesets:
   `hg up changeset`
   for file in `hg manifest`
   data[changeset][filename] = filesize(filename)

In general, hg likes to think of things in terms of changesets, not files. 
I would suggest also looking at RhodeCode, a very nice hg webapp. I've 
done this general kind of query-hg-and-produce-file-based-results work 
before: you will almost certainly want to cache the DAG and any other 
information you want, as hg may take a bit of convincing to execute the 
kind of queries you want to do. I'd recommend a sqlite database or other 
flexible system. You may also, as Simon suggested, want to use the Python 
API instead and produce an extension to get what you particularly need. 
It's *quite* a bit faster.

Best of luck!

- - -
Regards,
Paul Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121213/cd84415c/attachment.html>


More information about the Mercurial-devel mailing list