# HG changeset patch # User Thomas Arendsen Hein # Date 2008-02-06 08:11:36 # Node ID c9f615ab3082608f11b76e0c22a377d0a19b0895 # Parent df659eb233600f2330e406f46d911af384323ec5 # Parent b7f44f01a632ab4a59f276de21dc3c5d8f1b8560 merge with main diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -86,10 +86,13 @@ import re, shutil, sys, tempfile, time commands.optionalrepo += ' kwdemo' +# hg commands that do not act on keywords +nokwcommands = ('add addremove bundle copy export grep identify incoming init' + ' log outgoing push remove rename rollback tip convert') + # hg commands that trigger expansion only when writing to working dir, # not when reading filelog, and unexpand when reading from working dir -restricted = ('diff1', 'record', - 'qfold', 'qimport', 'qnew', 'qpush', 'qrefresh', 'qrecord') +restricted = 'diff1 record qfold qimport qnew qpush qrefresh qrecord' def utcdate(date): '''Returns hgdate in cvs-like UTC format.''' @@ -113,11 +116,11 @@ class kwtemplater(object): 'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}', } - def __init__(self, ui, repo, inc, exc, hgcmd): + def __init__(self, ui, repo, inc, exc, restricted): self.ui = ui self.repo = repo self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] - self.hgcmd = hgcmd + self.restricted = restricted self.commitnode = None self.path = '' @@ -149,14 +152,14 @@ class kwtemplater(object): self.ct.use_template(self.templates[kw]) self.ui.pushbuffer() self.ct.show(changenode=fnode, root=self.repo.root, file=self.path) - return '$%s: %s $' % (kw, templatefilters.firstline( - self.ui.popbuffer())) + ekw = templatefilters.firstline(self.ui.popbuffer()) + return '$%s: %s $' % (kw, ekw) return subfunc(kwsub, data) def expand(self, node, data): '''Returns data with keywords expanded.''' - if util.binary(data) or self.hgcmd in restricted: + if self.restricted or util.binary(data): return data return self.substitute(node, data, self.re_kw.sub) @@ -410,13 +413,8 @@ def reposetup(ui, repo): if not repo.local(): return - nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy', - 'export', 'grep', 'identify', 'incoming', 'init', - 'log', 'outgoing', 'push', 'remove', 'rename', - 'rollback', 'tip', - 'convert') hgcmd, func, args, opts, cmdopts = dispatch._parse(ui, sys.argv[1:]) - if hgcmd in nokwcommands: + if hgcmd in nokwcommands.split(): return if hgcmd == 'diff': @@ -438,7 +436,8 @@ def reposetup(ui, repo): return global _kwtemplater - _kwtemplater = kwtemplater(ui, repo, inc, exc, hgcmd) + _restricted = hgcmd in restricted.split() + _kwtemplater = kwtemplater(ui, repo, inc, exc, _restricted) class kwrepo(repo.__class__): def file(self, f, kwmatch=False): @@ -450,13 +449,13 @@ def reposetup(ui, repo): def wread(self, filename): data = super(kwrepo, self).wread(filename) - if hgcmd in restricted and _kwtemplater.matcher(filename): + if _restricted and _kwtemplater.matcher(filename): return _kwtemplater.shrink(data) return data def commit(self, files=None, text='', user=None, date=None, match=util.always, force=False, force_editor=False, - p1=None, p2=None, extra={}): + p1=None, p2=None, extra={}, empty_ok=False): wlock = lock = None _p1 = _p2 = None try: @@ -484,7 +483,8 @@ def reposetup(ui, repo): self).commit(files=files, text=text, user=user, date=date, match=match, force=force, force_editor=force_editor, - p1=p1, p2=p2, extra=extra) + p1=p1, p2=p2, extra=extra, + empty_ok=empty_ok) # restore commit hooks for name, cmd in commithooks.iteritems(): diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -43,14 +43,16 @@ def _picktool(repo, ui, path, binary, sy return False # HGMERGE takes precedence - if os.environ.get("HGMERGE"): - return os.environ.get("HGMERGE") + hgmerge = os.environ.get("HGMERGE") + if hgmerge: + return (hgmerge, hgmerge) # then patterns for pat, tool in ui.configitems("merge-patterns"): mf = util.matcher(repo.root, "", [pat], [], [])[1] if mf(path) and check(tool, pat, symlink, False): - return tool + toolpath = _findtool(ui, tool) + return (tool, '"' + toolpath + '"') # then merge tools tools = {} @@ -63,10 +65,12 @@ def _picktool(repo, ui, path, binary, sy if ui.config("ui", "merge"): tools.insert(0, (None, ui.config("ui", "merge"))) # highest priority tools.append((None, "hgmerge")) # the old default, if found - tools.append((None, "internal:merge")) # internal merge as last resort for p,t in tools: - if _findtool(ui, t) and check(t, None, symlink, binary): - return t + toolpath = _findtool(ui, t) + if toolpath and check(t, None, symlink, binary): + return (t, '"' + toolpath + '"') + # internal merge as last resort + return (not (symlink or binary) and "internal:merge" or None, None) def _eoltype(data): "Guess the EOL type of a file" @@ -124,7 +128,7 @@ def filemerge(repo, fw, fd, fo, wctx, mc fca = fcm.ancestor(fco) or repo.filectx(fw, fileid=nullrev) binary = isbin(fcm) or isbin(fco) or isbin(fca) symlink = fcm.islink() or fco.islink() - tool = _picktool(repo, ui, fw, binary, symlink) + tool, toolpath = _picktool(repo, ui, fw, binary, symlink) ui.debug(_("picked tool '%s' for %s (binary %s symlink %s)\n") % (tool, fw, binary, symlink)) @@ -177,7 +181,6 @@ def filemerge(repo, fw, fd, fo, wctx, mc if tool == "internal:merge": r = simplemerge.simplemerge(a, b, c, label=['local', 'other']) else: - toolpath = _findtool(ui, tool) args = _toolstr(ui, tool, "args", '$local $base $other') if "$output" in args: out, a = a, back # read input from backup, write to original