[PATCH 1/5]: cleaning the template parent management in hgweb
authormpm@selenic.com
Sat, 02 Jul 2005 12:27:27 -0800
changeset 569 3e347929f5f9
parent 568 e8fd41110dce
child 570 2ee819a950aa
[PATCH 1/5]: cleaning the template parent management in hgweb -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [PATCH 1/5]: cleaning the template parent management in hgweb From: Goffredo Baroncelli <kreijack@libero.it> the template pages contain two entry named #parent1# and #parent2#; this is no +good because with the template system implemented in hgweb both the functions can be replaced with only one entry named "#parent#". The code in hgweb will replace this tag with the appropriate number of parents (+one, two... or more if and when will be used ). The first two patch perform this change in two step: 1) change the code to manage only one entry ( #parent1# ) 2) remove any reference to #parent2#, and change both the code and the templates to rename #parent1# in #parent2# the last three patchs are clean-up. The patch are five - - patch #1: - - clean the code in order to ignore #parent2# and use only #parent1# hgweb: chanage the parent1/parent2 code managment manifest hash: 6ba707904edf176c7269f2d9b80502902e6934c6 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCxvivywK+sNU5EO8RAkotAJ4vbR0KE+Jem20rQbaJxy8NRFeyJgCdHy2M hxmeD9erv17BrSKLGd5QAQI= =Or/F -----END PGP SIGNATURE-----
mercurial/hgweb.py
--- a/mercurial/hgweb.py	Fri Jul 01 14:46:31 2005 -0800
+++ b/mercurial/hgweb.py	Sat Jul 02 12:27:27 2005 -0800
@@ -155,6 +155,12 @@
         if node != hex(nullid):
             yield self.t(t1, node = node, rev = rev, **args)
 
+    def parents(self, t1, nodes=[], rev=None,**args):
+        if not rev: rev = lambda x: ""
+        for node in nodes:
+            if node != nullid:
+                yield self.t(t1, node = hex(node), rev = rev(node), **args)
+
     def showtag(self, t1, node=nullid, **args):
         for t in self.repo.nodetags(node):
              yield self.t(t1, tag = t, **args)
@@ -259,10 +265,8 @@
                     'changelogentry',
                     parity = parity,
                     author = changes[1],
-                    parent1 = self.parent("changelogparent",
-                                          hex(p1), cl.rev(p1)),
-                    parent2 = self.parent("changelogparent",
-                                          hex(p2), cl.rev(p2)),
+                    parent1 = self.parents("changelogparent",
+                                          cl.parents(n), cl.rev),
                     changelogtag = self.showtag("changelogtag",n),
                     p1 = hex(p1), p2 = hex(p2),
                     p1rev = cl.rev(p1), p2rev = cl.rev(p2),
@@ -327,10 +331,8 @@
                     'searchentry',
                     parity = count & 1,
                     author = changes[1],
-                    parent1 = self.parent("changelogparent",
-                                          hex(p1), cl.rev(p1)),
-                    parent2 = self.parent("changelogparent",
-                                          hex(p2), cl.rev(p2)),
+                    parent1 = self.parents("changelogparent",
+                                          cl.parents(n), cl.rev),
                     changelogtag = self.showtag("changelogtag",n),
                     p1 = hex(p1), p2 = hex(p2),
                     p1rev = cl.rev(p1), p2rev = cl.rev(p2),
@@ -378,10 +380,8 @@
                      diff = diff,
                      rev = cl.rev(n),
                      node = nodeid,
-                     parent1 = self.parent("changesetparent",
-                                           hex(p1), cl.rev(p1)),
-                     parent2 = self.parent("changesetparent",
-                                           hex(p2), cl.rev(p2)),
+                     parent1 = self.parents("changesetparent",
+                                           cl.parents(n), cl.rev),
                      changesettag = self.showtag("changesettag",n),
                      p1 = hex(p1), p2 = hex(p2),
                      p1rev = cl.rev(p1), p2rev = cl.rev(p2),
@@ -462,10 +462,8 @@
                      manifest = hex(mfn),
                      author = cs[1],
                      date = t,
-                     parent1 = self.parent("filerevparent",
-                                           hex(p1), fl.rev(p1), file=f),
-                     parent2 = self.parent("filerevparent",
-                                           hex(p2), fl.rev(p2), file=f),
+                     parent1 = self.parents("filerevparent",
+                                           fl.parents(n), fl.rev, file=f),
                      p1 = hex(p1), p2 = hex(p2),
                      permissions = self.repo.manifest.readflags(mfn)[f],
                      p1rev = fl.rev(p1), p2rev = fl.rev(p2))
@@ -531,10 +529,8 @@
                      manifest = hex(mfn),
                      author = cs[1],
                      date = t,
-                     parent1 = self.parent("fileannotateparent",
-                                           hex(p1), fl.rev(p1), file=f),
-                     parent2 = self.parent("fileannotateparent",
-                                           hex(p2), fl.rev(p2), file=f),
+                     parent1 = self.parents("fileannotateparent",
+                                           fl.parents(n), fl.rev, file=f),
                      p1 = hex(p1), p2 = hex(p2),
                      permissions = self.repo.manifest.readflags(mfn)[f],
                      p1rev = fl.rev(p1), p2rev = fl.rev(p2))