92 import getopt, os, re, shutil, tempfile, time |
92 import getopt, os, re, shutil, tempfile, time |
93 |
93 |
94 commands.optionalrepo += ' kwdemo' |
94 commands.optionalrepo += ' kwdemo' |
95 |
95 |
96 # hg commands that do not act on keywords |
96 # hg commands that do not act on keywords |
97 nokwcommands = ('add addremove bundle copy export grep incoming init' |
97 nokwcommands = ('add addremove annotate bundle copy export grep incoming init' |
98 ' log outgoing push rename rollback tip' |
98 ' log outgoing push rename rollback tip' |
99 ' convert email glog') |
99 ' convert email glog') |
100 |
100 |
101 # hg commands that trigger expansion only when writing to working dir, |
101 # hg commands that trigger expansion only when writing to working dir, |
102 # not when reading filelog, and unexpand when reading from working dir |
102 # not when reading filelog, and unexpand when reading from working dir |
701 patch_diff = patch.diff |
701 patch_diff = patch.diff |
702 patch.diff = kw_diff |
702 patch.diff = kw_diff |
703 |
703 |
704 try: |
704 try: |
705 from mercurial.hgweb import webcommands |
705 from mercurial.hgweb import webcommands |
|
706 def kwweb_annotate(web, req, tmpl): |
|
707 '''Wraps webcommands.annotate turning off keyword expansion.''' |
|
708 kwt.matcher = util.never |
|
709 return webcommands_annotate(web, req, tmpl) |
|
710 |
706 def kwweb_changeset(web, req, tmpl): |
711 def kwweb_changeset(web, req, tmpl): |
707 '''Wraps webcommands.changeset turning off keyword expansion.''' |
712 '''Wraps webcommands.changeset turning off keyword expansion.''' |
708 kwt.matcher = util.never |
713 kwt.matcher = util.never |
709 return webcommands_changeset(web, req, tmpl) |
714 return webcommands_changeset(web, req, tmpl) |
710 |
715 |
711 def kwweb_filediff(web, req, tmpl): |
716 def kwweb_filediff(web, req, tmpl): |
712 '''Wraps webcommands.filediff turning off keyword expansion.''' |
717 '''Wraps webcommands.filediff turning off keyword expansion.''' |
713 kwt.matcher = util.never |
718 kwt.matcher = util.never |
714 return webcommands_filediff(web, req, tmpl) |
719 return webcommands_filediff(web, req, tmpl) |
715 |
720 |
|
721 webcommands_annotate = webcommands.annotate |
716 webcommands_changeset = webcommands.changeset |
722 webcommands_changeset = webcommands.changeset |
717 webcommands_filediff = webcommands.filediff |
723 webcommands_filediff = webcommands.filediff |
|
724 |
|
725 webcommands.annotate = kwweb_annotate |
718 webcommands.changeset = webcommands.rev = kwweb_changeset |
726 webcommands.changeset = webcommands.rev = kwweb_changeset |
719 webcommands.filediff = webcommands.diff = kwweb_filediff |
727 webcommands.filediff = webcommands.diff = kwweb_filediff |
720 |
728 |
721 except ImportError: |
729 except ImportError: |
722 from mercurial.hgweb.hgweb_mod import hgweb |
730 from mercurial.hgweb.hgweb_mod import hgweb |
|
731 def kwweb_do_annotate(self, req): |
|
732 kwt.matcher = util.never |
|
733 hgweb_do_annotate(self, req) |
|
734 |
723 def kwweb_do_changeset(self, req): |
735 def kwweb_do_changeset(self, req): |
724 kwt.matcher = util.never |
736 kwt.matcher = util.never |
725 hgweb_do_changeset(self, req) |
737 hgweb_do_changeset(self, req) |
726 |
738 |
727 def kwweb_do_filediff(self, req): |
739 def kwweb_do_filediff(self, req): |
728 kwt.matcher = util.never |
740 kwt.matcher = util.never |
729 hgweb_do_filediff(self, req) |
741 hgweb_do_filediff(self, req) |
730 |
742 |
|
743 hgweb_do_annotate = hgweb.do_annotate |
731 hgweb_do_changeset = hgweb.do_changeset |
744 hgweb_do_changeset = hgweb.do_changeset |
732 hgweb_do_filediff = hgweb.do_filediff |
745 hgweb_do_filediff = hgweb.do_filediff |
|
746 |
|
747 hgweb.do_annotate = kwweb_do_annotate |
733 hgweb.do_changeset = hgweb.do_rev = kwweb_do_changeset |
748 hgweb.do_changeset = hgweb.do_rev = kwweb_do_changeset |
734 hgweb.do_filediff = hgweb.do_diff = kwweb_do_filediff |
749 hgweb.do_filediff = hgweb.do_diff = kwweb_do_filediff |
735 |
750 |
736 |
751 |
737 cmdtable = { |
752 cmdtable = { |