comparison mercurial/commands.py @ 536:c15b4bc0a11c

Refactor diffrevs/diffdir into changes -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Refactor diffrevs/diffdir into changes Add dirstate.changes to replace most of diffdir Add localrepository.changes to replace diffrevs/diffdir This code can now efficiently check for changes in single files, and often without consulting the manifest. This should eventually make 'hg diff Makefile' in a large project much faster. This also fixes a bug where 'hg diff -r tip' failed to account for files that had been added but not committed yet. manifest hash: 20fde5d4b4cee49a76bcfe50f2dacf58b1f2258b -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCxMxpywK+sNU5EO8RAhzOAJ9VLQJoC+hiRYQtTSPbDhXBEJfQZwCgpDx9 GAwQ9jZHNsgXckBfXNCkJV8= =hMuc -----END PGP SIGNATURE-----
author mpm@selenic.com
date Thu, 30 Jun 2005 20:54:01 -0800
parents fba26990604a
children 411e05b04ffa
comparison
equal deleted inserted replaced
535:fba26990604a 536:c15b4bc0a11c
37 return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) 37 return time.asctime(time.gmtime(float(c[2].split(' ')[0])))
38 38
39 if node2: 39 if node2:
40 change = repo.changelog.read(node2) 40 change = repo.changelog.read(node2)
41 mmap2 = repo.manifest.read(change[0]) 41 mmap2 = repo.manifest.read(change[0])
42 (c, a, d) = repo.diffrevs(node1, node2) 42 (c, a, d, u) = repo.changes(node1, node2)
43 def read(f): return repo.file(f).read(mmap2[f]) 43 def read(f): return repo.file(f).read(mmap2[f])
44 date2 = date(change) 44 date2 = date(change)
45 else: 45 else:
46 date2 = time.asctime() 46 date2 = time.asctime()
47 (c, a, d, u) = repo.diffdir(path, node1) 47 (c, a, d, u) = repo.changes(None, node1, path)
48 if not node1: 48 if not node1:
49 node1 = repo.dirstate.parents()[0] 49 node1 = repo.dirstate.parents()[0]
50 def read(f): return repo.wfile(f).read() 50 def read(f): return repo.wfile(f).read()
51 51
52 if ui.quiet: 52 if ui.quiet:
122 hg.hex(changes[0]))) 122 hg.hex(changes[0])))
123 ui.status("user: %s\n" % changes[1]) 123 ui.status("user: %s\n" % changes[1])
124 ui.status("date: %s\n" % time.asctime( 124 ui.status("date: %s\n" % time.asctime(
125 time.localtime(float(changes[2].split(' ')[0])))) 125 time.localtime(float(changes[2].split(' ')[0]))))
126 if ui.debugflag: 126 if ui.debugflag:
127 files = repo.diffrevs(changelog.parents(changenode)[0], changenode) 127 files = repo.changes(changelog.parents(changenode)[0], changenode)
128 for key, value in zip(["files:", "files+:", "files-:"], files): 128 for key, value in zip(["files:", "files+:", "files-:"], files):
129 if value: 129 if value:
130 ui.note("%-12s %s\n" % (key, " ".join(value))) 130 ui.note("%-12s %s\n" % (key, " ".join(value)))
131 else: 131 else:
132 ui.note("files: %s\n" % " ".join(changes[3])) 132 ui.note("files: %s\n" % " ".join(changes[3]))
212 if s != 'r' and not isfile: 212 if s != 'r' and not isfile:
213 d.append(f) 213 d.append(f)
214 elif s not in 'nmai' and isfile: 214 elif s not in 'nmai' and isfile:
215 u.append(f) 215 u.append(f)
216 else: 216 else:
217 (c, a, d, u) = repo.diffdir(repo.root) 217 (c, a, d, u) = repo.changes(None, None)
218 repo.add(u) 218 repo.add(u)
219 repo.remove(d) 219 repo.remove(d)
220 220
221 def annotate(u, repo, file, *files, **ops): 221 def annotate(u, repo, file, *files, **ops):
222 """show changeset information per file line""" 222 """show changeset information per file line"""
445 if not parents: 445 if not parents:
446 ui.write("unknown\n") 446 ui.write("unknown\n")
447 return 447 return
448 448
449 hexfunc = ui.verbose and hg.hex or hg.short 449 hexfunc = ui.verbose and hg.hex or hg.short
450 (c, a, d, u) = repo.diffdir(repo.root) 450 (c, a, d, u) = repo.changes(None, None)
451 output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]), 451 output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]),
452 (c or a or d) and "+" or "")] 452 (c or a or d) and "+" or "")]
453 453
454 if not ui.quiet: 454 if not ui.quiet:
455 # multiple tags for a single parent separated by '/' 455 # multiple tags for a single parent separated by '/'
643 C = changed 643 C = changed
644 A = added 644 A = added
645 R = removed 645 R = removed
646 ? = not tracked''' 646 ? = not tracked'''
647 647
648 (c, a, d, u) = repo.diffdir(os.getcwd()) 648 (c, a, d, u) = repo.changes(None, None, os.getcwd())
649 (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u)) 649 (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u))
650 650
651 for f in c: print "C", f 651 for f in c: print "C", f
652 for f in a: print "A", f 652 for f in a: print "A", f
653 for f in d: print "R", f 653 for f in d: print "R", f
658 658
659 if name == "tip": 659 if name == "tip":
660 ui.warn("abort: 'tip' is a reserved name!\n") 660 ui.warn("abort: 'tip' is a reserved name!\n")
661 return -1 661 return -1
662 662
663 (c, a, d, u) = repo.diffdir(repo.root) 663 (c, a, d, u) = repo.changes(None, None)
664 for x in (c, a, d, u): 664 for x in (c, a, d, u):
665 if ".hgtags" in x: 665 if ".hgtags" in x:
666 ui.warn("abort: working copy of .hgtags is changed!\n") 666 ui.warn("abort: working copy of .hgtags is changed!\n")
667 ui.status("(please commit .hgtags manually)\n") 667 ui.status("(please commit .hgtags manually)\n")
668 return -1 668 return -1