Show More
@@ -51,7 +51,7 b' qseries.missing = red bold' | |||||
51 |
|
51 | |||
52 | import re, sys |
|
52 | import re, sys | |
53 |
|
53 | |||
54 | from mercurial import commands, cmdutil |
|
54 | from mercurial import commands, cmdutil, extensions | |
55 | from mercurial.i18n import _ |
|
55 | from mercurial.i18n import _ | |
56 |
|
56 | |||
57 | # start and stop parameters for effects |
|
57 | # start and stop parameters for effects | |
@@ -89,14 +89,14 b' def render_effects(text, *effects):' | |||||
89 | stop = '\033[' + ';'.join(stop) + 'm' |
|
89 | stop = '\033[' + ';'.join(stop) + 'm' | |
90 | return start + text + stop |
|
90 | return start + text + stop | |
91 |
|
91 | |||
92 |
def colorstatus( |
|
92 | def colorstatus(orig, ui, repo, *pats, **opts): | |
93 | '''run the status command with colored output''' |
|
93 | '''run the status command with colored output''' | |
94 |
|
94 | |||
95 | delimiter = opts['print0'] and '\0' or '\n' |
|
95 | delimiter = opts['print0'] and '\0' or '\n' | |
96 |
|
96 | |||
97 | # run status and capture it's output |
|
97 | # run status and capture it's output | |
98 | ui.pushbuffer() |
|
98 | ui.pushbuffer() | |
99 |
retval = |
|
99 | retval = orig(ui, repo, *pats, **opts) | |
100 | # filter out empty strings |
|
100 | # filter out empty strings | |
101 | lines = [ line for line in ui.popbuffer().split(delimiter) if line ] |
|
101 | lines = [ line for line in ui.popbuffer().split(delimiter) if line ] | |
102 |
|
102 | |||
@@ -139,10 +139,10 b' def colorstatus(statusfunc, ui, repo, *p' | |||||
139 | 'clean': ('none', ), |
|
139 | 'clean': ('none', ), | |
140 | 'copied': ('none', ), } |
|
140 | 'copied': ('none', ), } | |
141 |
|
141 | |||
142 |
def colorqseries( |
|
142 | def colorqseries(orig, ui, repo, *dummy, **opts): | |
143 | '''run the qseries command with colored output''' |
|
143 | '''run the qseries command with colored output''' | |
144 | ui.pushbuffer() |
|
144 | ui.pushbuffer() | |
145 |
retval = |
|
145 | retval = orig(ui, repo, **opts) | |
146 | patches = ui.popbuffer().splitlines() |
|
146 | patches = ui.popbuffer().splitlines() | |
147 | for patch in patches: |
|
147 | for patch in patches: | |
148 | patchname = patch |
|
148 | patchname = patch | |
@@ -168,58 +168,23 b' def colorqseries(qseriesfunc, ui, repo, ' | |||||
168 |
|
168 | |||
169 | def uisetup(ui): |
|
169 | def uisetup(ui): | |
170 | '''Initialize the extension.''' |
|
170 | '''Initialize the extension.''' | |
171 | nocoloropt = ('', 'no-color', None, _("don't colorize output")) |
|
171 | _setupcmd(ui, 'status', commands.table, colorstatus, _status_effects) | |
172 | _decoratecmd(ui, 'status', commands.table, colorstatus, nocoloropt) |
|
|||
173 | _configcmdeffects(ui, 'status', _status_effects); |
|
|||
174 | if ui.config('extensions', 'hgext.mq') is not None or \ |
|
172 | if ui.config('extensions', 'hgext.mq') is not None or \ | |
175 | ui.config('extensions', 'mq') is not None: |
|
173 | ui.config('extensions', 'mq') is not None: | |
176 | from hgext import mq |
|
174 | from hgext import mq | |
177 |
_ |
|
175 | _setupcmd(ui, 'qseries', mq.cmdtable, colorqseries, _patch_effects) | |
178 | _configcmdeffects(ui, 'qseries', _patch_effects); |
|
|||
179 |
|
||||
180 | def _decoratecmd(ui, cmd, table, delegate, *delegateoptions): |
|
|||
181 | '''Replace the function that implements cmd in table with a decorator. |
|
|||
182 |
|
||||
183 | The decorator that becomes the new implementation of cmd calls |
|
|||
184 | delegate. The delegate's first argument is the replaced function, |
|
|||
185 | followed by the normal Mercurial command arguments (ui, repo, ...). If |
|
|||
186 | the delegate adds command options, supply them as delegateoptions. |
|
|||
187 | ''' |
|
|||
188 | cmdkey, cmdentry = _cmdtableitem(ui, cmd, table) |
|
|||
189 | decorator = lambda ui, repo, *args, **opts: \ |
|
|||
190 | _colordecorator(delegate, cmdentry[0], |
|
|||
191 | ui, repo, *args, **opts) |
|
|||
192 | # make sure 'hg help cmd' still works |
|
|||
193 | decorator.__doc__ = cmdentry[0].__doc__ |
|
|||
194 | decoratorentry = (decorator,) + cmdentry[1:] |
|
|||
195 | for option in delegateoptions: |
|
|||
196 | decoratorentry[1].append(option) |
|
|||
197 | table[cmdkey] = decoratorentry |
|
|||
198 |
|
176 | |||
199 |
def _ |
|
177 | def _setupcmd(ui, cmd, table, func, effectsmap): | |
200 | '''Return key, value from table for cmd, or None if not found.''' |
|
178 | '''patch in command to command table and load effect map''' | |
201 | aliases, entry = cmdutil.findcmd(cmd, table) |
|
179 | def nocolor(orig, *args, **kwargs): | |
202 | for candidatekey, candidateentry in table.iteritems(): |
|
180 | if kwargs['no_color']: | |
203 | if candidateentry is entry: |
|
181 | return orig(*args, **kwargs) | |
204 | return candidatekey, entry |
|
182 | return func(orig, *args, **kwargs) | |
205 |
|
||||
206 | def _colordecorator(colorfunc, nocolorfunc, ui, repo, *args, **opts): |
|
|||
207 | '''Delegate to colorfunc or nocolorfunc, depending on conditions. |
|
|||
208 |
|
183 | |||
209 | Delegate to colorfunc unless --no-color option is set or output is not |
|
184 | entry = extensions.wrapcommand(table, cmd, nocolor) | |
210 | to a tty. |
|
185 | entry[1].append(('', 'no-color', None, _("don't colorize output"))) | |
211 | ''' |
|
|||
212 | if opts['no_color'] or not sys.stdout.isatty(): |
|
|||
213 | return nocolorfunc(ui, repo, *args, **opts) |
|
|||
214 | return colorfunc(nocolorfunc, ui, repo, *args, **opts) |
|
|||
215 |
|
186 | |||
216 | def _configcmdeffects(ui, cmdname, effectsmap): |
|
|||
217 | '''Override default effects for cmdname with those from .hgrc file. |
|
|||
218 |
|
||||
219 | Entries in the .hgrc file are in the [color] section, and look like |
|
|||
220 | 'cmdname'.'status' (for instance, 'status.modified = blue bold inverse'). |
|
|||
221 | ''' |
|
|||
222 | for status in effectsmap: |
|
187 | for status in effectsmap: | |
223 |
effects = ui.config('color', cmd |
|
188 | effects = ui.config('color', cmd + '.' + status) | |
224 | if effects: |
|
189 | if effects: | |
225 | effectsmap[status] = re.split('\W+', effects) |
|
190 | effectsmap[status] = re.split('\W+', effects) |
@@ -20,11 +20,9 b" The default is 'colorful'." | |||||
20 |
|
20 | |||
21 | import highlight |
|
21 | import highlight | |
22 | from mercurial.hgweb import webcommands, webutil, common |
|
22 | from mercurial.hgweb import webcommands, webutil, common | |
|
23 | from mercurial import extensions | |||
23 |
|
24 | |||
24 | web_filerevision = webcommands._filerevision |
|
25 | def filerevision_highlight(orig, web, tmpl, fctx): | |
25 | web_annotate = webcommands.annotate |
|
|||
26 |
|
||||
27 | def filerevision_highlight(web, tmpl, fctx): |
|
|||
28 | mt = ''.join(tmpl('mimetype', encoding=web.encoding)) |
|
26 | mt = ''.join(tmpl('mimetype', encoding=web.encoding)) | |
29 | # only pygmentize for mimetype containing 'html' so we both match |
|
27 | # only pygmentize for mimetype containing 'html' so we both match | |
30 | # 'text/html' and possibly 'application/xhtml+xml' in the future |
|
28 | # 'text/html' and possibly 'application/xhtml+xml' in the future | |
@@ -36,15 +34,15 b' def filerevision_highlight(web, tmpl, fc' | |||||
36 | if 'html' in mt: |
|
34 | if 'html' in mt: | |
37 | style = web.config('web', 'pygments_style', 'colorful') |
|
35 | style = web.config('web', 'pygments_style', 'colorful') | |
38 | highlight.pygmentize('fileline', fctx, style, tmpl) |
|
36 | highlight.pygmentize('fileline', fctx, style, tmpl) | |
39 |
return |
|
37 | return orig(web, tmpl, fctx) | |
40 |
|
38 | |||
41 | def annotate_highlight(web, req, tmpl): |
|
39 | def annotate_highlight(orig, web, req, tmpl): | |
42 | mt = ''.join(tmpl('mimetype', encoding=web.encoding)) |
|
40 | mt = ''.join(tmpl('mimetype', encoding=web.encoding)) | |
43 | if 'html' in mt: |
|
41 | if 'html' in mt: | |
44 | fctx = webutil.filectx(web.repo, req) |
|
42 | fctx = webutil.filectx(web.repo, req) | |
45 | style = web.config('web', 'pygments_style', 'colorful') |
|
43 | style = web.config('web', 'pygments_style', 'colorful') | |
46 | highlight.pygmentize('annotateline', fctx, style, tmpl) |
|
44 | highlight.pygmentize('annotateline', fctx, style, tmpl) | |
47 |
return |
|
45 | return orig(web, req, tmpl) | |
48 |
|
46 | |||
49 | def generate_css(web, req, tmpl): |
|
47 | def generate_css(web, req, tmpl): | |
50 | pg_style = web.config('web', 'pygments_style', 'colorful') |
|
48 | pg_style = web.config('web', 'pygments_style', 'colorful') | |
@@ -52,10 +50,8 b' def generate_css(web, req, tmpl):' | |||||
52 | req.respond(common.HTTP_OK, 'text/css') |
|
50 | req.respond(common.HTTP_OK, 'text/css') | |
53 | return ['/* pygments_style = %s */\n\n' % pg_style, fmter.get_style_defs('')] |
|
51 | return ['/* pygments_style = %s */\n\n' % pg_style, fmter.get_style_defs('')] | |
54 |
|
52 | |||
55 |
|
||||
56 | # monkeypatch in the new version |
|
53 | # monkeypatch in the new version | |
57 |
|
54 | extensions.wrapfunction(webcommands, '_filerevision', filerevision_highlight) | ||
58 | webcommands._filerevision = filerevision_highlight |
|
55 | extensions.wrapfunction(webcommands, 'annotate', annotate_highlight) | |
59 | webcommands.annotate = annotate_highlight |
|
|||
60 | webcommands.highlightcss = generate_css |
|
56 | webcommands.highlightcss = generate_css | |
61 | webcommands.__all__.append('highlightcss') |
|
57 | webcommands.__all__.append('highlightcss') |
@@ -27,7 +27,7 b'' | |||||
27 |
|
27 | |||
28 | import re |
|
28 | import re | |
29 | from mercurial.hgweb import hgweb_mod |
|
29 | from mercurial.hgweb import hgweb_mod | |
30 | from mercurial import templatefilters |
|
30 | from mercurial import templatefilters, extensions | |
31 | from mercurial.i18n import _ |
|
31 | from mercurial.i18n import _ | |
32 |
|
32 | |||
33 | orig_escape = templatefilters.filters["escape"] |
|
33 | orig_escape = templatefilters.filters["escape"] | |
@@ -42,9 +42,7 b' def interhg_escape(x):' | |||||
42 |
|
42 | |||
43 | templatefilters.filters["escape"] = interhg_escape |
|
43 | templatefilters.filters["escape"] = interhg_escape | |
44 |
|
44 | |||
45 | orig_refresh = hgweb_mod.hgweb.refresh |
|
45 | def interhg_refresh(orig, self): | |
46 |
|
||||
47 | def interhg_refresh(self): |
|
|||
48 | interhg_table[:] = [] |
|
46 | interhg_table[:] = [] | |
49 | for key, pattern in self.repo.ui.configitems('interhg'): |
|
47 | for key, pattern in self.repo.ui.configitems('interhg'): | |
50 | # grab the delimiter from the character after the "s" |
|
48 | # grab the delimiter from the character after the "s" | |
@@ -79,6 +77,6 b' def interhg_refresh(self):' | |||||
79 | except re.error: |
|
77 | except re.error: | |
80 | self.repo.ui.warn(_("interhg: invalid regexp for %s: %s\n") |
|
78 | self.repo.ui.warn(_("interhg: invalid regexp for %s: %s\n") | |
81 | % (key, regexp)) |
|
79 | % (key, regexp)) | |
82 |
return orig |
|
80 | return orig(self) | |
83 |
|
81 | |||
84 |
hgweb_mod.hgweb |
|
82 | extensions.wrapfunction(hgweb_mod.hgweb, 'refresh', interhg_refresh) |
@@ -78,7 +78,7 b" like CVS' $Log$, are not supported. A ke" | |||||
78 | "Log = {desc}" expands to the first line of the changeset description. |
|
78 | "Log = {desc}" expands to the first line of the changeset description. | |
79 | ''' |
|
79 | ''' | |
80 |
|
80 | |||
81 | from mercurial import commands, cmdutil, dispatch, filelog, revlog |
|
81 | from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions | |
82 | from mercurial import patch, localrepo, templater, templatefilters, util |
|
82 | from mercurial import patch, localrepo, templater, templatefilters, util | |
83 | from mercurial.hgweb import webcommands |
|
83 | from mercurial.hgweb import webcommands | |
84 | from mercurial.node import nullid, hex |
|
84 | from mercurial.node import nullid, hex | |
@@ -416,14 +416,13 b' def uisetup(ui):' | |||||
416 | kwtools['exc'].append(pat) |
|
416 | kwtools['exc'].append(pat) | |
417 |
|
417 | |||
418 | if kwtools['inc']: |
|
418 | if kwtools['inc']: | |
419 | def kwdispatch_parse(ui, args): |
|
419 | def kwdispatch_parse(orig, ui, args): | |
420 | '''Monkeypatch dispatch._parse to obtain running hg command.''' |
|
420 | '''Monkeypatch dispatch._parse to obtain running hg command.''' | |
421 |
cmd, func, args, options, cmdoptions = |
|
421 | cmd, func, args, options, cmdoptions = orig(ui, args) | |
422 | kwtools['hgcmd'] = cmd |
|
422 | kwtools['hgcmd'] = cmd | |
423 | return cmd, func, args, options, cmdoptions |
|
423 | return cmd, func, args, options, cmdoptions | |
424 |
|
424 | |||
425 | dispatch_parse = dispatch._parse |
|
425 | extensions.wrapfunction(dispatch, '_parse', kwdispatch_parse) | |
426 | dispatch._parse = kwdispatch_parse |
|
|||
427 |
|
426 | |||
428 | def reposetup(ui, repo): |
|
427 | def reposetup(ui, repo): | |
429 | '''Sets up repo as kwrepo for keyword substitution. |
|
428 | '''Sets up repo as kwrepo for keyword substitution. | |
@@ -495,14 +494,14 b' def reposetup(ui, repo):' | |||||
495 | del wlock, lock |
|
494 | del wlock, lock | |
496 |
|
495 | |||
497 | # monkeypatches |
|
496 | # monkeypatches | |
498 | def kwpatchfile_init(self, ui, fname, missing=False): |
|
497 | def kwpatchfile_init(orig, self, ui, fname, missing=False): | |
499 | '''Monkeypatch/wrap patch.patchfile.__init__ to avoid |
|
498 | '''Monkeypatch/wrap patch.patchfile.__init__ to avoid | |
500 | rejects or conflicts due to expanded keywords in working dir.''' |
|
499 | rejects or conflicts due to expanded keywords in working dir.''' | |
501 |
|
|
500 | orig(self, ui, fname, missing) | |
502 | # shrink keywords read from working dir |
|
501 | # shrink keywords read from working dir | |
503 | self.lines = kwt.shrinklines(self.fname, self.lines) |
|
502 | self.lines = kwt.shrinklines(self.fname, self.lines) | |
504 |
|
503 | |||
505 | def kw_diff(repo, node1=None, node2=None, match=None, |
|
504 | def kw_diff(orig, repo, node1=None, node2=None, match=None, | |
506 | fp=None, changes=None, opts=None): |
|
505 | fp=None, changes=None, opts=None): | |
507 | '''Monkeypatch patch.diff to avoid expansion except when |
|
506 | '''Monkeypatch patch.diff to avoid expansion except when | |
508 | comparing against working dir.''' |
|
507 | comparing against working dir.''' | |
@@ -510,37 +509,19 b' def reposetup(ui, repo):' | |||||
510 | kwt.matcher = util.never |
|
509 | kwt.matcher = util.never | |
511 | elif node1 is not None and node1 != repo['.'].node(): |
|
510 | elif node1 is not None and node1 != repo['.'].node(): | |
512 | kwt.restrict = True |
|
511 | kwt.restrict = True | |
513 |
|
|
512 | orig(repo, node1, node2, match, fp, changes, opts) | |
514 |
|
||||
515 | def kwweb_annotate(web, req, tmpl): |
|
|||
516 | '''Wraps webcommands.annotate turning off keyword expansion.''' |
|
|||
517 | kwt.matcher = util.never |
|
|||
518 | return webcommands_annotate(web, req, tmpl) |
|
|||
519 |
|
513 | |||
520 |
def kwweb_ |
|
514 | def kwweb_skip(orig, web, req, tmpl): | |
521 |
'''Wraps webcommands. |
|
515 | '''Wraps webcommands.x turning off keyword expansion.''' | |
522 | kwt.matcher = util.never |
|
516 | kwt.matcher = util.never | |
523 |
return |
|
517 | return orig(web, req, tmpl) | |
524 |
|
||||
525 | def kwweb_filediff(web, req, tmpl): |
|
|||
526 | '''Wraps webcommands.filediff turning off keyword expansion.''' |
|
|||
527 | kwt.matcher = util.never |
|
|||
528 | return webcommands_filediff(web, req, tmpl) |
|
|||
529 |
|
518 | |||
530 | repo.__class__ = kwrepo |
|
519 | repo.__class__ = kwrepo | |
531 |
|
520 | |||
532 | patchfile_init = patch.patchfile.__init__ |
|
521 | extensions.wrapfunction(patch.patchfile, '__init__', kwpatchfile_init) | |
533 | patch_diff = patch.diff |
|
522 | extensions.wrapfunction(patch, 'diff', kw_diff) | |
534 | webcommands_annotate = webcommands.annotate |
|
523 | for c in 'annotate changeset rev filediff diff'.split(): | |
535 | webcommands_changeset = webcommands.changeset |
|
524 | extensions.wrapfunction(webcommands, c, kwweb_skip) | |
536 | webcommands_filediff = webcommands.filediff |
|
|||
537 |
|
||||
538 | patch.patchfile.__init__ = kwpatchfile_init |
|
|||
539 | patch.diff = kw_diff |
|
|||
540 | webcommands.annotate = kwweb_annotate |
|
|||
541 | webcommands.changeset = webcommands.rev = kwweb_changeset |
|
|||
542 | webcommands.filediff = webcommands.diff = kwweb_filediff |
|
|||
543 |
|
||||
544 |
|
525 | |||
545 | cmdtable = { |
|
526 | cmdtable = { | |
546 | 'kwdemo': |
|
527 | 'kwdemo': |
@@ -33,7 +33,7 b' from mercurial.i18n import _' | |||||
33 | from mercurial.node import bin, hex, short |
|
33 | from mercurial.node import bin, hex, short | |
34 | from mercurial.repo import RepoError |
|
34 | from mercurial.repo import RepoError | |
35 | from mercurial import commands, cmdutil, hg, patch, revlog, util |
|
35 | from mercurial import commands, cmdutil, hg, patch, revlog, util | |
36 | from mercurial import repair |
|
36 | from mercurial import repair, extensions | |
37 | import os, sys, re, errno, urllib |
|
37 | import os, sys, re, errno, urllib | |
38 |
|
38 | |||
39 | commands.norepo += " qclone" |
|
39 | commands.norepo += " qclone" | |
@@ -2366,22 +2366,14 b' def reposetup(ui, repo):' | |||||
2366 | repo.__class__ = mqrepo |
|
2366 | repo.__class__ = mqrepo | |
2367 | repo.mq = queue(ui, repo.join("")) |
|
2367 | repo.mq = queue(ui, repo.join("")) | |
2368 |
|
2368 | |||
|
2369 | def mqimport(orig, ui, repo, *args, **kwargs): | |||
|
2370 | if hasattr(repo, 'abort_if_wdir_patched'): | |||
|
2371 | repo.abort_if_wdir_patched(_('cannot import over an applied patch'), | |||
|
2372 | kwargs.get('force')) | |||
|
2373 | return orig(ui, repo, *args, **kwargs) | |||
|
2374 | ||||
2369 | def uisetup(ui): |
|
2375 | def uisetup(ui): | |
2370 | # override import to disallow importing over patch |
|
2376 | extensions.wrapcommand(commands.table, 'import', mqimport) | |
2371 | importalias, importcmd = cmdutil.findcmd('import', commands.table) |
|
|||
2372 | for alias, cmd in commands.table.iteritems(): |
|
|||
2373 | if cmd is importcmd: |
|
|||
2374 | importkey = alias |
|
|||
2375 | break |
|
|||
2376 | orig_import = importcmd[0] |
|
|||
2377 | def mqimport(ui, repo, patch1, *patches, **opts): |
|
|||
2378 | if hasattr(repo, 'abort_if_wdir_patched'): |
|
|||
2379 | repo.abort_if_wdir_patched(_('cannot import over an applied patch'), |
|
|||
2380 | opts.get('force')) |
|
|||
2381 | orig_import(ui, repo, patch1, *patches, **opts) |
|
|||
2382 | importcmd = list(importcmd) |
|
|||
2383 | importcmd[0] = mqimport |
|
|||
2384 | commands.table[importkey] = tuple(importcmd) |
|
|||
2385 |
|
2377 | |||
2386 | seriesopts = [('s', 'summary', None, _('print first line of patch header'))] |
|
2378 | seriesopts = [('s', 'summary', None, _('print first line of patch header'))] | |
2387 |
|
2379 |
@@ -47,10 +47,10 b' them in the global .hgrc' | |||||
47 | ''' |
|
47 | ''' | |
48 |
|
48 | |||
49 | import sys, os, signal |
|
49 | import sys, os, signal | |
50 | from mercurial import dispatch, util |
|
50 | from mercurial import dispatch, util, extensions | |
51 |
|
51 | |||
52 | def uisetup(ui): |
|
52 | def uisetup(ui): | |
53 | def pagecmd(ui, options, cmd, cmdfunc): |
|
53 | def pagecmd(orig, ui, options, cmd, cmdfunc): | |
54 | p = ui.config("pager", "pager", os.environ.get("PAGER")) |
|
54 | p = ui.config("pager", "pager", os.environ.get("PAGER")) | |
55 | if p and sys.stdout.isatty() and '--debugger' not in sys.argv: |
|
55 | if p and sys.stdout.isatty() and '--debugger' not in sys.argv: | |
56 | attend = ui.configlist('pager', 'attend') |
|
56 | attend = ui.configlist('pager', 'attend') | |
@@ -59,7 +59,6 b' def uisetup(ui):' | |||||
59 | sys.stderr = sys.stdout = util.popen(p, "wb") |
|
59 | sys.stderr = sys.stdout = util.popen(p, "wb") | |
60 | if ui.configbool('pager', 'quiet'): |
|
60 | if ui.configbool('pager', 'quiet'): | |
61 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
|
61 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) | |
62 |
return o |
|
62 | return orig(ui, options, cmd, cmdfunc) | |
63 |
|
63 | |||
64 | oldrun = dispatch._runcommand |
|
64 | extensions.wrapfunction(dispatch, '_runcommand', pagecmd) | |
65 | dispatch._runcommand = pagecmd |
|
@@ -13,7 +13,7 b' For more information:' | |||||
13 | http://www.selenic.com/mercurial/wiki/index.cgi/RebaseProject |
|
13 | http://www.selenic.com/mercurial/wiki/index.cgi/RebaseProject | |
14 | ''' |
|
14 | ''' | |
15 |
|
15 | |||
16 | from mercurial import util, repair, merge, cmdutil, dispatch, commands |
|
16 | from mercurial import util, repair, merge, cmdutil, dispatch, commands, extensions | |
17 | from mercurial.commands import templateopts |
|
17 | from mercurial.commands import templateopts | |
18 | from mercurial.node import nullrev |
|
18 | from mercurial.node import nullrev | |
19 | from mercurial.i18n import _ |
|
19 | from mercurial.i18n import _ | |
@@ -352,7 +352,7 b' def buildstate(repo, dest, src, base, co' | |||||
352 | state[source] = nullrev |
|
352 | state[source] = nullrev | |
353 | return repo['.'].rev(), repo[dest].rev(), state, external |
|
353 | return repo['.'].rev(), repo[dest].rev(), state, external | |
354 |
|
354 | |||
355 |
def pull |
|
355 | def pullrebase(orig, ui, repo, *args, **opts): | |
356 | 'Call rebase after pull if the latter has been invoked with --rebase' |
|
356 | 'Call rebase after pull if the latter has been invoked with --rebase' | |
357 | if opts.get('rebase'): |
|
357 | if opts.get('rebase'): | |
358 | if opts.get('update'): |
|
358 | if opts.get('update'): | |
@@ -360,31 +360,19 b' def pulldelegate(pullfunction, repo, *ar' | |||||
360 |
|
360 | |||
361 | cmdutil.bail_if_changed(repo) |
|
361 | cmdutil.bail_if_changed(repo) | |
362 | revsprepull = len(repo) |
|
362 | revsprepull = len(repo) | |
363 |
|
|
363 | orig(ui, repo, *args, **opts) | |
364 | revspostpull = len(repo) |
|
364 | revspostpull = len(repo) | |
365 | if revspostpull > revsprepull: |
|
365 | if revspostpull > revsprepull: | |
366 |
rebase( |
|
366 | rebase(ui, repo, **opts) | |
367 | else: |
|
367 | else: | |
368 |
|
|
368 | orig(ui, repo, *args, **opts) | |
369 |
|
369 | |||
370 | def uisetup(ui): |
|
370 | def uisetup(ui): | |
371 | 'Replace pull with a decorator to provide --rebase option' |
|
371 | 'Replace pull with a decorator to provide --rebase option' | |
372 | # cribbed from color.py |
|
372 | entry = extensions.wrapcommand(commands.table, 'pull', pullrebase) | |
373 | aliases, entry = cmdutil.findcmd('pull', commands.table) |
|
373 | entry[1].append(('', 'rebase', None, | |
374 | for candidatekey, candidateentry in commands.table.iteritems(): |
|
374 | _("rebase working directory to branch head")) | |
375 | if candidateentry is entry: |
|
375 | ) | |
376 | cmdkey, cmdentry = candidatekey, entry |
|
|||
377 | break |
|
|||
378 |
|
||||
379 | decorator = lambda ui, repo, *args, **opts: \ |
|
|||
380 | pulldelegate(cmdentry[0], repo, *args, **opts) |
|
|||
381 | # make sure 'hg help cmd' still works |
|
|||
382 | decorator.__doc__ = cmdentry[0].__doc__ |
|
|||
383 | decoratorentry = (decorator,) + cmdentry[1:] |
|
|||
384 | rebaseopt = ('', 'rebase', None, |
|
|||
385 | _("rebase working directory to branch head")) |
|
|||
386 | decoratorentry[1].append(rebaseopt) |
|
|||
387 | commands.table[cmdkey] = decoratorentry |
|
|||
388 |
|
376 | |||
389 | cmdtable = { |
|
377 | cmdtable = { | |
390 | "rebase": |
|
378 | "rebase": |
@@ -8,6 +8,7 b'' | |||||
8 |
|
8 | |||
9 | import Zeroconf, socket, time, os |
|
9 | import Zeroconf, socket, time, os | |
10 | from mercurial import ui |
|
10 | from mercurial import ui | |
|
11 | from mercurial import extensions | |||
11 | from mercurial.hgweb import hgweb_mod |
|
12 | from mercurial.hgweb import hgweb_mod | |
12 | from mercurial.hgweb import hgwebdir_mod |
|
13 | from mercurial.hgweb import hgwebdir_mod | |
13 |
|
14 | |||
@@ -114,22 +115,20 b' def getzcpaths():' | |||||
114 | v.properties.get("path", "/")) |
|
115 | v.properties.get("path", "/")) | |
115 | yield "zc-" + n, u |
|
116 | yield "zc-" + n, u | |
116 |
|
117 | |||
117 | def config(self, section, key, default=None, untrusted=False): |
|
118 | def config(orig, self, section, key, default=None, untrusted=False): | |
118 | if section == "paths" and key.startswith("zc-"): |
|
119 | if section == "paths" and key.startswith("zc-"): | |
119 | for n, p in getzcpaths(): |
|
120 | for n, p in getzcpaths(): | |
120 | if n == key: |
|
121 | if n == key: | |
121 | return p |
|
122 | return p | |
122 |
return o |
|
123 | return orig(self, section, key, default, untrusted) | |
123 |
|
124 | |||
124 | def configitems(self, section): |
|
125 | def configitems(orig, self, section): | |
125 |
r = o |
|
126 | r = orig(self, section, untrusted=False) | |
126 | if section == "paths": |
|
127 | if section == "paths": | |
127 | r += getzcpaths() |
|
128 | r += getzcpaths() | |
128 | return r |
|
129 | return r | |
129 |
|
130 | |||
130 | oldconfig = ui.ui.config |
|
131 | extensions.wrapfunction(ui.ui, 'config', config) | |
131 | oldconfigitems = ui.ui.configitems |
|
132 | extensions.wrapfunction(ui.ui, 'configitems', configitems) | |
132 | ui.ui.config = config |
|
|||
133 | ui.ui.configitems = configitems |
|
|||
134 | hgweb_mod.hgweb = hgwebzc |
|
133 | hgweb_mod.hgweb = hgwebzc | |
135 | hgwebdir_mod.hgwebdir = hgwebdirzc |
|
134 | hgwebdir_mod.hgwebdir = hgwebdirzc |
General Comments 0
You need to be logged in to leave comments.
Login now