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