Show More
@@ -389,22 +389,20 b' def overridelog(orig, ui, repo, *pats, *' | |||||
389 | # (2) to determine what files to print out diffs for. |
|
389 | # (2) to determine what files to print out diffs for. | |
390 | # The magic matchandpats override should be used for case (1) but not for |
|
390 | # The magic matchandpats override should be used for case (1) but not for | |
391 | # case (2). |
|
391 | # case (2). | |
392 |
def overridemake |
|
392 | def overridemakefilematcher(repo, pats, opts, badfn=None): | |
393 | wctx = repo[None] |
|
393 | wctx = repo[None] | |
394 | match, pats = oldmatchandpats(wctx, pats, opts, badfn=badfn) |
|
394 | match, pats = oldmatchandpats(wctx, pats, opts, badfn=badfn) | |
395 | return lambda rev: match |
|
395 | return lambda rev: match | |
396 |
|
396 | |||
397 | oldmatchandpats = installmatchandpatsfn(overridematchandpats) |
|
397 | oldmatchandpats = installmatchandpatsfn(overridematchandpats) | |
398 |
oldmake |
|
398 | oldmakefilematcher = logcmdutil._makenofollowfilematcher | |
399 |
setattr(logcmdutil, '_makenofollow |
|
399 | setattr(logcmdutil, '_makenofollowfilematcher', overridemakefilematcher) | |
400 | overridemakelogfilematcher) |
|
|||
401 |
|
400 | |||
402 | try: |
|
401 | try: | |
403 | return orig(ui, repo, *pats, **opts) |
|
402 | return orig(ui, repo, *pats, **opts) | |
404 | finally: |
|
403 | finally: | |
405 | restorematchandpatsfn() |
|
404 | restorematchandpatsfn() | |
406 |
setattr(logcmdutil, '_makenofollow |
|
405 | setattr(logcmdutil, '_makenofollowfilematcher', oldmakefilematcher) | |
407 | oldmakelogfilematcher) |
|
|||
408 |
|
406 | |||
409 | def overrideverify(orig, ui, repo, *pats, **opts): |
|
407 | def overrideverify(orig, ui, repo, *pats, **opts): | |
410 | large = opts.pop(r'large', False) |
|
408 | large = opts.pop(r'large', False) |
@@ -126,7 +126,7 b' def _setuplog(ui):' | |||||
126 | entry[1].append(('', 'sparse', None, |
|
126 | entry[1].append(('', 'sparse', None, | |
127 | "limit to changesets affecting the sparse checkout")) |
|
127 | "limit to changesets affecting the sparse checkout")) | |
128 |
|
128 | |||
129 |
def _l |
|
129 | def _initialrevs(orig, repo, opts): | |
130 | revs = orig(repo, opts) |
|
130 | revs = orig(repo, opts) | |
131 | if opts.get('sparse'): |
|
131 | if opts.get('sparse'): | |
132 | sparsematch = sparse.matcher(repo) |
|
132 | sparsematch = sparse.matcher(repo) | |
@@ -135,7 +135,7 b' def _setuplog(ui):' | |||||
135 | return any(f for f in ctx.files() if sparsematch(f)) |
|
135 | return any(f for f in ctx.files() if sparsematch(f)) | |
136 | revs = revs.filter(ctxmatch) |
|
136 | revs = revs.filter(ctxmatch) | |
137 | return revs |
|
137 | return revs | |
138 |
extensions.wrapfunction(logcmdutil, '_l |
|
138 | extensions.wrapfunction(logcmdutil, '_initialrevs', _initialrevs) | |
139 |
|
139 | |||
140 | def _clonesparsecmd(orig, ui, repo, *args, **opts): |
|
140 | def _clonesparsecmd(orig, ui, repo, *args, **opts): | |
141 | include_pat = opts.get('include') |
|
141 | include_pat = opts.get('include') |
@@ -46,17 +46,17 b' from . import (' | |||||
46 | ) |
|
46 | ) | |
47 | stringio = util.stringio |
|
47 | stringio = util.stringio | |
48 |
|
48 | |||
49 |
loglimit = logcmdutil. |
|
49 | loglimit = logcmdutil.getlimit | |
50 | diffordiffstat = logcmdutil.diffordiffstat |
|
50 | diffordiffstat = logcmdutil.diffordiffstat | |
51 | _changesetlabels = logcmdutil.changesetlabels |
|
51 | _changesetlabels = logcmdutil.changesetlabels | |
52 | changeset_printer = logcmdutil.changesetprinter |
|
52 | changeset_printer = logcmdutil.changesetprinter | |
53 | jsonchangeset = logcmdutil.jsonchangeset |
|
53 | jsonchangeset = logcmdutil.jsonchangeset | |
54 | changeset_templater = logcmdutil.changesettemplater |
|
54 | changeset_templater = logcmdutil.changesettemplater | |
55 |
logtemplatespec = logcmdutil. |
|
55 | logtemplatespec = logcmdutil.templatespec | |
56 |
makelogtemplater = logcmdutil.make |
|
56 | makelogtemplater = logcmdutil.maketemplater | |
57 | show_changeset = logcmdutil.changesetdisplayer |
|
57 | show_changeset = logcmdutil.changesetdisplayer | |
58 |
getlogrevs = logcmdutil.get |
|
58 | getlogrevs = logcmdutil.getrevs | |
59 |
getloglinerangerevs = logcmdutil.getl |
|
59 | getloglinerangerevs = logcmdutil.getlinerangerevs | |
60 | displaygraph = logcmdutil.displaygraph |
|
60 | displaygraph = logcmdutil.displaygraph | |
61 | graphlog = logcmdutil.graphlog |
|
61 | graphlog = logcmdutil.graphlog | |
62 | checkunsupportedgraphflags = logcmdutil.checkunsupportedgraphflags |
|
62 | checkunsupportedgraphflags = logcmdutil.checkunsupportedgraphflags |
@@ -36,7 +36,7 b' from . import (' | |||||
36 | util, |
|
36 | util, | |
37 | ) |
|
37 | ) | |
38 |
|
38 | |||
39 |
def |
|
39 | def getlimit(opts): | |
40 | """get the log limit according to option -l/--limit""" |
|
40 | """get the log limit according to option -l/--limit""" | |
41 | limit = opts.get('limit') |
|
41 | limit = opts.get('limit') | |
42 | if limit: |
|
42 | if limit: | |
@@ -391,7 +391,7 b' class changesettemplater(changesetprinte' | |||||
391 |
|
391 | |||
392 | Note: there are a variety of convenience functions to build a |
|
392 | Note: there are a variety of convenience functions to build a | |
393 | changesettemplater for common cases. See functions such as: |
|
393 | changesettemplater for common cases. See functions such as: | |
394 |
make |
|
394 | maketemplater, changesetdisplayer, buildcommittemplate, or other | |
395 | functions that use changesest_templater. |
|
395 | functions that use changesest_templater. | |
396 | ''' |
|
396 | ''' | |
397 |
|
397 | |||
@@ -478,13 +478,13 b' class changesettemplater(changesetprinte' | |||||
478 | self.footer = templater.stringify( |
|
478 | self.footer = templater.stringify( | |
479 | self.t(self._parts['footer'], **props)) |
|
479 | self.t(self._parts['footer'], **props)) | |
480 |
|
480 | |||
481 |
def |
|
481 | def templatespec(tmpl, mapfile): | |
482 | if mapfile: |
|
482 | if mapfile: | |
483 | return formatter.templatespec('changeset', tmpl, mapfile) |
|
483 | return formatter.templatespec('changeset', tmpl, mapfile) | |
484 | else: |
|
484 | else: | |
485 | return formatter.templatespec('', tmpl, None) |
|
485 | return formatter.templatespec('', tmpl, None) | |
486 |
|
486 | |||
487 |
def _lookup |
|
487 | def _lookuptemplate(ui, tmpl, style): | |
488 | """Find the template matching the given template spec or style |
|
488 | """Find the template matching the given template spec or style | |
489 |
|
489 | |||
490 | See formatter.lookuptemplate() for details. |
|
490 | See formatter.lookuptemplate() for details. | |
@@ -494,7 +494,7 b' def _lookuplogtemplate(ui, tmpl, style):' | |||||
494 | if not tmpl and not style: # template are stronger than style |
|
494 | if not tmpl and not style: # template are stronger than style | |
495 | tmpl = ui.config('ui', 'logtemplate') |
|
495 | tmpl = ui.config('ui', 'logtemplate') | |
496 | if tmpl: |
|
496 | if tmpl: | |
497 |
return |
|
497 | return templatespec(templater.unquotestring(tmpl), None) | |
498 | else: |
|
498 | else: | |
499 | style = util.expandpath(ui.config('ui', 'style')) |
|
499 | style = util.expandpath(ui.config('ui', 'style')) | |
500 |
|
500 | |||
@@ -505,17 +505,17 b' def _lookuplogtemplate(ui, tmpl, style):' | |||||
505 | or templater.templatepath(mapfile)) |
|
505 | or templater.templatepath(mapfile)) | |
506 | if mapname: |
|
506 | if mapname: | |
507 | mapfile = mapname |
|
507 | mapfile = mapname | |
508 |
return |
|
508 | return templatespec(None, mapfile) | |
509 |
|
509 | |||
510 | if not tmpl: |
|
510 | if not tmpl: | |
511 |
return |
|
511 | return templatespec(None, None) | |
512 |
|
512 | |||
513 | return formatter.lookuptemplate(ui, 'changeset', tmpl) |
|
513 | return formatter.lookuptemplate(ui, 'changeset', tmpl) | |
514 |
|
514 | |||
515 |
def make |
|
515 | def maketemplater(ui, repo, tmpl, buffered=False): | |
516 | """Create a changesettemplater from a literal template 'tmpl' |
|
516 | """Create a changesettemplater from a literal template 'tmpl' | |
517 | byte-string.""" |
|
517 | byte-string.""" | |
518 |
spec = |
|
518 | spec = templatespec(tmpl, None) | |
519 | return changesettemplater(ui, repo, spec, buffered=buffered) |
|
519 | return changesettemplater(ui, repo, spec, buffered=buffered) | |
520 |
|
520 | |||
521 | def changesetdisplayer(ui, repo, opts, buffered=False): |
|
521 | def changesetdisplayer(ui, repo, opts, buffered=False): | |
@@ -537,14 +537,14 b' def changesetdisplayer(ui, repo, opts, b' | |||||
537 | if opts.get('template') == 'json': |
|
537 | if opts.get('template') == 'json': | |
538 | return jsonchangeset(ui, repo, match, opts, buffered) |
|
538 | return jsonchangeset(ui, repo, match, opts, buffered) | |
539 |
|
539 | |||
540 |
spec = _lookup |
|
540 | spec = _lookuptemplate(ui, opts.get('template'), opts.get('style')) | |
541 |
|
541 | |||
542 | if not spec.ref and not spec.tmpl and not spec.mapfile: |
|
542 | if not spec.ref and not spec.tmpl and not spec.mapfile: | |
543 | return changesetprinter(ui, repo, match, opts, buffered) |
|
543 | return changesetprinter(ui, repo, match, opts, buffered) | |
544 |
|
544 | |||
545 | return changesettemplater(ui, repo, spec, match, opts, buffered) |
|
545 | return changesettemplater(ui, repo, spec, match, opts, buffered) | |
546 |
|
546 | |||
547 |
def _make |
|
547 | def _makematcher(repo, revs, pats, opts): | |
548 | """Build matcher and expanded patterns from log options |
|
548 | """Build matcher and expanded patterns from log options | |
549 |
|
549 | |||
550 | If --follow, revs are the revisions to follow from. |
|
550 | If --follow, revs are the revisions to follow from. | |
@@ -625,7 +625,7 b' def _fileancestors(repo, revs, match, fo' | |||||
625 | yield rev |
|
625 | yield rev | |
626 | return smartset.generatorset(revgen(), iterasc=False), filematcher |
|
626 | return smartset.generatorset(revgen(), iterasc=False), filematcher | |
627 |
|
627 | |||
628 |
def _makenofollow |
|
628 | def _makenofollowfilematcher(repo, pats, opts): | |
629 | '''hook for extensions to override the filematcher for non-follow cases''' |
|
629 | '''hook for extensions to override the filematcher for non-follow cases''' | |
630 | return None |
|
630 | return None | |
631 |
|
631 | |||
@@ -641,7 +641,7 b' def _makenofollowlogfilematcher(repo, pa' | |||||
641 | 'user': ('user(%s)', '%lr'), |
|
641 | 'user': ('user(%s)', '%lr'), | |
642 | } |
|
642 | } | |
643 |
|
643 | |||
644 |
def _make |
|
644 | def _makerevset(repo, match, pats, slowpath, opts): | |
645 | """Return a revset string built from log options and file patterns""" |
|
645 | """Return a revset string built from log options and file patterns""" | |
646 | opts = dict(opts) |
|
646 | opts = dict(opts) | |
647 | # follow or not follow? |
|
647 | # follow or not follow? | |
@@ -694,7 +694,7 b' def _makelogrevset(repo, match, pats, sl' | |||||
694 | expr = None |
|
694 | expr = None | |
695 | return expr |
|
695 | return expr | |
696 |
|
696 | |||
697 |
def _l |
|
697 | def _initialrevs(repo, opts): | |
698 | """Return the initial set of revisions to be filtered or followed""" |
|
698 | """Return the initial set of revisions to be filtered or followed""" | |
699 | follow = opts.get('follow') or opts.get('follow_first') |
|
699 | follow = opts.get('follow') or opts.get('follow_first') | |
700 | if opts.get('rev'): |
|
700 | if opts.get('rev'): | |
@@ -708,7 +708,7 b' def _logrevs(repo, opts):' | |||||
708 | revs.reverse() |
|
708 | revs.reverse() | |
709 | return revs |
|
709 | return revs | |
710 |
|
710 | |||
711 |
def get |
|
711 | def getrevs(repo, pats, opts): | |
712 | """Return (revs, filematcher) where revs is a smartset |
|
712 | """Return (revs, filematcher) where revs is a smartset | |
713 |
|
713 | |||
714 | filematcher is a callable taking a revision number and returning a match |
|
714 | filematcher is a callable taking a revision number and returning a match | |
@@ -716,11 +716,11 b' def getlogrevs(repo, pats, opts):' | |||||
716 | """ |
|
716 | """ | |
717 | follow = opts.get('follow') or opts.get('follow_first') |
|
717 | follow = opts.get('follow') or opts.get('follow_first') | |
718 | followfirst = opts.get('follow_first') |
|
718 | followfirst = opts.get('follow_first') | |
719 |
limit = |
|
719 | limit = getlimit(opts) | |
720 |
revs = _l |
|
720 | revs = _initialrevs(repo, opts) | |
721 | if not revs: |
|
721 | if not revs: | |
722 | return smartset.baseset(), None |
|
722 | return smartset.baseset(), None | |
723 |
match, pats, slowpath = _make |
|
723 | match, pats, slowpath = _makematcher(repo, revs, pats, opts) | |
724 | filematcher = None |
|
724 | filematcher = None | |
725 | if follow: |
|
725 | if follow: | |
726 | if slowpath or match.always(): |
|
726 | if slowpath or match.always(): | |
@@ -729,15 +729,15 b' def getlogrevs(repo, pats, opts):' | |||||
729 | revs, filematcher = _fileancestors(repo, revs, match, followfirst) |
|
729 | revs, filematcher = _fileancestors(repo, revs, match, followfirst) | |
730 | revs.reverse() |
|
730 | revs.reverse() | |
731 | if filematcher is None: |
|
731 | if filematcher is None: | |
732 |
filematcher = _makenofollow |
|
732 | filematcher = _makenofollowfilematcher(repo, pats, opts) | |
733 | if filematcher is None: |
|
733 | if filematcher is None: | |
734 | def filematcher(rev): |
|
734 | def filematcher(rev): | |
735 | return match |
|
735 | return match | |
736 |
|
736 | |||
737 |
expr = _make |
|
737 | expr = _makerevset(repo, match, pats, slowpath, opts) | |
738 | if opts.get('graph') and opts.get('rev'): |
|
738 | if opts.get('graph') and opts.get('rev'): | |
739 | # User-specified revs might be unsorted, but don't sort before |
|
739 | # User-specified revs might be unsorted, but don't sort before | |
740 |
# _make |
|
740 | # _makerevset because it might depend on the order of revs | |
741 | if not (revs.isdescending() or revs.istopo()): |
|
741 | if not (revs.isdescending() or revs.istopo()): | |
742 | revs.sort(reverse=True) |
|
742 | revs.sort(reverse=True) | |
743 | if expr: |
|
743 | if expr: | |
@@ -747,7 +747,7 b' def getlogrevs(repo, pats, opts):' | |||||
747 | revs = revs.slice(0, limit) |
|
747 | revs = revs.slice(0, limit) | |
748 | return revs, filematcher |
|
748 | return revs, filematcher | |
749 |
|
749 | |||
750 |
def _parselinerange |
|
750 | def _parselinerangeopt(repo, opts): | |
751 | """Parse --line-range log option and return a list of tuples (filename, |
|
751 | """Parse --line-range log option and return a list of tuples (filename, | |
752 | (fromline, toline)). |
|
752 | (fromline, toline)). | |
753 | """ |
|
753 | """ | |
@@ -767,7 +767,7 b' def _parselinerangelogopt(repo, opts):' | |||||
767 | (fname, util.processlinerange(fromline, toline))) |
|
767 | (fname, util.processlinerange(fromline, toline))) | |
768 | return linerangebyfname |
|
768 | return linerangebyfname | |
769 |
|
769 | |||
770 |
def getl |
|
770 | def getlinerangerevs(repo, userrevs, opts): | |
771 | """Return (revs, filematcher, hunksfilter). |
|
771 | """Return (revs, filematcher, hunksfilter). | |
772 |
|
772 | |||
773 | "revs" are revisions obtained by processing "line-range" log options and |
|
773 | "revs" are revisions obtained by processing "line-range" log options and | |
@@ -785,7 +785,7 b' def getloglinerangerevs(repo, userrevs, ' | |||||
785 |
|
785 | |||
786 | # Two-levels map of "rev -> file ctx -> [line range]". |
|
786 | # Two-levels map of "rev -> file ctx -> [line range]". | |
787 | linerangesbyrev = {} |
|
787 | linerangesbyrev = {} | |
788 |
for fname, (fromline, toline) in _parselinerange |
|
788 | for fname, (fromline, toline) in _parselinerangeopt(repo, opts): | |
789 | if fname not in wctx: |
|
789 | if fname not in wctx: | |
790 | raise error.Abort(_('cannot follow file not in parent ' |
|
790 | raise error.Abort(_('cannot follow file not in parent ' | |
791 | 'revision: "%s"') % fname) |
|
791 | 'revision: "%s"') % fname) | |
@@ -926,7 +926,7 b' def checkunsupportedgraphflags(pats, opt' | |||||
926 | % op.replace("_", "-")) |
|
926 | % op.replace("_", "-")) | |
927 |
|
927 | |||
928 | def graphrevs(repo, nodes, opts): |
|
928 | def graphrevs(repo, nodes, opts): | |
929 |
limit = |
|
929 | limit = getlimit(opts) | |
930 | nodes.reverse() |
|
930 | nodes.reverse() | |
931 | if limit is not None: |
|
931 | if limit is not None: | |
932 | nodes = nodes[:limit] |
|
932 | nodes = nodes[:limit] |
@@ -93,11 +93,11 b' o (0) root' | |||||
93 | > ) |
|
93 | > ) | |
94 | > |
|
94 | > | |
95 | > def logrevset(repo, pats, opts): |
|
95 | > def logrevset(repo, pats, opts): | |
96 |
> revs = logcmdutil._l |
|
96 | > revs = logcmdutil._initialrevs(repo, opts) | |
97 | > if not revs: |
|
97 | > if not revs: | |
98 | > return None |
|
98 | > return None | |
99 |
> match, pats, slowpath = logcmdutil._make |
|
99 | > match, pats, slowpath = logcmdutil._makematcher(repo, revs, pats, opts) | |
100 |
> return logcmdutil._make |
|
100 | > return logcmdutil._makerevset(repo, match, pats, slowpath, opts) | |
101 | > |
|
101 | > | |
102 | > def uisetup(ui): |
|
102 | > def uisetup(ui): | |
103 | > def printrevset(orig, repo, pats, opts): |
|
103 | > def printrevset(orig, repo, pats, opts): |
General Comments 0
You need to be logged in to leave comments.
Login now