Mercurial > hg
comparison hgext/graphlog.py @ 7713:b8c4ba0fd7c4
graphlog: import util module rather than selected functions
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Mon, 26 Jan 2009 16:15:28 +0100 |
parents | 5e13df32fb74 |
children | fd3266287b40 |
comparison
equal
deleted
inserted
replaced
7712:9f9bbd33f71e | 7713:b8c4ba0fd7c4 |
---|---|
15 import sys | 15 import sys |
16 from mercurial.cmdutil import revrange, show_changeset | 16 from mercurial.cmdutil import revrange, show_changeset |
17 from mercurial.commands import templateopts, logopts, remoteopts | 17 from mercurial.commands import templateopts, logopts, remoteopts |
18 from mercurial.i18n import _ | 18 from mercurial.i18n import _ |
19 from mercurial.node import nullrev | 19 from mercurial.node import nullrev |
20 from mercurial.util import Abort, canonpath | |
21 from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions | 20 from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions |
22 from mercurial import hg, ui, url | 21 from mercurial import hg, ui, url, util |
23 | 22 |
24 def revisions(repo, start, stop): | 23 def revisions(repo, start, stop): |
25 """cset DAG generator yielding (rev, node, [parents]) tuples | 24 """cset DAG generator yielding (rev, node, [parents]) tuples |
26 | 25 |
27 This generator function walks through the revision history from revision | 26 This generator function walks through the revision history from revision |
248 def get_limit(limit_opt): | 247 def get_limit(limit_opt): |
249 if limit_opt: | 248 if limit_opt: |
250 try: | 249 try: |
251 limit = int(limit_opt) | 250 limit = int(limit_opt) |
252 except ValueError: | 251 except ValueError: |
253 raise Abort(_("limit must be a positive integer")) | 252 raise util.Abort(_("limit must be a positive integer")) |
254 if limit <= 0: | 253 if limit <= 0: |
255 raise Abort(_("limit must be positive")) | 254 raise util.Abort(_("limit must be positive")) |
256 else: | 255 else: |
257 limit = sys.maxint | 256 limit = sys.maxint |
258 return limit | 257 return limit |
259 | 258 |
260 def get_revs(repo, rev_opt): | 259 def get_revs(repo, rev_opt): |
267 def check_unsupported_flags(opts): | 266 def check_unsupported_flags(opts): |
268 for op in ["follow", "follow_first", "date", "copies", "keyword", "remove", | 267 for op in ["follow", "follow_first", "date", "copies", "keyword", "remove", |
269 "only_merges", "user", "only_branch", "prune", "newest_first", | 268 "only_merges", "user", "only_branch", "prune", "newest_first", |
270 "no_merges", "include", "exclude"]: | 269 "no_merges", "include", "exclude"]: |
271 if op in opts and opts[op]: | 270 if op in opts and opts[op]: |
272 raise Abort(_("--graph option is incompatible with --%s") % op) | 271 raise util.Abort(_("--graph option is incompatible with --%s") % op) |
273 | 272 |
274 | 273 |
275 def graphlog(ui, repo, path=None, **opts): | 274 def graphlog(ui, repo, path=None, **opts): |
276 """show revision history alongside an ASCII revision graph | 275 """show revision history alongside an ASCII revision graph |
277 | 276 |
288 stop = max(stop, start - limit + 1) | 287 stop = max(stop, start - limit + 1) |
289 if start == nullrev: | 288 if start == nullrev: |
290 return | 289 return |
291 | 290 |
292 if path: | 291 if path: |
293 path = canonpath(repo.root, os.getcwd(), path) | 292 path = util.canonpath(repo.root, os.getcwd(), path) |
294 if path: # could be reset in canonpath | 293 if path: # could be reset in canonpath |
295 revdag = filerevs(repo, path, start, stop) | 294 revdag = filerevs(repo, path, start, stop) |
296 else: | 295 else: |
297 revdag = revisions(repo, start, stop) | 296 revdag = revisions(repo, start, stop) |
298 | 297 |