Skip to content
Snippets Groups Projects
Commit c9f615ab3082 authored by Thomas Arendsen Hein's avatar Thomas Arendsen Hein
Browse files

merge with main

No related branches found
No related tags found
No related merge requests found
......@@ -86,5 +86,9 @@
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
......@@ -89,7 +93,6 @@
# 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,7 +116,7 @@
'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]
......@@ -117,7 +120,7 @@
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,10 +152,10 @@
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.'''
......@@ -154,9 +157,9 @@
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,9 +413,4 @@
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:])
......@@ -418,5 +416,5 @@
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 @@
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,9 +449,9 @@
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,
......@@ -454,9 +453,9 @@
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 @@
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():
......
......@@ -43,10 +43,11 @@
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):
......@@ -48,9 +49,10 @@
# 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,5 +65,4 @@
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:
......@@ -67,6 +68,9 @@
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 @@
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 @@
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment