Show More
@@ -71,6 +71,61 b' def dodiff(repo, path, files = None, nod' | |||||
71 | tn = None |
|
71 | tn = None | |
72 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) |
|
72 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) | |
73 |
|
73 | |||
|
74 | def show_changeset(ui, repo, rev=0, changenode=None, filelog=None): | |||
|
75 | """show a single changeset or file revision""" | |||
|
76 | changelog = repo.changelog | |||
|
77 | if filelog: | |||
|
78 | log = filelog | |||
|
79 | filerev = rev | |||
|
80 | node = filenode = filelog.node(filerev) | |||
|
81 | changerev = filelog.linkrev(filenode) | |||
|
82 | changenode = changenode or changelog.node(changerev) | |||
|
83 | else: | |||
|
84 | changerev = rev | |||
|
85 | log = changelog | |||
|
86 | if changenode is None: | |||
|
87 | changenode = changelog.node(changerev) | |||
|
88 | elif not changerev: | |||
|
89 | rev = changerev = changelog.rev(changenode) | |||
|
90 | node = changenode | |||
|
91 | ||||
|
92 | if ui.quiet: | |||
|
93 | ui.write("%d:%s\n" % (rev, hg.hex(node))) | |||
|
94 | return | |||
|
95 | ||||
|
96 | changes = changelog.read(changenode) | |||
|
97 | description = changes[4].strip().splitlines() | |||
|
98 | ||||
|
99 | parents = [(log.rev(parent), hg.hex(parent)) | |||
|
100 | for parent in log.parents(node) | |||
|
101 | if ui.debugflag or parent != hg.nullid] | |||
|
102 | if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1: | |||
|
103 | parents = [] | |||
|
104 | ||||
|
105 | if filelog: | |||
|
106 | ui.write("revision: %d:%s\n" % (filerev, hg.hex(filenode))) | |||
|
107 | for parent in parents: | |||
|
108 | ui.write("parent: %d:%s\n" % parent) | |||
|
109 | ui.status("changeset: %d:%s\n" % (changerev, hg.hex(changenode))) | |||
|
110 | else: | |||
|
111 | ui.write("changeset: %d:%s\n" % (changerev, hg.hex(changenode))) | |||
|
112 | for parent in parents: | |||
|
113 | ui.write("parent: %d:%s\n" % parent) | |||
|
114 | ui.note("manifest: %d:%s\n" % (repo.manifest.rev(changes[0]), | |||
|
115 | hg.hex(changes[0]))) | |||
|
116 | ui.status("user: %s\n" % changes[1]) | |||
|
117 | ui.status("date: %s\n" % time.asctime( | |||
|
118 | time.localtime(float(changes[2].split(' ')[0])))) | |||
|
119 | ui.note("files: %s\n" % " ".join(changes[3])) | |||
|
120 | if description: | |||
|
121 | if ui.verbose: | |||
|
122 | ui.status("description:\n") | |||
|
123 | ui.status(changes[4].strip()) | |||
|
124 | ui.status("\n") | |||
|
125 | else: | |||
|
126 | ui.status("summary: %s\n" % description[0]) | |||
|
127 | ui.status("\n") | |||
|
128 | ||||
74 | def help(ui, cmd=None): |
|
129 | def help(ui, cmd=None): | |
75 | '''show help for a given command or all commands''' |
|
130 | '''show help for a given command or all commands''' | |
76 | if cmd: |
|
131 | if cmd: | |
@@ -248,44 +303,14 b' def forget(ui, repo, file, *files):' | |||||
248 | repo.forget(relpath(repo, (file,) + files)) |
|
303 | repo.forget(relpath(repo, (file,) + files)) | |
249 |
|
304 | |||
250 | def heads(ui, repo): |
|
305 | def heads(ui, repo): | |
251 |
|
|
306 | """show current repository heads""" | |
252 | for n in repo.changelog.heads(): |
|
307 | for n in repo.changelog.heads(): | |
253 | i = repo.changelog.rev(n) |
|
308 | show_changeset(ui, repo, changenode=n) | |
254 | changes = repo.changelog.read(n) |
|
|||
255 | (p1, p2) = repo.changelog.parents(n) |
|
|||
256 | (h, h1, h2) = map(hg.hex, (n, p1, p2)) |
|
|||
257 | (i1, i2) = map(repo.changelog.rev, (p1, p2)) |
|
|||
258 | print "rev: %4d:%s" % (i, h) |
|
|||
259 | print "parents: %4d:%s" % (i1, h1) |
|
|||
260 | if i2: print " %4d:%s" % (i2, h2) |
|
|||
261 | print "manifest: %4d:%s" % (repo.manifest.rev(changes[0]), |
|
|||
262 | hg.hex(changes[0])) |
|
|||
263 | print "user:", changes[1] |
|
|||
264 | print "date:", time.asctime( |
|
|||
265 | time.localtime(float(changes[2].split(' ')[0]))) |
|
|||
266 | if ui.verbose: print "files:", " ".join(changes[3]) |
|
|||
267 | print "description:" |
|
|||
268 | print changes[4] |
|
|||
269 |
|
309 | |||
270 | def history(ui, repo): |
|
310 | def history(ui, repo): | |
271 | """show the changelog history""" |
|
311 | """show the changelog history""" | |
272 | for i in range(repo.changelog.count() - 1, -1, -1): |
|
312 | for i in range(repo.changelog.count() - 1, -1, -1): | |
273 | n = repo.changelog.node(i) |
|
313 | show_changeset(ui, repo, rev=i) | |
274 | changes = repo.changelog.read(n) |
|
|||
275 | (p1, p2) = repo.changelog.parents(n) |
|
|||
276 | (h, h1, h2) = map(hg.hex, (n, p1, p2)) |
|
|||
277 | (i1, i2) = map(repo.changelog.rev, (p1, p2)) |
|
|||
278 | print "rev: %4d:%s" % (i, h) |
|
|||
279 | print "parents: %4d:%s" % (i1, h1) |
|
|||
280 | if i2: print " %4d:%s" % (i2, h2) |
|
|||
281 | print "manifest: %4d:%s" % (repo.manifest.rev(changes[0]), |
|
|||
282 | hg.hex(changes[0])) |
|
|||
283 | print "user:", changes[1] |
|
|||
284 | print "date:", time.asctime( |
|
|||
285 | time.localtime(float(changes[2].split(' ')[0]))) |
|
|||
286 | if ui.verbose: print "files:", " ".join(changes[3]) |
|
|||
287 | print "description:" |
|
|||
288 | print changes[4] |
|
|||
289 |
|
314 | |||
290 | def init(ui, source=None): |
|
315 | def init(ui, source=None): | |
291 | """create a new repository or copy an existing one""" |
|
316 | """create a new repository or copy an existing one""" | |
@@ -323,23 +348,7 b' def log(ui, repo, f):' | |||||
323 |
|
348 | |||
324 | r = repo.file(f) |
|
349 | r = repo.file(f) | |
325 | for i in range(r.count() - 1, -1, -1): |
|
350 | for i in range(r.count() - 1, -1, -1): | |
326 | n = r.node(i) |
|
351 | show_changeset(ui, repo, filelog=r, rev=i) | |
327 | (p1, p2) = r.parents(n) |
|
|||
328 | (h, h1, h2) = map(hg.hex, (n, p1, p2)) |
|
|||
329 | (i1, i2) = map(r.rev, (p1, p2)) |
|
|||
330 | cr = r.linkrev(n) |
|
|||
331 | cn = hg.hex(repo.changelog.node(cr)) |
|
|||
332 | print "rev: %4d:%s" % (i, h) |
|
|||
333 | print "changeset: %4d:%s" % (cr, cn) |
|
|||
334 | print "parents: %4d:%s" % (i1, h1) |
|
|||
335 | if i2: print " %4d:%s" % (i2, h2) |
|
|||
336 | changes = repo.changelog.read(repo.changelog.node(cr)) |
|
|||
337 | print "user: %s" % changes[1] |
|
|||
338 | print "date: %s" % time.asctime( |
|
|||
339 | time.localtime(float(changes[2].split(' ')[0]))) |
|
|||
340 | print "description:" |
|
|||
341 | print changes[4].rstrip() |
|
|||
342 |
|
||||
343 |
|
352 | |||
344 | def manifest(ui, repo, rev = []): |
|
353 | def manifest(ui, repo, rev = []): | |
345 | """output the latest or given revision of the project manifest""" |
|
354 | """output the latest or given revision of the project manifest""" | |
@@ -363,7 +372,7 b' def parents(ui, repo, node = None):' | |||||
363 |
|
372 | |||
364 | for n in p: |
|
373 | for n in p: | |
365 | if n != hg.nullid: |
|
374 | if n != hg.nullid: | |
366 | ui.write("%d:%s\n" % (repo.changelog.rev(n), hg.hex(n))) |
|
375 | show_changeset(ui, repo, changenode=n) | |
367 |
|
376 | |||
368 | def patch(ui, repo, patch1, *patches, **opts): |
|
377 | def patch(ui, repo, patch1, *patches, **opts): | |
369 | """import an ordered set of patches""" |
|
378 | """import an ordered set of patches""" | |
@@ -519,8 +528,7 b' def tags(ui, repo):' | |||||
519 | def tip(ui, repo): |
|
528 | def tip(ui, repo): | |
520 | """show the tip revision""" |
|
529 | """show the tip revision""" | |
521 | n = repo.changelog.tip() |
|
530 | n = repo.changelog.tip() | |
522 | t = repo.changelog.rev(n) |
|
531 | show_changeset(ui, repo, changenode=n) | |
523 | ui.status("%d:%s\n" % (t, hg.hex(n))) |
|
|||
524 |
|
532 | |||
525 | def undo(ui, repo): |
|
533 | def undo(ui, repo): | |
526 | """undo the last transaction""" |
|
534 | """undo the last transaction""" |
General Comments 0
You need to be logged in to leave comments.
Login now