hgext/graphlog.py
changeset 7715 fd3266287b40
parent 7713 b8c4ba0fd7c4
child 7716 4ad12930a459
equal deleted inserted replaced
7714:f6cee47c0907 7715:fd3266287b40
   242 
   242 
   243         # ... and start over
   243         # ... and start over
   244         prev_node_index = node_index
   244         prev_node_index = node_index
   245         prev_n_columns_diff = n_columns_diff
   245         prev_n_columns_diff = n_columns_diff
   246 
   246 
   247 def get_limit(limit_opt):
       
   248     if limit_opt:
       
   249         try:
       
   250             limit = int(limit_opt)
       
   251         except ValueError:
       
   252             raise util.Abort(_("limit must be a positive integer"))
       
   253         if limit <= 0:
       
   254             raise util.Abort(_("limit must be positive"))
       
   255     else:
       
   256         limit = sys.maxint
       
   257     return limit
       
   258 
       
   259 def get_revs(repo, rev_opt):
   247 def get_revs(repo, rev_opt):
   260     if rev_opt:
   248     if rev_opt:
   261         revs = revrange(repo, rev_opt)
   249         revs = revrange(repo, rev_opt)
   262         return (max(revs), min(revs))
   250         return (max(revs), min(revs))
   263     else:
   251     else:
   268                "only_merges", "user", "only_branch", "prune", "newest_first",
   256                "only_merges", "user", "only_branch", "prune", "newest_first",
   269                "no_merges", "include", "exclude"]:
   257                "no_merges", "include", "exclude"]:
   270         if op in opts and opts[op]:
   258         if op in opts and opts[op]:
   271             raise util.Abort(_("--graph option is incompatible with --%s") % op)
   259             raise util.Abort(_("--graph option is incompatible with --%s") % op)
   272 
   260 
   273 
       
   274 def graphlog(ui, repo, path=None, **opts):
   261 def graphlog(ui, repo, path=None, **opts):
   275     """show revision history alongside an ASCII revision graph
   262     """show revision history alongside an ASCII revision graph
   276 
   263 
   277     Print a revision history alongside a revision graph drawn with
   264     Print a revision history alongside a revision graph drawn with
   278     ASCII characters.
   265     ASCII characters.
   280     Nodes printed as an @ character are parents of the working
   267     Nodes printed as an @ character are parents of the working
   281     directory.
   268     directory.
   282     """
   269     """
   283 
   270 
   284     check_unsupported_flags(opts)
   271     check_unsupported_flags(opts)
   285     limit = get_limit(opts["limit"])
   272     limit = cmdutil.loglimit(opts)
   286     start, stop = get_revs(repo, opts["rev"])
   273     start, stop = get_revs(repo, opts["rev"])
   287     stop = max(stop, start - limit + 1)
   274     stop = max(stop, start - limit + 1)
   288     if start == nullrev:
   275     if start == nullrev:
   289         return
   276         return
   290 
   277