[PATCH 1/3]: show in hgweb the deleted file

Goffredo Baroncelli kreijack at libero.it
Thu Jul 7 13:54:24 CDT 2005


On Thursday 07 July 2005 09:38, you (Matt Mackall) wrote:
> On Wed, Jul 06, 2005 at 09:41:11PM +0200, Goffredo Baroncelli wrote:
> > # HG changeset patch
> > # User kreijack at inwind.REMOVEME.it
> > # Node ID e14ea21f78af9ac652956b12258568014a873498
> > # Parent  7369ec5d93f2ffd490a43970edd9adf8d2bbe269
> > show in the changelog html page the deleted files from the (first) parent

> Can't we just use repo.changes() here? 
I diden't because repo.changes() returns a lot of things in which I am not interested. But
if you like, i will do

> Note that pulling the manifest 
> is O(files) and can be expensive on large projects and thus is not a
> good idea for anything but the single changeset view.
The only improvement which I found is caching the previous results ( but only
work quite well in the changelog generator page; see the attached patch  ); otherwise 
I will search a way to find the involved file in the changeset directly, instead of 
retriving this information via the canonical way. Do you have any suggestion ?

> Also note that this will in general be partly wrong on merges. If the
> file was deleted relative to p2, it won't show up.
Yes, I know ( in fact I wrote 'from the (first)...' )... 
But I think that is the correct behaviour; or you are also interested in the changes from
a pulled branch ?

Goffredo



 HG changeset patch
# User kreijack at inwind.REMOVEME.it
# Node ID 3b4d2da2bff41c24f68816049be06af75eddb159
# Parent  8c89408a7154d2da94766e957a088407fd0fef93
show in the changelog html page the deleted files from the (first) parent

diff -r 8c89408a7154 -r 3b4d2da2bff4 mercurial/hgweb.py
--- a/mercurial/hgweb.py        Thu Jul  7 06:41:56 2005
+++ b/mercurial/hgweb.py        Thu Jul  7 18:49:44 2005
@@ -258,11 +258,36 @@
             parity = (start - end) & 1
             cl = self.repo.changelog
             l = [] # build a list in forward order for efficiency
+
+            class cacheread:
+                def __init__(self, obj_):
+                    self.cache = {}
+                    self.obj = obj_
+
+                def read(self, w):
+                    if w in self.cache.keys():
+                        return self.cache[w]
+                    else:
+                        o = self.obj.read(w)
+                        self.cache[w] = o
+                        return o
+
+            manf = cacheread( self.repo.manifest )
+
             for i in range(start, end):
                 n = cl.node(i)
                 changes = cl.read(n)
                 hn = hex(n)
                 t = float(changes[2].split(' ')[0])
+                parent = cl.parents(n)[0]
+                if parent:
+                    pchange = cl.read(parent)
+
+                    pmf = manf.read(pchange[0])
+                    mf = manf.read(changes[0])
+                    deleted = [ x for x in pmf if not x in mf ]
+                else:
+                    deleted = []

                 l.insert(0, self.t(
                     'changelogentry',
@@ -275,6 +300,7 @@
                     desc = changes[4],
                     date = t,
                     files = self.listfilediffs(changes[3], n),
+                    deletedfiles = deleted,
                     rev = i,
                     node = hn))
                 parity = 1 - parity
diff -r 8c89408a7154 -r 3b4d2da2bff4 templates/changelogentry.tmpl
--- a/templates/changelogentry.tmpl     Thu Jul  7 06:41:56 2005
+++ b/templates/changelogentry.tmpl     Thu Jul  7 18:49:44 2005
@@ -21,4 +21,8 @@
   <th class="files"><a href="?cmd=manifest;manifest=#manifest#;path=/">files</a>:</th>
   <td class="files">#files#</td>
  </tr>
+ <tr>
+  <th class="files">removed files:</th>
+  <td class="files">#deletedfiles#</td>
+ </tr>
 </table>
\ No newline at end of file

-- 
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack AT inwind DOT it>
Key fingerprint = CE3C 7E01 6782 30A3 5B87  87C0 BB86 505C 6B2A CFF9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.selenic.com/pipermail/mercurial/attachments/20050707/e2c03a3c/attachment.pgp


More information about the Mercurial mailing list