comparison mercurial/commands.py @ 537:411e05b04ffa

Propagate file list through dodiff -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Propagate file list through dodiff This speeds up operations like 'hg diff Makefile'. Previously it would walk the entire directory tree looking for changes. Now it will only stat Makefile. Further, if Makefile appears untouched, it will skip reading the manifest. manifest hash: ab22a70a5511ed2d7a647f2cd15d129a88dccabf -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCxNRyywK+sNU5EO8RAgb6AKC2TzWmRjNsWq0Q9Pa+ppCZ6Y+pdwCfdHUA UHu024/2Wt6C6WZ5vcWfPbo= =E35L -----END PGP SIGNATURE-----
author mpm@selenic.com
date Thu, 30 Jun 2005 21:28:18 -0800
parents c15b4bc0a11c
children 4fc63e22b1fe
comparison
equal deleted inserted replaced
536:c15b4bc0a11c 537:411e05b04ffa
30 if os.getcwd() != repo.root: 30 if os.getcwd() != repo.root:
31 p = os.getcwd()[len(repo.root) + 1: ] 31 p = os.getcwd()[len(repo.root) + 1: ]
32 return [ util.pconvert(os.path.normpath(os.path.join(p, x))) for x in args ] 32 return [ util.pconvert(os.path.normpath(os.path.join(p, x))) for x in args ]
33 return args 33 return args
34 34
35 def dodiff(ui, repo, path, files = None, node1 = None, node2 = None): 35 def dodiff(ui, repo, files = None, node1 = None, node2 = None):
36 def date(c): 36 def date(c):
37 return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) 37 return time.asctime(time.gmtime(float(c[2].split(' ')[0])))
38
39 (c, a, d, u) = repo.changes(None, node1, files)
40 if files:
41 c, a, d = map(lambda x: filterfiles(files, x), (c, a, d))
42
43 if not c and not a and not d:
44 return
38 45
39 if node2: 46 if node2:
40 change = repo.changelog.read(node2) 47 change = repo.changelog.read(node2)
41 mmap2 = repo.manifest.read(change[0]) 48 mmap2 = repo.manifest.read(change[0])
42 (c, a, d, u) = repo.changes(node1, node2)
43 def read(f): return repo.file(f).read(mmap2[f]) 49 def read(f): return repo.file(f).read(mmap2[f])
44 date2 = date(change) 50 date2 = date(change)
45 else: 51 else:
46 date2 = time.asctime() 52 date2 = time.asctime()
47 (c, a, d, u) = repo.changes(None, node1, path)
48 if not node1: 53 if not node1:
49 node1 = repo.dirstate.parents()[0] 54 node1 = repo.dirstate.parents()[0]
50 def read(f): return repo.wfile(f).read() 55 def read(f): return repo.wfile(f).read()
51 56
52 if ui.quiet: 57 if ui.quiet:
56 r = [hexfunc(node) for node in [node1, node2] if node] 61 r = [hexfunc(node) for node in [node1, node2] if node]
57 62
58 change = repo.changelog.read(node1) 63 change = repo.changelog.read(node1)
59 mmap = repo.manifest.read(change[0]) 64 mmap = repo.manifest.read(change[0])
60 date1 = date(change) 65 date1 = date(change)
61
62 if files:
63 c, a, d = map(lambda x: filterfiles(files, x), (c, a, d))
64 66
65 for f in c: 67 for f in c:
66 to = None 68 to = None
67 if f in mmap: 69 if f in mmap:
68 to = repo.file(f).read(mmap[f]) 70 to = repo.file(f).read(mmap[f])
409 if files: 411 if files:
410 files = relpath(repo, files) 412 files = relpath(repo, files)
411 else: 413 else:
412 files = relpath(repo, [""]) 414 files = relpath(repo, [""])
413 415
414 dodiff(ui, repo, os.getcwd(), files, *revs) 416 dodiff(ui, repo, files, *revs)
415 417
416 def export(ui, repo, changeset): 418 def export(ui, repo, changeset):
417 """dump the changeset header and diffs for a revision""" 419 """dump the changeset header and diffs for a revision"""
418 node = repo.lookup(changeset) 420 node = repo.lookup(changeset)
419 prev, other = repo.changelog.parents(node) 421 prev, other = repo.changelog.parents(node)
426 if other != hg.nullid: 428 if other != hg.nullid:
427 print "# Parent %s" % hg.hex(other) 429 print "# Parent %s" % hg.hex(other)
428 print change[4].rstrip() 430 print change[4].rstrip()
429 print 431 print
430 432
431 dodiff(ui, repo, "", None, prev, node) 433 dodiff(ui, repo, None, prev, node)
432 434
433 def forget(ui, repo, file, *files): 435 def forget(ui, repo, file, *files):
434 """don't add the specified files on the next commit""" 436 """don't add the specified files on the next commit"""
435 repo.forget(relpath(repo, (file,) + files)) 437 repo.forget(relpath(repo, (file,) + files))
436 438
643 C = changed 645 C = changed
644 A = added 646 A = added
645 R = removed 647 R = removed
646 ? = not tracked''' 648 ? = not tracked'''
647 649
648 (c, a, d, u) = repo.changes(None, None, os.getcwd()) 650 (c, a, d, u) = repo.changes(None, None)
649 (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u)) 651 (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u))
650 652
651 for f in c: print "C", f 653 for f in c: print "C", f
652 for f in a: print "A", f 654 for f in a: print "A", f
653 for f in d: print "R", f 655 for f in d: print "R", f