##// END OF EJS Templates
hgweb: teach siblings and callers to use contexts
Brendan Cully -
r3208:e7b7906c default
parent child Browse files
Show More
@@ -70,14 +70,12 b' class hgweb(object):'
70 70 if len(files) > self.maxfiles:
71 71 yield self.t("fileellipses")
72 72
73 def siblings(self, siblings=[], rev=None, hiderev=None, **args):
74 if not rev:
75 rev = lambda x: ""
76 siblings = [s for s in siblings if s != nullid]
77 if len(siblings) == 1 and rev(siblings[0]) == hiderev:
73 def siblings(self, siblings=[], hiderev=None, **args):
74 siblings = [s for s in siblings if s.node() != nullid]
75 if len(siblings) == 1 and siblings[0].rev() == hiderev:
78 76 return
79 77 for s in siblings:
80 yield dict(node=hex(s), rev=rev(s), **args)
78 yield dict(node=hex(s.node()), rev=s.rev(), **args)
81 79
82 80 def renamelink(self, fl, node):
83 81 r = fl.renamed(node)
@@ -191,22 +189,19 b' class hgweb(object):'
191 189 cl = self.repo.changelog
192 190 l = [] # build a list in forward order for efficiency
193 191 for i in range(start, end):
194 n = cl.node(i)
195 changes = cl.read(n)
196 hn = hex(n)
192 ctx = self.repo.changectx(i)
193 n = ctx.node()
197 194
198 195 l.insert(0, {"parity": parity,
199 "author": changes[1],
200 "parent": self.siblings(cl.parents(n), cl.rev,
201 cl.rev(n) - 1),
202 "child": self.siblings(cl.children(n), cl.rev,
203 cl.rev(n) + 1),
196 "author": ctx.user(),
197 "parent": self.siblings(ctx.parents(), i - 1),
198 "child": self.siblings(ctx.children(), i + 1),
204 199 "changelogtag": self.showtag("changelogtag",n),
205 "desc": changes[4],
206 "date": changes[2],
207 "files": self.listfilediffs(changes[3], n),
200 "desc": ctx.description(),
201 "date": ctx.date(),
202 "files": self.listfilediffs(ctx.files(), n),
208 203 "rev": i,
209 "node": hn})
204 "node": hex(n)})
210 205 parity = 1 - parity
211 206
212 207 for e in l:
@@ -237,44 +232,42 b' class hgweb(object):'
237 232 for i in range(cl.count() - 1, 0, -100):
238 233 l = []
239 234 for j in range(max(0, i - 100), i):
240 n = cl.node(j)
241 changes = cl.read(n)
242 l.append((n, j, changes))
235 ctx = self.repo.changectx(j)
236 l.append(ctx)
243 237 l.reverse()
244 238 for e in l:
245 239 yield e
246 240
247 for n, i, changes in revgen():
241 for ctx in revgen():
248 242 miss = 0
249 243 for q in qw:
250 if not (q in changes[1].lower() or
251 q in changes[4].lower() or
252 q in " ".join(changes[3][:20]).lower()):
244 if not (q in ctx.user().lower() or
245 q in ctx.description().lower() or
246 q in " ".join(ctx.files()[:20]).lower()):
253 247 miss = 1
254 248 break
255 249 if miss:
256 250 continue
257 251
258 252 count += 1
259 hn = hex(n)
253 n = ctx.node()
260 254
261 255 yield self.t('searchentry',
262 256 parity=self.stripes(count),
263 author=changes[1],
264 parent=self.siblings(cl.parents(n), cl.rev),
265 child=self.siblings(cl.children(n), cl.rev),
257 author=ctx.user(),
258 parent=self.siblings(ctx.parents()),
259 child=self.siblings(ctx.children()),
266 260 changelogtag=self.showtag("changelogtag",n),
267 desc=changes[4],
268 date=changes[2],
269 files=self.listfilediffs(changes[3], n),
270 rev=i,
271 node=hn)
261 desc=ctx.description(),
262 date=ctx.date(),
263 files=self.listfilediffs(ctx.files(), n),
264 rev=ctx.rev(),
265 node=hex(n))
272 266
273 267 if count >= self.maxchanges:
274 268 break
275 269
276 270 cl = self.repo.changelog
277 mf = cl.read(cl.tip())[0]
278 271
279 272 yield self.t('search',
280 273 query=query,
@@ -282,16 +275,14 b' class hgweb(object):'
282 275 entries=changelist)
283 276
284 277 def changeset(self, nodeid):
285 cl = self.repo.changelog
286 n = self.repo.lookup(nodeid)
287 nodeid = hex(n)
288 changes = cl.read(n)
289 p1 = cl.parents(n)[0]
278 ctx = self.repo.changectx(nodeid)
279 n = ctx.node()
280 parents = ctx.parents()
281 p1 = parents[0].node()
290 282
291 283 files = []
292 mf = self.repo.manifest.read(changes[0])
293 284 parity = 0
294 for f in changes[3]:
285 for f in ctx.files():
295 286 files.append(self.t("filenodelink",
296 287 node=hex(n), file=f,
297 288 parity=parity))
@@ -302,14 +293,14 b' class hgweb(object):'
302 293
303 294 yield self.t('changeset',
304 295 diff=diff,
305 rev=cl.rev(n),
306 node=nodeid,
307 parent=self.siblings(cl.parents(n), cl.rev),
308 child=self.siblings(cl.children(n), cl.rev),
296 rev=ctx.rev(),
297 node=hex(n),
298 parent=self.siblings(parents),
299 child=self.siblings(ctx.children()),
309 300 changesettag=self.showtag("changesettag",n),
310 author=changes[1],
311 desc=changes[4],
312 date=changes[2],
301 author=ctx.user(),
302 desc=ctx.description(),
303 date=ctx.date(),
313 304 files=files,
314 305 archives=self.archivelist(nodeid))
315 306
@@ -324,9 +315,8 b' class hgweb(object):'
324 315 parity = (count - 1) & 1
325 316
326 317 for i in range(count):
318 ctx = fctx.filectx(i)
327 319 n = fl.node(i)
328 lr = fl.linkrev(n)
329 ctx = self.repo.changectx(lr)
330 320
331 321 l.insert(0, {"parity": parity,
332 322 "filerev": i,
@@ -335,10 +325,8 b' class hgweb(object):'
335 325 "author": ctx.user(),
336 326 "date": ctx.date(),
337 327 "rename": self.renamelink(fl, n),
338 "parent": self.siblings(fl.parents(n),
339 fl.rev, file=f),
340 "child": self.siblings(fl.children(n),
341 fl.rev, file=f),
328 "parent": self.siblings(fctx.parents(), file=f),
329 "child": self.siblings(fctx.children(), file=f),
342 330 "desc": ctx.description()})
343 331 parity = 1 - parity
344 332
@@ -376,8 +364,8 b' class hgweb(object):'
376 364 node=hex(fctx.node()),
377 365 author=fctx.user(),
378 366 date=fctx.date(),
379 parent=self.siblings(fl.parents(n), fl.rev, file=f),
380 child=self.siblings(fl.children(n), fl.rev, file=f),
367 parent=self.siblings(fctx.parents(), file=f),
368 child=self.siblings(fctx.children(), file=f),
381 369 rename=self.renamelink(fl, n),
382 370 permissions=fctx.manifest().execf(f))
383 371
@@ -413,8 +401,8 b' class hgweb(object):'
413 401 author=fctx.user(),
414 402 date=fctx.date(),
415 403 rename=self.renamelink(fl, n),
416 parent=self.siblings(fl.parents(n), fl.rev, file=f),
417 child=self.siblings(fl.children(n), fl.rev, file=f),
404 parent=self.siblings(fctx.parents(), file=f),
405 child=self.siblings(fctx.children(), file=f),
418 406 permissions=fctx.manifest().execf(f))
419 407
420 408 def manifest(self, ctx, path):
@@ -565,23 +553,20 b' class hgweb(object):'
565 553 archives=self.archivelist("tip"))
566 554
567 555 def filediff(self, file, changeset):
568 cl = self.repo.changelog
569 n = self.repo.lookup(changeset)
570 changeset = hex(n)
571 p1 = cl.parents(n)[0]
572 cs = cl.read(n)
573 mf = self.repo.manifest.read(cs[0])
556 ctx = self.repo.changectx(changeset)
557 n = ctx.node()
558 parents = ctx.parents()
559 p1 = parents[0].node()
574 560
575 561 def diff(**map):
576 562 yield self.diff(p1, n, [file])
577 563
578 564 yield self.t("filediff",
579 565 file=file,
580 filenode=hex(mf.get(file, nullid)),
581 node=changeset,
582 rev=self.repo.changelog.rev(n),
583 parent=self.siblings(cl.parents(n), cl.rev),
584 child=self.siblings(cl.children(n), cl.rev),
566 node=hex(n),
567 rev=ctx.rev(),
568 parent=self.siblings(parents),
569 child=self.siblings(ctx.children()),
585 570 diff=diff)
586 571
587 572 archive_specs = {
General Comments 0
You need to be logged in to leave comments. Login now