comparison mercurial/hgweb/hgweb_mod.py @ 3206:79fd7a92f3e2

hgweb: kill off #filenode#
author Brendan Cully <brendan@kublai.com>
date Fri, 29 Sep 2006 16:26:09 -0700
parents 48395d2692de
children e7b7906cc47e
comparison
equal deleted inserted replaced
3205:48395d2692de 3206:79fd7a92f3e2
291 files = [] 291 files = []
292 mf = self.repo.manifest.read(changes[0]) 292 mf = self.repo.manifest.read(changes[0])
293 parity = 0 293 parity = 0
294 for f in changes[3]: 294 for f in changes[3]:
295 files.append(self.t("filenodelink", 295 files.append(self.t("filenodelink",
296 filenode=hex(mf.get(f, nullid)), file=f, 296 node=hex(n), file=f,
297 parity=parity)) 297 parity=parity))
298 parity = 1 - parity 298 parity = 1 - parity
299 299
300 def diff(**map): 300 def diff(**map):
301 yield self.diff(p1, n, None) 301 yield self.diff(p1, n, None)
311 desc=changes[4], 311 desc=changes[4],
312 date=changes[2], 312 date=changes[2],
313 files=files, 313 files=files,
314 archives=self.archivelist(nodeid)) 314 archives=self.archivelist(nodeid))
315 315
316 def filelog(self, f, filenode): 316 def filelog(self, fctx):
317 f = fctx.path()
317 cl = self.repo.changelog 318 cl = self.repo.changelog
318 fl = self.repo.file(f) 319 fl = fctx.filelog()
319 filenode = hex(fl.lookup(filenode))
320 count = fl.count() 320 count = fl.count()
321 321
322 def entries(**map): 322 def entries(**map):
323 l = [] 323 l = []
324 parity = (count - 1) & 1 324 parity = (count - 1) & 1
325 325
326 for i in range(count): 326 for i in range(count):
327 n = fl.node(i) 327 n = fl.node(i)
328 lr = fl.linkrev(n) 328 lr = fl.linkrev(n)
329 cn = cl.node(lr) 329 ctx = self.repo.changectx(lr)
330 cs = cl.read(cl.node(lr))
331 330
332 l.insert(0, {"parity": parity, 331 l.insert(0, {"parity": parity,
333 "filenode": hex(n),
334 "filerev": i, 332 "filerev": i,
335 "file": f, 333 "file": f,
336 "node": hex(cn), 334 "node": hex(ctx.node()),
337 "author": cs[1], 335 "author": ctx.user(),
338 "date": cs[2], 336 "date": ctx.date(),
339 "rename": self.renamelink(fl, n), 337 "rename": self.renamelink(fl, n),
340 "parent": self.siblings(fl.parents(n), 338 "parent": self.siblings(fl.parents(n),
341 fl.rev, file=f), 339 fl.rev, file=f),
342 "child": self.siblings(fl.children(n), 340 "child": self.siblings(fl.children(n),
343 fl.rev, file=f), 341 fl.rev, file=f),
344 "desc": cs[4]}) 342 "desc": ctx.description()})
345 parity = 1 - parity 343 parity = 1 - parity
346 344
347 for e in l: 345 for e in l:
348 yield e 346 yield e
349 347
350 yield self.t("filelog", file=f, filenode=filenode, entries=entries) 348 yield self.t("filelog", file=f, node=hex(fctx.node()), entries=entries)
351 349
352 def filerevision(self, f, node): 350 def filerevision(self, fctx):
353 fl = self.repo.file(f) 351 f = fctx.path()
354 n = fl.lookup(node) 352 text = fctx.data()
355 node = hex(n) 353 fl = fctx.filelog()
356 text = fl.read(n) 354 n = fctx.filenode()
357 changerev = fl.linkrev(n)
358 cl = self.repo.changelog
359 cn = cl.node(changerev)
360 cs = cl.read(cn)
361 mfn = cs[0]
362 355
363 mt = mimetypes.guess_type(f)[0] 356 mt = mimetypes.guess_type(f)[0]
364 rawtext = text 357 rawtext = text
365 if util.binary(text): 358 if util.binary(text):
366 mt = mt or 'application/octet-stream' 359 mt = mt or 'application/octet-stream'
373 "linenumber": "% 6d" % (l + 1), 366 "linenumber": "% 6d" % (l + 1),
374 "parity": self.stripes(l)} 367 "parity": self.stripes(l)}
375 368
376 yield self.t("filerevision", 369 yield self.t("filerevision",
377 file=f, 370 file=f,
378 filenode=node,
379 path=_up(f), 371 path=_up(f),
380 text=lines(), 372 text=lines(),
381 raw=rawtext, 373 raw=rawtext,
382 mimetype=mt, 374 mimetype=mt,
383 rev=changerev, 375 rev=fctx.rev(),
384 node=hex(cn), 376 node=hex(fctx.node()),
385 author=cs[1], 377 author=fctx.user(),
386 date=cs[2], 378 date=fctx.date(),
387 parent=self.siblings(fl.parents(n), fl.rev, file=f), 379 parent=self.siblings(fl.parents(n), fl.rev, file=f),
388 child=self.siblings(fl.children(n), fl.rev, file=f), 380 child=self.siblings(fl.children(n), fl.rev, file=f),
389 rename=self.renamelink(fl, n), 381 rename=self.renamelink(fl, n),
390 permissions=self.repo.manifest.read(mfn).execf(f)) 382 permissions=fctx.manifest().execf(f))
391 383
392 def fileannotate(self, f, node): 384 def fileannotate(self, fctx):
393 fctx = self.repo.filectx(f, fileid=node) 385 f = fctx.path()
394 n = fctx.filenode() 386 n = fctx.filenode()
395 fl = fctx.filelog() 387 fl = fctx.filelog()
396 388
397 def annotate(**map): 389 def annotate(**map):
398 parity = 0 390 parity = 0
405 parity = 1 - parity 397 parity = 1 - parity
406 last = fnode 398 last = fnode
407 399
408 yield {"parity": parity, 400 yield {"parity": parity,
409 "node": hex(f.node()), 401 "node": hex(f.node()),
410 "filenode": hex(fnode),
411 "rev": f.rev(), 402 "rev": f.rev(),
412 "author": name, 403 "author": name,
413 "file": f.path(), 404 "file": f.path(),
414 "line": l} 405 "line": l}
415 406
416 yield self.t("fileannotate", 407 yield self.t("fileannotate",
417 file=f, 408 file=f,
418 filenode=node,
419 annotate=annotate, 409 annotate=annotate,
420 path=_up(f), 410 path=_up(f),
421 rev=fctx.rev(), 411 rev=fctx.rev(),
422 node=hex(fctx.node()), 412 node=hex(fctx.node()),
423 author=fctx.user(), 413 author=fctx.user(),
680 except hg.RepoError: 670 except hg.RepoError:
681 man = self.repo.manifest 671 man = self.repo.manifest
682 mn = man.lookup(changeid) 672 mn = man.lookup(changeid)
683 req.changectx = self.repo.changectx(man.linkrev(mn)) 673 req.changectx = self.repo.changectx(man.linkrev(mn))
684 674
675 if form.has_key('filenode'):
676 changeid = req.form['filenode'][0]
677 path = self.cleanpath(req.form['file'][0])
678 try:
679 req.changectx = self.repo.changectx(changeid)
680 req.filectx = req.changectx.filectx(path)
681 except hg.RepoError:
682 req.filectx = self.repo.filectx(path, fileid=changeid)
683 req.changectx = req.filectx.changectx()
684
685 self.refresh() 685 self.refresh()
686 686
687 expand_form(req.form) 687 expand_form(req.form)
688 688
689 m = os.path.join(self.templatepath, "map") 689 m = os.path.join(self.templatepath, "map")
772 def do_filediff(self, req): 772 def do_filediff(self, req):
773 req.write(self.filediff(self.cleanpath(req.form['file'][0]), 773 req.write(self.filediff(self.cleanpath(req.form['file'][0]),
774 req.form['node'][0])) 774 req.form['node'][0]))
775 775
776 def do_file(self, req): 776 def do_file(self, req):
777 req.write(self.filerevision(self.cleanpath(req.form['file'][0]), 777 req.write(self.filerevision(req.filectx))
778 req.form['filenode'][0]))
779 778
780 def do_annotate(self, req): 779 def do_annotate(self, req):
781 req.write(self.fileannotate(self.cleanpath(req.form['file'][0]), 780 req.write(self.fileannotate(req.filectx))
782 req.form['filenode'][0]))
783 781
784 def do_filelog(self, req): 782 def do_filelog(self, req):
785 req.write(self.filelog(self.cleanpath(req.form['file'][0]), 783 req.write(self.filelog(req.filectx))
786 req.form['filenode'][0]))
787 784
788 def do_heads(self, req): 785 def do_heads(self, req):
789 resp = " ".join(map(hex, self.repo.heads())) + "\n" 786 resp = " ".join(map(hex, self.repo.heads())) + "\n"
790 req.httphdr("application/mercurial-0.1", length=len(resp)) 787 req.httphdr("application/mercurial-0.1", length=len(resp))
791 req.write(resp) 788 req.write(resp)