Show More
@@ -71,6 +71,57 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 | ui.status("description: %s\n" % description[0]) | |||
|
122 | ui.note(''.join(["| %s\n" % line.rstrip() for line in description[1:]])) | |||
|
123 | ui.status("\n") | |||
|
124 | ||||
74 | def help(ui, cmd=None): |
|
125 | def help(ui, cmd=None): | |
75 | '''show help for a given command or all commands''' |
|
126 | '''show help for a given command or all commands''' | |
76 | if cmd: |
|
127 | if cmd: | |
@@ -248,44 +299,14 b' def forget(ui, repo, file, *files):' | |||||
248 | repo.forget(relpath(repo, (file,) + files)) |
|
299 | repo.forget(relpath(repo, (file,) + files)) | |
249 |
|
300 | |||
250 | def heads(ui, repo): |
|
301 | def heads(ui, repo): | |
251 |
|
|
302 | """show current repository heads""" | |
252 | for n in repo.changelog.heads(): |
|
303 | for n in repo.changelog.heads(): | |
253 | i = repo.changelog.rev(n) |
|
304 | 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 |
|
305 | |||
270 | def history(ui, repo): |
|
306 | def history(ui, repo): | |
271 | """show the changelog history""" |
|
307 | """show the changelog history""" | |
272 | for i in range(repo.changelog.count() - 1, -1, -1): |
|
308 | for i in range(repo.changelog.count() - 1, -1, -1): | |
273 | n = repo.changelog.node(i) |
|
309 | 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 |
|
310 | |||
290 | def init(ui, source=None): |
|
311 | def init(ui, source=None): | |
291 | """create a new repository or copy an existing one""" |
|
312 | """create a new repository or copy an existing one""" | |
@@ -323,23 +344,7 b' def log(ui, repo, f):' | |||||
323 |
|
344 | |||
324 | r = repo.file(f) |
|
345 | r = repo.file(f) | |
325 | for i in range(r.count() - 1, -1, -1): |
|
346 | for i in range(r.count() - 1, -1, -1): | |
326 | n = r.node(i) |
|
347 | 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 |
|
348 | |||
344 | def manifest(ui, repo, rev = []): |
|
349 | def manifest(ui, repo, rev = []): | |
345 | """output the latest or given revision of the project manifest""" |
|
350 | """output the latest or given revision of the project manifest""" | |
@@ -363,7 +368,7 b' def parents(ui, repo, node = None):' | |||||
363 |
|
368 | |||
364 | for n in p: |
|
369 | for n in p: | |
365 | if n != hg.nullid: |
|
370 | if n != hg.nullid: | |
366 | ui.write("%d:%s\n" % (repo.changelog.rev(n), hg.hex(n))) |
|
371 | show_changeset(ui, repo, changenode=n) | |
367 |
|
372 | |||
368 | def patch(ui, repo, patch1, *patches, **opts): |
|
373 | def patch(ui, repo, patch1, *patches, **opts): | |
369 | """import an ordered set of patches""" |
|
374 | """import an ordered set of patches""" | |
@@ -519,8 +524,7 b' def tags(ui, repo):' | |||||
519 | def tip(ui, repo): |
|
524 | def tip(ui, repo): | |
520 | """show the tip revision""" |
|
525 | """show the tip revision""" | |
521 | n = repo.changelog.tip() |
|
526 | n = repo.changelog.tip() | |
522 | t = repo.changelog.rev(n) |
|
527 | show_changeset(ui, repo, changenode=n) | |
523 | ui.status("%d:%s\n" % (t, hg.hex(n))) |
|
|||
524 |
|
528 | |||
525 | def undo(ui, repo): |
|
529 | def undo(ui, repo): | |
526 | """undo the last transaction""" |
|
530 | """undo the last transaction""" |
General Comments 0
You need to be logged in to leave comments.
Login now