Mercurial > hg
changeset 334:290574209284
hgit: remove tabs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
hgit: remove tabs
- From Chris Mason
manifest hash: 68e016c1bbaaebed60ab9755fd054b95dae7263a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCr1RfywK+sNU5EO8RAjWBAKCMhIYjj/wOIvztLyoOjeuKMSSvLgCePIuD
Mm44JPLF9xegWFyOgB7QVoA=
=eEHJ
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Tue, 14 Jun 2005 14:04:15 -0800 |
parents | d60a3060f9e2 |
children | 74b9332faece |
files | contrib/hgit |
diffstat | 1 files changed, 106 insertions(+), 106 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/hgit Tue Jun 14 13:53:22 2005 -0800 +++ b/contrib/hgit Tue Jun 14 14:04:15 2005 -0800 @@ -12,58 +12,58 @@ def difftree(args, repo): def __difftree(repo, files = None, node1 = None, node2 = None): - def date(c): - return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) + def date(c): + return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) - if node2: - change = repo.changelog.read(node2) - mmap2 = repo.manifest.read(change[0]) - (c, a, d) = repo.diffrevs(node1, node2) - def read(f): return repo.file(f).read(mmap2[f]) - date2 = date(change) - else: - date2 = time.asctime() - (c, a, d, u) = repo.diffdir(repo.root, node1) - if not node1: - node1 = repo.dirstate.parents()[0] - def read(f): return file(os.path.join(repo.root, f)).read() + if node2: + change = repo.changelog.read(node2) + mmap2 = repo.manifest.read(change[0]) + (c, a, d) = repo.diffrevs(node1, node2) + def read(f): return repo.file(f).read(mmap2[f]) + date2 = date(change) + else: + date2 = time.asctime() + (c, a, d, u) = repo.diffdir(repo.root, node1) + if not node1: + node1 = repo.dirstate.parents()[0] + def read(f): return file(os.path.join(repo.root, f)).read() - change = repo.changelog.read(node1) - mmap = repo.manifest.read(change[0]) - date1 = date(change) - empty = "0" * 40; + change = repo.changelog.read(node1) + mmap = repo.manifest.read(change[0]) + date1 = date(change) + empty = "0" * 40; - if files: - c, a, d = map(lambda x: filterfiles(files, x), (c, a, d)) + if files: + c, a, d = map(lambda x: filterfiles(files, x), (c, a, d)) - for f in c: - # TODO get file permissions - print ":100664 100664 %s %s %s %s" % (hg.hex(mmap[f]), - hg.hex(mmap2[f]), f, f) - for f in a: - print ":000000 100664 %s %s %s %s" % (empty, hg.hex(mmap2[f]), f, f) - for f in d: - print ":100664 000000 %s %s %s %s" % (hg.hex(mmap[f]), empty, f, f) + for f in c: + # TODO get file permissions + print ":100664 100664 %s %s %s %s" % (hg.hex(mmap[f]), + hg.hex(mmap2[f]), f, f) + for f in a: + print ":000000 100664 %s %s %s %s" % (empty, hg.hex(mmap2[f]), f, f) + for f in d: + print ":100664 000000 %s %s %s %s" % (hg.hex(mmap[f]), empty, f, f) ## revs = [] if args: - doptions = {} - opts = [('p', 'patch', None, 'patch'), - ('r', 'recursive', None, 'recursive')] - args = fancyopts.fancyopts(args, opts, doptions, + doptions = {} + opts = [('p', 'patch', None, 'patch'), + ('r', 'recursive', None, 'recursive')] + args = fancyopts.fancyopts(args, opts, doptions, 'hg diff-tree [options] sha1 sha1') if len(args) < 2: - help() + help() sys.exit(1) revs.append(repo.lookup(args[0])) revs.append(repo.lookup(args[1])) args = args[2:] if doptions['patch']: - commands.dodiff(repo, args, *revs) + commands.dodiff(repo, args, *revs) else: - __difftree(repo, args, *revs) + __difftree(repo, args, *revs) def catcommit(repo, n, prefix): nlprefix = '\n' + prefix; @@ -80,15 +80,15 @@ print "%scommitter <%s> %s %s" % (prefix, changes[1], date, date_ar[1]) print prefix if prefix != "": - print "%s%s" % (prefix, changes[4].replace('\n', nlprefix).strip()) + print "%s%s" % (prefix, changes[4].replace('\n', nlprefix).strip()) else: - print changes[4] + print changes[4] def catfile(args, ui, repo): doptions = {} opts = [('s', 'stdin', None, 'stdin')] args = fancyopts.fancyopts(args, opts, doptions, - 'hg cat-file type sha1') + 'hg cat-file type sha1') # in stdin mode, every line except the commit is prefixed with two # spaces. This way the our caller can find the commit without magic @@ -96,32 +96,32 @@ # prefix = "" if doptions['stdin']: - try: - (type, r) = raw_input().split(' '); - prefix = " " - except EOFError: - return + try: + (type, r) = raw_input().split(' '); + prefix = " " + except EOFError: + return else: - if len(args) < 2: - help() - sys.exit(1) + if len(args) < 2: + help() + sys.exit(1) type = args[0] - r = args[1] + r = args[1] while r: - if type != "commit": - sys.stderr.write("aborting hg cat-file only understands commits\n") - sys.exit(1); - n = repo.changelog.lookup(r) - catcommit(repo, n, prefix) - if doptions['stdin']: - try: - (type, r) = raw_input().split(' '); - except EOFError: - break - else: - break + if type != "commit": + sys.stderr.write("aborting hg cat-file only understands commits\n") + sys.exit(1); + n = repo.changelog.lookup(r) + catcommit(repo, n, prefix) + if doptions['stdin']: + try: + (type, r) = raw_input().split(' '); + except EOFError: + break + else: + break # git rev-tree is a confusing thing. You can supply a number of # commit sha1s on the command line, and it walks the commit history @@ -131,14 +131,14 @@ def revtree(args, repo): # calculate and return the reachability bitmask for sha def is_reachable(ar, reachable, sha): - if len(ar) == 0: - return 1 - mask = 0 - for i in range(len(ar)): - if sha in reachable[i]: - mask |= 1 << i + if len(ar) == 0: + return 1 + mask = 0 + for i in range(len(ar)): + if sha in reachable[i]: + mask |= 1 << i - return mask + return mask reachable = [] stop_sha1 = [] @@ -148,47 +148,47 @@ # want us to stop on for i in range(len(args)): if args[i].count('^'): - s = args[i].split('^')[1] - stop_sha1.append(repo.changelog.lookup(s)) - want_sha1.append(s) - elif args[i] != 'HEAD': - want_sha1.append(args[i]) + s = args[i].split('^')[1] + stop_sha1.append(repo.changelog.lookup(s)) + 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({}); - n = repo.changelog.lookup(want_sha1[i]); - visit = [n]; - reachable[i][n] = 1 - while visit: - n = visit.pop(0) - if n in stop_sha1: - break - for p in repo.changelog.parents(n): - if p not in reachable[i]: - reachable[i][p] = 1 - visit.append(p) - if p in stop_sha1: - break + reachable.append({}); + n = repo.changelog.lookup(want_sha1[i]); + visit = [n]; + reachable[i][n] = 1 + while visit: + n = visit.pop(0) + if n in stop_sha1: + break + for p in repo.changelog.parents(n): + if p not in reachable[i]: + reachable[i][p] = 1 + 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()): - 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)) + 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)) - 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 "" # 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 @@ -197,12 +197,12 @@ doptions = {} opts = [('c', 'commit', None, 'commit')] args = fancyopts.fancyopts(args, opts, doptions, - 'hg rev-list') + '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, ' ') + n = repo.changelog.node(i) + print hg.hex(n) + if doptions['commit']: + catcommit(repo, n, ' ') def catchterm(*args): raise SignalInterrupt