##// END OF EJS Templates
hgk: use contexts
Benoit Boissinot -
r3979:e0d13267 default
parent child Browse files
Show More
@@ -12,13 +12,11 b' def difftree(ui, repo, node1=None, node2'
12 12 """diff trees from two commits"""
13 13 def __difftree(repo, node1, node2, files=[]):
14 14 assert node2 is not None
15 change = repo.changelog.read(node2)
16 mmap2 = repo.manifest.read(change[0])
15 mmap2 = repo.changectx(node2).manifest()
17 16 status = repo.status(node1, node2, files=files)[:5]
18 17 modified, added, removed, deleted, unknown = status
19 18
20 change = repo.changelog.read(node1)
21 mmap = repo.manifest.read(change[0])
19 mmap = repo.changectx(node1).manifest()
22 20 empty = hg.short(hg.nullid)
23 21
24 22 for f in modified:
@@ -64,32 +62,30 b' def difftree(ui, repo, node1=None, node2'
64 62 if not opts['stdin']:
65 63 break
66 64
67 def catcommit(repo, n, prefix, changes=None):
65 def catcommit(repo, n, prefix, ctx=None):
68 66 nlprefix = '\n' + prefix;
69 (p1, p2) = repo.changelog.parents(n)
70 (h, h1, h2) = map(hg.short, (n, p1, p2))
71 (i1, i2) = map(repo.changelog.rev, (p1, p2))
72 if not changes:
73 changes = repo.changelog.read(n)
74 print "tree %s" % (hg.short(changes[0]))
75 if i1 != hg.nullrev: print "parent %s" % (h1)
76 if i2 != hg.nullrev: print "parent %s" % (h2)
77 date_ar = changes[2]
78 date = int(float(date_ar[0]))
79 lines = changes[4].splitlines()
67 if ctx is None:
68 ctx = repo.changectx(n)
69 (p1, p2) = ctx.parents()
70 print "tree %s" % (hg.short(ctx.changeset()[0])) # use ctx.node() instead ??
71 if p1: print "parent %s" % (hg.short(p1.node()))
72 if p2: print "parent %s" % (hg.short(p2.node()))
73 date = ctx.date()
74 description = ctx.description()
75 lines = description.splitlines()
80 76 if lines and lines[-1].startswith('committer:'):
81 77 committer = lines[-1].split(': ')[1].rstrip()
82 78 else:
83 committer = changes[1]
79 committer = ctx.user()
84 80
85 print "author %s %s %s" % (changes[1], date, date_ar[1])
86 print "committer %s %s %s" % (committer, date, date_ar[1])
87 print "revision %d" % repo.changelog.rev(n)
81 print "author %s %s %s" % (ctx.user(), int(date[0]), date[1])
82 print "committer %s %s %s" % (committer, int(date[0]), date[1])
83 print "revision %d" % ctx.rev()
88 84 print ""
89 85 if prefix != "":
90 print "%s%s" % (prefix, changes[4].replace('\n', nlprefix).strip())
86 print "%s%s" % (prefix, description.replace('\n', nlprefix).strip())
91 87 else:
92 print changes[4]
88 print description
93 89 if prefix:
94 90 sys.stdout.write('\0')
95 91
@@ -140,8 +136,7 b' def catfile(ui, repo, type=None, r=None,'
140 136 # you can specify a commit to stop at by starting the sha1 with ^
141 137 def revtree(args, repo, full="tree", maxnr=0, parents=False):
142 138 def chlogwalk():
143 ch = repo.changelog
144 count = ch.count()
139 count = repo.changelog.count()
145 140 i = count
146 141 l = [0] * 100
147 142 chunk = 100
@@ -157,7 +152,7 b' def revtree(args, repo, full="tree", max'
157 152 l[chunk - x:] = [0] * (chunk - x)
158 153 break
159 154 if full != None:
160 l[x] = ch.read(ch.node(i + x))
155 l[x] = repo.changectx(i + x)
161 156 else:
162 157 l[x] = 1
163 158 for x in xrange(chunk-1, -1, -1):
@@ -211,7 +206,7 b' def revtree(args, repo, full="tree", max'
211 206
212 207 # walk the repository looking for commits that are in our
213 208 # reachability graph
214 for i, changes in chlogwalk():
209 for i, ctx in chlogwalk():
215 210 n = repo.changelog.node(i)
216 211 mask = is_reachable(want_sha1, reachable, n)
217 212 if mask:
@@ -226,13 +221,13 b' def revtree(args, repo, full="tree", max'
226 221 print hg.short(n) + parentstr
227 222 elif full == "commit":
228 223 print hg.short(n) + parentstr
229 catcommit(repo, n, ' ', changes)
224 catcommit(repo, n, ' ', ctx)
230 225 else:
231 226 (p1, p2) = repo.changelog.parents(n)
232 227 (h, h1, h2) = map(hg.short, (n, p1, p2))
233 228 (i1, i2) = map(repo.changelog.rev, (p1, p2))
234 229
235 date = changes[2][0]
230 date = ctx.date()[0]
236 231 print "%s %s:%s" % (date, h, mask),
237 232 mask = is_reachable(want_sha1, reachable, p1)
238 233 if i1 != hg.nullrev and mask > 0:
General Comments 0
You need to be logged in to leave comments. Login now