Mercurial > hg-stable
changeset 356:7dec9a46d82a
hgit rev-list support
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
hgit rev-list support
From: Chris Mason <mason@suse.com>
Update hgit rev-list support, make it a special case of hgit rev-tree
Print newest commit first
Add the ability to specify the max number of commits to print (-n or --max-nr=)
Match git feature of stopping at a given commit (hgit rev-list start_commit sto\p_commit)
manifest hash: b9bbd5e95dae771ebef89f8f4102e458052b1835
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCsG26ywK+sNU5EO8RAm5OAJ46G1nhXN2kQ+cKaBOK+oX4zSdQRgCdECvG
6wbG0JRdm7S29K4ynzs4cyY=
=pwpz
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Wed, 15 Jun 2005 10:04:42 -0800 |
parents | 3e18360a8912 |
children | 1cb3d9d5119e |
files | contrib/hgit |
diffstat | 1 files changed, 36 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/hgit Wed Jun 15 10:02:41 2005 -0800 +++ b/contrib/hgit Wed Jun 15 10:04:42 2005 -0800 @@ -128,7 +128,7 @@ # telling you which commits are reachable from the supplied ones via # a bitmask based on arg position. # you can specify a commit to stop at by starting the sha1 with ^ -def revtree(args, repo): +def revtree(args, repo, full="tree", maxnr=0): # calculate and return the reachability bitmask for sha def is_reachable(ar, reachable, sha): if len(ar) == 0: @@ -143,6 +143,7 @@ reachable = [] stop_sha1 = [] want_sha1 = [] + count = 0 # figure out which commits they are asking for and which ones they # want us to stop on @@ -153,6 +154,7 @@ want_sha1.append(s) elif args[i] != 'HEAD': want_sha1.append(args[i]) + # calculate the graph for the supplied commits for i in range(len(want_sha1)): reachable.append({}); @@ -169,40 +171,53 @@ visit.append(p) if p in stop_sha1: break + # walk the repository looking for commits that are in our # reachability graph - for i in range(repo.changelog.count()): + for i in range(repo.changelog.count()-1, -1, -1): n = repo.changelog.node(i) mask = is_reachable(want_sha1, reachable, n) if mask: - changes = repo.changelog.read(n) - (p1, p2) = repo.changelog.parents(n) - (h, h1, h2) = map(hg.hex, (n, p1, p2)) - (i1, i2) = map(repo.changelog.rev, (p1, p2)) + if not full: + print hg.hex(n) + elif full is "commit": + print hg.hex(n) + catcommit(repo, n, ' ') + else: + changes = repo.changelog.read(n) + (p1, p2) = repo.changelog.parents(n) + (h, h1, h2) = map(hg.hex, (n, p1, p2)) + (i1, i2) = map(repo.changelog.rev, (p1, p2)) - date = changes[2].split(' ')[0] - print "%s %s:%s" % (date, h, mask), - mask = is_reachable(want_sha1, reachable, p1) - if i1 != -1 and mask > 0: - print "%s:%s " % (h1, mask), - mask = is_reachable(want_sha1, reachable, p2) - if i2 != -1 and mask > 0: - print "%s:%s " % (h2, mask), - print "" + date = changes[2].split(' ')[0] + print "%s %s:%s" % (date, h, mask), + mask = is_reachable(want_sha1, reachable, p1) + if i1 != -1 and mask > 0: + print "%s:%s " % (h1, mask), + mask = is_reachable(want_sha1, reachable, p2) + if i2 != -1 and mask > 0: + print "%s:%s " % (h2, mask), + print "" + if maxnr and count >= maxnr: + break + count += 1 # git rev-list tries to order things by date, and has the ability to stop # at a given commit without walking the whole repo. TODO add the stop # parameter def revlist(args, repo): doptions = {} - opts = [('c', 'commit', None, 'commit')] + opts = [('c', 'commit', None, 'commit'), + ('n', 'max-nr', 0, 'max-nr')] args = fancyopts.fancyopts(args, opts, doptions, 'hg rev-list') - for i in range(repo.changelog.count()): - n = repo.changelog.node(i) - print hg.hex(n) - if doptions['commit']: - catcommit(repo, n, ' ') + if doptions['commit']: + full = "commit" + else: + full = None + for i in range(1, len(args)): + args[i] = '^' + args[i] + revtree(args, repo, full, doptions['max-nr']) def catchterm(*args): raise SignalInterrupt