Mercurial > hg
comparison hgext/keyword.py @ 6051:1038b1458d7a
keyword: safeguards against erroneous behaviour or aborts
prevent issues due to global [keyword] filename patterns:
- add email to nokwcommands
- protect everything under .hg from expansion
(tested with qcommit)
- exclude everything starting with .hg* just in case
prevent abort when pulling from bundlerepo:
- do not set up kwrepo for bundlerepo
expansion inside a bundle is nonsense
bundlerepo issue spotted and test case provided by pmezard.
author | Christian Ebert <blacktrash@gmx.net> |
---|---|
date | Wed, 06 Feb 2008 23:14:33 +0100 |
parents | adf73753eb7d |
children | 75425961e955 |
comparison
equal
deleted
inserted
replaced
6050:adf73753eb7d | 6051:1038b1458d7a |
---|---|
86 | 86 |
87 commands.optionalrepo += ' kwdemo' | 87 commands.optionalrepo += ' kwdemo' |
88 | 88 |
89 # hg commands that do not act on keywords | 89 # hg commands that do not act on keywords |
90 nokwcommands = ('add addremove bundle copy export grep identify incoming init' | 90 nokwcommands = ('add addremove bundle copy export grep identify incoming init' |
91 ' log outgoing push remove rename rollback tip convert') | 91 ' log outgoing push remove rename rollback tip convert email') |
92 | 92 |
93 # hg commands that trigger expansion only when writing to working dir, | 93 # hg commands that trigger expansion only when writing to working dir, |
94 # not when reading filelog, and unexpand when reading from working dir | 94 # not when reading filelog, and unexpand when reading from working dir |
95 restricted = 'diff1 record qfold qimport qnew qpush qrefresh qrecord' | 95 restricted = 'diff1 record qfold qimport qnew qpush qrefresh qrecord' |
96 | 96 |
408 Wraps commit to overwrite configured files with updated | 408 Wraps commit to overwrite configured files with updated |
409 keyword substitutions. | 409 keyword substitutions. |
410 This is done for local repos only, and only if there are | 410 This is done for local repos only, and only if there are |
411 files configured at all for keyword substitution.''' | 411 files configured at all for keyword substitution.''' |
412 | 412 |
413 if not repo.local(): | 413 try: |
414 return | 414 if (not repo.local() or '.hg' in repo.root.split('/') |
415 or repo._url.startswith('bundle:')): | |
416 return | |
417 except AttributeError: | |
418 pass | |
415 | 419 |
416 hgcmd, func, args, opts, cmdopts = dispatch._parse(ui, sys.argv[1:]) | 420 hgcmd, func, args, opts, cmdopts = dispatch._parse(ui, sys.argv[1:]) |
417 if hgcmd in nokwcommands.split(): | 421 if hgcmd in nokwcommands.split(): |
418 return | 422 return |
419 | 423 |
424 return | 428 return |
425 # shrink if rev is not current node | 429 # shrink if rev is not current node |
426 if node1 is not None and node1 != repo.changectx().node(): | 430 if node1 is not None and node1 != repo.changectx().node(): |
427 hgcmd = 'diff1' | 431 hgcmd = 'diff1' |
428 | 432 |
429 inc, exc = [], ['.hgtags'] | 433 inc, exc = [], ['.hg*'] |
430 for pat, opt in ui.configitems('keyword'): | 434 for pat, opt in ui.configitems('keyword'): |
431 if opt != 'ignore': | 435 if opt != 'ignore': |
432 inc.append(pat) | 436 inc.append(pat) |
433 else: | 437 else: |
434 exc.append(pat) | 438 exc.append(pat) |