Mercurial > hg > pyhgsh
comparison hg @ 67:a182f2561c8e
Add tag support
author | mpm@selenic.com |
---|---|
date | Fri, 13 May 2005 13:12:32 -0800 |
parents | d40cc5aacc31 |
children | 6fa994fe90fc |
comparison
equal
deleted
inserted
replaced
66:5ec8b2ed858f | 67:a182f2561c8e |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # mercurial - a minimal scalable distributed SCM | 3 # mercurial - a minimal scalable distributed SCM |
4 # v0.4e "sabina" | 4 # v0.4f "jane dark" |
5 # | 5 # |
6 # Copyright 2005 Matt Mackall <mpm@selenic.com> | 6 # Copyright 2005 Matt Mackall <mpm@selenic.com> |
7 # | 7 # |
8 # This software may be used and distributed according to the terms | 8 # This software may be used and distributed according to the terms |
9 # of the GNU General Public License, incorporated herein by reference. | 9 # of the GNU General Public License, incorporated herein by reference. |
35 history show changeset history | 35 history show changeset history |
36 log <file> show revision history of a single file | 36 log <file> show revision history of a single file |
37 dump <file> [rev] dump the latest or given revision of a file | 37 dump <file> [rev] dump the latest or given revision of a file |
38 dumpmanifest [rev] dump the latest or given revision of the manifest | 38 dumpmanifest [rev] dump the latest or given revision of the manifest |
39 diff [files...] diff working directory (or selected files) | 39 diff [files...] diff working directory (or selected files) |
40 tags show current changeset tags | |
40 """ | 41 """ |
41 | 42 |
42 def filterfiles(list, files): | 43 def filterfiles(list, files): |
43 l = [ x for x in list if x in files ] | 44 l = [ x for x in list if x in files ] |
44 | 45 |
116 sys.exit(0) | 117 sys.exit(0) |
117 | 118 |
118 if cmd == "checkout" or cmd == "co": | 119 if cmd == "checkout" or cmd == "co": |
119 node = repo.changelog.tip() | 120 node = repo.changelog.tip() |
120 if args: | 121 if args: |
121 node = repo.changelog.lookup(args[0]) | 122 node = repo.lookup(args[0]) |
122 repo.checkout(node) | 123 repo.checkout(node) |
123 | 124 |
124 elif cmd == "add": | 125 elif cmd == "add": |
125 repo.add(args) | 126 repo.add(args) |
126 | 127 |
175 if args: | 176 if args: |
176 doptions = {} | 177 doptions = {} |
177 opts = [('r', 'revision', [], 'revision')] | 178 opts = [('r', 'revision', [], 'revision')] |
178 args = fancyopts.fancyopts(args, opts, doptions, | 179 args = fancyopts.fancyopts(args, opts, doptions, |
179 'hg diff [options] [files]') | 180 'hg diff [options] [files]') |
180 revs = map(lambda x: repo.changelog.lookup(x), doptions['revision']) | 181 revs = map(lambda x: repo.lookup(x), doptions['revision']) |
181 | 182 |
182 if len(revs) > 2: | 183 if len(revs) > 2: |
183 print "too many revisions to diff" | 184 print "too many revisions to diff" |
184 sys.exit(1) | 185 sys.exit(1) |
185 | 186 |
189 else: args = [ os.path.join(relpath, x) for x in args ] | 190 else: args = [ os.path.join(relpath, x) for x in args ] |
190 | 191 |
191 diff(args, *revs) | 192 diff(args, *revs) |
192 | 193 |
193 elif cmd == "export": | 194 elif cmd == "export": |
194 node = repo.changelog.lookup(args[0]) | 195 node = repo.lookup(args[0]) |
195 prev = repo.changelog.parents(node)[0] | 196 prev = repo.changelog.parents(node)[0] |
196 diff(None, prev, node) | 197 diff(None, prev, node) |
197 | 198 |
198 elif cmd == "debugchangegroup": | 199 elif cmd == "debugchangegroup": |
199 newer = repo.newer(map(repo.changelog.lookup, args)) | 200 newer = repo.newer(map(repo.lookup, args)) |
200 for chunk in repo.changegroup(newer): | 201 for chunk in repo.changegroup(newer): |
201 sys.stdout.write(chunk) | 202 sys.stdout.write(chunk) |
202 | 203 |
203 elif cmd == "debugaddchangegroup": | 204 elif cmd == "debugaddchangegroup": |
204 data = sys.stdin.read() | 205 data = sys.stdin.read() |
286 cg = repo.getchangegroup(other) | 287 cg = repo.getchangegroup(other) |
287 repo.addchangegroup(cg) | 288 repo.addchangegroup(cg) |
288 else: | 289 else: |
289 print "missing source repository" | 290 print "missing source repository" |
290 | 291 |
292 elif cmd == "tags": | |
293 repo.lookup(0) # prime the cache | |
294 i = repo.tags.items() | |
295 i.sort() | |
296 for k, n in i: | |
297 try: | |
298 r = repo.changelog.rev(n) | |
299 except KeyError: | |
300 r = "?" | |
301 print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n)) | |
302 | |
291 elif cmd == "debugoldmerge": | 303 elif cmd == "debugoldmerge": |
292 if args: | 304 if args: |
293 other = hg.repository(ui, args[0]) | 305 other = hg.repository(ui, args[0]) |
294 repo.merge(other) | 306 repo.merge(other) |
295 else: | 307 else: |