Show More
@@ -94,7 +94,7 b" nokwcommands = ('add addremove bundle co" | |||
|
94 | 94 | |
|
95 | 95 | # hg commands that trigger expansion only when writing to working dir, |
|
96 | 96 | # not when reading filelog, and unexpand when reading from working dir |
|
97 |
restricted = ' |
|
|
97 | restricted = 'record qfold qimport qnew qpush qrefresh qrecord' | |
|
98 | 98 | |
|
99 | 99 | def utcdate(date): |
|
100 | 100 | '''Returns hgdate in cvs-like UTC format.''' |
@@ -105,6 +105,7 b' def utcdate(date):' | |||
|
105 | 105 | |
|
106 | 106 | # store originals of monkeypatches |
|
107 | 107 | _patchfile_init = patch.patchfile.__init__ |
|
108 | _patch_diff = patch.diff | |
|
108 | 109 | _dispatch_parse = dispatch._parse |
|
109 | 110 | |
|
110 | 111 | def _kwpatchfile_init(self, ui, fname, missing=False): |
@@ -116,6 +117,16 b' def _kwpatchfile_init(self, ui, fname, m' | |||
|
116 | 117 | kwshrunk = _kwtemplater.shrink(''.join(self.lines)) |
|
117 | 118 | self.lines = kwshrunk.splitlines(True) |
|
118 | 119 | |
|
120 | def _kw_diff(repo, node1=None, node2=None, files=None, match=util.always, | |
|
121 | fp=None, changes=None, opts=None): | |
|
122 | # only expand if comparing against working dir | |
|
123 | if node2 is not None: | |
|
124 | _kwtemplater.matcher = util.never | |
|
125 | if node1 is not None and node1 != repo.changectx().node(): | |
|
126 | _kwtemplater.restrict = True | |
|
127 | _patch_diff(repo, node1=node1, node2=node2, files=files, match=match, | |
|
128 | fp=fp, changes=changes, opts=opts) | |
|
129 | ||
|
119 | 130 | def _kwweb_changeset(web, req, tmpl): |
|
120 | 131 | '''Wraps webcommands.changeset turning off keyword expansion.''' |
|
121 | 132 | _kwtemplater.matcher = util.never |
@@ -127,11 +138,10 b' def _kwweb_filediff(web, req, tmpl):' | |||
|
127 | 138 | return web.filediff(tmpl, web.filectx(req)) |
|
128 | 139 | |
|
129 | 140 | def _kwdispatch_parse(ui, args): |
|
130 | '''Monkeypatch dispatch._parse to obtain | |
|
131 | current command and command options (global _cmd, _cmdoptions).''' | |
|
132 | global _cmd, _cmdoptions | |
|
133 |
_cmd, func, args, options, |
|
|
134 | return _cmd, func, args, options, _cmdoptions | |
|
141 | '''Monkeypatch dispatch._parse to obtain running hg command.''' | |
|
142 | global _cmd | |
|
143 | _cmd, func, args, options, cmdoptions = _dispatch_parse(ui, args) | |
|
144 | return _cmd, func, args, options, cmdoptions | |
|
135 | 145 | |
|
136 | 146 | # dispatch._parse is run before reposetup, so wrap it here |
|
137 | 147 | dispatch._parse = _kwdispatch_parse |
@@ -434,10 +444,9 b' def reposetup(ui, repo):' | |||
|
434 | 444 | files configured at all for keyword substitution.''' |
|
435 | 445 | |
|
436 | 446 | global _kwtemplater |
|
437 | hgcmd, hgcmdopts = _cmd, _cmdoptions | |
|
438 | 447 | |
|
439 | 448 | try: |
|
440 |
if (not repo.local() or |
|
|
449 | if (not repo.local() or _cmd in nokwcommands.split() | |
|
441 | 450 | or '.hg' in util.splitpath(repo.root) |
|
442 | 451 | or repo._url.startswith('bundle:')): |
|
443 | 452 | return |
@@ -453,16 +462,7 b' def reposetup(ui, repo):' | |||
|
453 | 462 | if not inc: |
|
454 | 463 | return |
|
455 | 464 | |
|
456 | if hgcmd == 'diff': | |
|
457 | # only expand if comparing against working dir | |
|
458 | node1, node2 = cmdutil.revpair(repo, hgcmdopts.get('rev')) | |
|
459 | if node2 is not None: | |
|
460 | return | |
|
461 | # shrink if rev is not current node | |
|
462 | if node1 is not None and node1 != repo.changectx().node(): | |
|
463 | hgcmd = 'diff1' | |
|
464 | ||
|
465 | _kwtemplater = kwtemplater(ui, repo, inc, exc, hgcmd) | |
|
465 | _kwtemplater = kwtemplater(ui, repo, inc, exc, _cmd) | |
|
466 | 466 | |
|
467 | 467 | class kwrepo(repo.__class__): |
|
468 | 468 | def file(self, f, kwmatch=False): |
@@ -523,6 +523,7 b' def reposetup(ui, repo):' | |||
|
523 | 523 | |
|
524 | 524 | repo.__class__ = kwrepo |
|
525 | 525 | patch.patchfile.__init__ = _kwpatchfile_init |
|
526 | patch.diff = _kw_diff | |
|
526 | 527 | webcommands.changeset = webcommands.rev = _kwweb_changeset |
|
527 | 528 | webcommands.filediff = webcommands.diff = _kwweb_filediff |
|
528 | 529 |
General Comments 0
You need to be logged in to leave comments.
Login now