85 from mercurial.node import * |
85 from mercurial.node import * |
86 from mercurial.i18n import _ |
86 from mercurial.i18n import _ |
87 import re, shutil, sys, tempfile, time |
87 import re, shutil, sys, tempfile, time |
88 |
88 |
89 commands.optionalrepo += ' kwdemo' |
89 commands.optionalrepo += ' kwdemo' |
|
90 |
|
91 # handle for external callers |
|
92 externalcall = None, None, {} |
|
93 |
|
94 # hook for external callers |
|
95 def externalcmdhook(hgcmd, *args, **opts): |
|
96 global externalcall |
|
97 externalcall = hgcmd.__name__, args, opts |
90 |
98 |
91 # hg commands that trigger expansion only when writing to working dir, |
99 # hg commands that trigger expansion only when writing to working dir, |
92 # not when reading filelog, and unexpand when reading from working dir |
100 # not when reading filelog, and unexpand when reading from working dir |
93 restricted = ('diff1', 'record', |
101 restricted = ('diff1', 'record', |
94 'qfold', 'qimport', 'qnew', 'qpush', 'qrefresh', 'qrecord') |
102 'qfold', 'qimport', 'qnew', 'qpush', 'qrefresh', 'qrecord') |
414 nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy', |
422 nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy', |
415 'export', 'grep', 'identify', 'incoming', 'init', |
423 'export', 'grep', 'identify', 'incoming', 'init', |
416 'log', 'outgoing', 'push', 'remove', 'rename', |
424 'log', 'outgoing', 'push', 'remove', 'rename', |
417 'rollback', 'tip', |
425 'rollback', 'tip', |
418 'convert') |
426 'convert') |
419 hgcmd, func, args, opts, cmdopts = dispatch._parse(ui, sys.argv[1:]) |
427 try: |
|
428 hgcmd, func, args, opts, cmdopts = dispatch._parse(ui, sys.argv[1:]) |
|
429 except cmdutil.UnknownCommand: |
|
430 hgcmd, args, cmdopts = externalcall |
|
431 if hgcmd is None: # no command was specified from outside |
|
432 raise |
420 if hgcmd in nokwcommands: |
433 if hgcmd in nokwcommands: |
421 return |
434 return |
422 |
435 |
423 if hgcmd == 'diff': |
436 if hgcmd == 'diff': |
424 # only expand if comparing against working dir |
437 # only expand if comparing against working dir |