##// END OF EJS Templates
log: changed implementation to use graphlog code...
Lucas Moscovicz -
r21127:69402eb7 default
parent child Browse files
Show More
@@ -1673,6 +1673,54 def getgraphlogrevs(repo, pats, opts):
1673
1673
1674 return revs, expr, filematcher
1674 return revs, expr, filematcher
1675
1675
1676 def getlogrevs(repo, pats, opts):
1677 """Return (revs, expr, filematcher) where revs is an iterable of
1678 revision numbers, expr is a revset string built from log options
1679 and file patterns or None, and used to filter 'revs'. If --stat or
1680 --patch are not passed filematcher is None. Otherwise it is a
1681 callable taking a revision number and returning a match objects
1682 filtering the files to be detailed when displaying the revision.
1683 """
1684 limit = loglimit(opts)
1685 # Default --rev value depends on --follow but --follow behaviour
1686 # depends on revisions resolved from --rev...
1687 follow = opts.get('follow') or opts.get('follow_first')
1688 if opts.get('rev'):
1689 revs = scmutil.revrange(repo, opts['rev'])
1690 elif follow:
1691 revs = revset.baseset(repo.revs('reverse(:.)'))
1692 else:
1693 revs = revset.spanset(repo)
1694 revs.reverse()
1695 if not revs:
1696 return revset.baseset([]), None, None
1697 expr, filematcher = _makelogrevset(repo, pats, opts, revs)
1698 if expr:
1699 # Revset matchers often operate faster on revisions in changelog
1700 # order, because most filters deal with the changelog.
1701 if not opts.get('rev'):
1702 revs.reverse()
1703 matcher = revset.match(repo.ui, expr)
1704 # Revset matches can reorder revisions. "A or B" typically returns
1705 # returns the revision matching A then the revision matching B. Sort
1706 # again to fix that.
1707 revs = matcher(repo, revs)
1708 if not opts.get('rev'):
1709 revs.sort(reverse=True)
1710 if limit is not None:
1711 count = 0
1712 limitedrevs = revset.baseset([])
1713 it = iter(revs)
1714 while count < limit:
1715 try:
1716 limitedrevs.append(it.next())
1717 except (StopIteration):
1718 break
1719 count += 1
1720 revs = limitedrevs
1721
1722 return revs, expr, filematcher
1723
1676 def displaygraph(ui, dag, displayer, showparents, edgefn, getrenamed=None,
1724 def displaygraph(ui, dag, displayer, showparents, edgefn, getrenamed=None,
1677 filematcher=None):
1725 filematcher=None):
1678 seen, state = [], graphmod.asciistate()
1726 seen, state = [], graphmod.asciistate()
@@ -4082,55 +4082,22 def log(ui, repo, *pats, **opts):
4082 if opts.get('graph'):
4082 if opts.get('graph'):
4083 return cmdutil.graphlog(ui, repo, *pats, **opts)
4083 return cmdutil.graphlog(ui, repo, *pats, **opts)
4084
4084
4085 matchfn = scmutil.match(repo[None], pats, opts)
4085 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4086 limit = cmdutil.loglimit(opts)
4086 limit = cmdutil.loglimit(opts)
4087 count = 0
4087 count = 0
4088
4088
4089 getrenamed, endrev = None, None
4089 getrenamed = None
4090 if opts.get('copies'):
4090 if opts.get('copies'):
4091 endrev = None
4091 if opts.get('rev'):
4092 if opts.get('rev'):
4092 endrev = max(scmutil.revrange(repo, opts.get('rev'))) + 1
4093 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4093 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4094 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4094
4095
4095 df = False
4096 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4096 if opts.get("date"):
4097 for rev in revs:
4097 df = util.matchdate(opts["date"])
4098 if count == limit:
4098
4099 branches = opts.get('branch', []) + opts.get('only_branch', [])
4100 opts['branch'] = [repo.lookupbranch(b) for b in branches]
4101
4102 displayer = cmdutil.show_changeset(ui, repo, opts, True)
4103 def prep(ctx, fns):
4104 rev = ctx.rev()
4105 parents = [p for p in repo.changelog.parentrevs(rev)
4106 if p != nullrev]
4107 if opts.get('no_merges') and len(parents) == 2:
4108 return
4109 if opts.get('only_merges') and len(parents) != 2:
4110 return
4111 if opts.get('branch') and ctx.branch() not in opts['branch']:
4112 return
4113 if df and not df(ctx.date()[0]):
4114 return
4115
4116 lower = encoding.lower
4117 if opts.get('user'):
4118 luser = lower(ctx.user())
4119 for k in [lower(x) for x in opts['user']]:
4120 if (k in luser):
4121 break
4099 break
4122 else:
4100 ctx = repo[rev]
4123 return
4124 if opts.get('keyword'):
4125 luser = lower(ctx.user())
4126 ldesc = lower(ctx.description())
4127 lfiles = lower(" ".join(ctx.files()))
4128 for k in [lower(x) for x in opts['keyword']]:
4129 if (k in luser or k in ldesc or k in lfiles):
4130 break
4131 else:
4132 return
4133
4134 copies = None
4101 copies = None
4135 if getrenamed is not None and rev:
4102 if getrenamed is not None and rev:
4136 copies = []
4103 copies = []
@@ -4138,22 +4105,11 def log(ui, repo, *pats, **opts):
4138 rename = getrenamed(fn, rev)
4105 rename = getrenamed(fn, rev)
4139 if rename:
4106 if rename:
4140 copies.append((fn, rename[0]))
4107 copies.append((fn, rename[0]))
4141
4108 revmatchfn = filematcher and filematcher(ctx.rev()) or None
4142 revmatchfn = None
4143 if opts.get('patch') or opts.get('stat'):
4144 if opts.get('follow') or opts.get('follow_first'):
4145 # note: this might be wrong when following through merges
4146 revmatchfn = scmutil.match(repo[None], fns, default='path')
4147 else:
4148 revmatchfn = matchfn
4149
4150 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4109 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4151
4110 if displayer.flush(rev):
4152 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
4153 if displayer.flush(ctx.rev()):
4154 count += 1
4111 count += 1
4155 if count == limit:
4112
4156 break
4157 displayer.close()
4113 displayer.close()
4158
4114
4159 @command('manifest',
4115 @command('manifest',
@@ -1972,8 +1972,9 Test --follow and forward --rev
1972 +++ glog.nodes * (glob)
1972 +++ glog.nodes * (glob)
1973 @@ -1,3 +1,3 @@
1973 @@ -1,3 +1,3 @@
1974 -nodetag 6
1974 -nodetag 6
1975 -nodetag 7
1975 nodetag 8
1976 nodetag 8
1976 nodetag 7
1977 +nodetag 7
1977 +nodetag 6
1978 +nodetag 6
1978
1979
1979 Test --follow-first and forward --rev
1980 Test --follow-first and forward --rev
@@ -1988,8 +1989,9 Test --follow-first and forward --rev
1988 +++ glog.nodes * (glob)
1989 +++ glog.nodes * (glob)
1989 @@ -1,3 +1,3 @@
1990 @@ -1,3 +1,3 @@
1990 -nodetag 6
1991 -nodetag 6
1992 -nodetag 7
1991 nodetag 8
1993 nodetag 8
1992 nodetag 7
1994 +nodetag 7
1993 +nodetag 6
1995 +nodetag 6
1994
1996
1995 Test --follow and backward --rev
1997 Test --follow and backward --rev
General Comments 0
You need to be logged in to leave comments. Login now