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 @@ ...@@ -86,5 +86,9 @@
commands.optionalrepo += ' kwdemo' 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, # hg commands that trigger expansion only when writing to working dir,
# not when reading filelog, and unexpand when reading from working dir # not when reading filelog, and unexpand when reading from working dir
...@@ -89,7 +93,6 @@ ...@@ -89,7 +93,6 @@
# hg commands that trigger expansion only when writing to working dir, # hg commands that trigger expansion only when writing to working dir,
# not when reading filelog, and unexpand when reading from working dir # not when reading filelog, and unexpand when reading from working dir
restricted = ('diff1', 'record', restricted = 'diff1 record qfold qimport qnew qpush qrefresh qrecord'
'qfold', 'qimport', 'qnew', 'qpush', 'qrefresh', 'qrecord')
def utcdate(date): def utcdate(date):
'''Returns hgdate in cvs-like UTC format.''' '''Returns hgdate in cvs-like UTC format.'''
...@@ -113,7 +116,7 @@ ...@@ -113,7 +116,7 @@
'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}', '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.ui = ui
self.repo = repo self.repo = repo
self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
...@@ -117,7 +120,7 @@ ...@@ -117,7 +120,7 @@
self.ui = ui self.ui = ui
self.repo = repo self.repo = repo
self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
self.hgcmd = hgcmd self.restricted = restricted
self.commitnode = None self.commitnode = None
self.path = '' self.path = ''
...@@ -149,10 +152,10 @@ ...@@ -149,10 +152,10 @@
self.ct.use_template(self.templates[kw]) self.ct.use_template(self.templates[kw])
self.ui.pushbuffer() self.ui.pushbuffer()
self.ct.show(changenode=fnode, root=self.repo.root, file=self.path) self.ct.show(changenode=fnode, root=self.repo.root, file=self.path)
return '$%s: %s $' % (kw, templatefilters.firstline( ekw = templatefilters.firstline(self.ui.popbuffer())
self.ui.popbuffer())) return '$%s: %s $' % (kw, ekw)
return subfunc(kwsub, data) return subfunc(kwsub, data)
def expand(self, node, data): def expand(self, node, data):
'''Returns data with keywords expanded.''' '''Returns data with keywords expanded.'''
...@@ -154,9 +157,9 @@ ...@@ -154,9 +157,9 @@
return subfunc(kwsub, data) return subfunc(kwsub, data)
def expand(self, node, data): def expand(self, node, data):
'''Returns data with keywords expanded.''' '''Returns data with keywords expanded.'''
if util.binary(data) or self.hgcmd in restricted: if self.restricted or util.binary(data):
return data return data
return self.substitute(node, data, self.re_kw.sub) return self.substitute(node, data, self.re_kw.sub)
...@@ -410,9 +413,4 @@ ...@@ -410,9 +413,4 @@
if not repo.local(): if not repo.local():
return 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:]) hgcmd, func, args, opts, cmdopts = dispatch._parse(ui, sys.argv[1:])
...@@ -418,5 +416,5 @@ ...@@ -418,5 +416,5 @@
hgcmd, func, args, opts, cmdopts = dispatch._parse(ui, sys.argv[1:]) hgcmd, func, args, opts, cmdopts = dispatch._parse(ui, sys.argv[1:])
if hgcmd in nokwcommands: if hgcmd in nokwcommands.split():
return return
if hgcmd == 'diff': if hgcmd == 'diff':
...@@ -438,7 +436,8 @@ ...@@ -438,7 +436,8 @@
return return
global _kwtemplater 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__): class kwrepo(repo.__class__):
def file(self, f, kwmatch=False): def file(self, f, kwmatch=False):
...@@ -450,9 +449,9 @@ ...@@ -450,9 +449,9 @@
def wread(self, filename): def wread(self, filename):
data = super(kwrepo, self).wread(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 _kwtemplater.shrink(data)
return data return data
def commit(self, files=None, text='', user=None, date=None, def commit(self, files=None, text='', user=None, date=None,
match=util.always, force=False, force_editor=False, match=util.always, force=False, force_editor=False,
...@@ -454,9 +453,9 @@ ...@@ -454,9 +453,9 @@
return _kwtemplater.shrink(data) return _kwtemplater.shrink(data)
return data return data
def commit(self, files=None, text='', user=None, date=None, def commit(self, files=None, text='', user=None, date=None,
match=util.always, force=False, force_editor=False, match=util.always, force=False, force_editor=False,
p1=None, p2=None, extra={}): p1=None, p2=None, extra={}, empty_ok=False):
wlock = lock = None wlock = lock = None
_p1 = _p2 = None _p1 = _p2 = None
try: try:
...@@ -484,7 +483,8 @@ ...@@ -484,7 +483,8 @@
self).commit(files=files, text=text, user=user, self).commit(files=files, text=text, user=user,
date=date, match=match, force=force, date=date, match=match, force=force,
force_editor=force_editor, force_editor=force_editor,
p1=p1, p2=p2, extra=extra) p1=p1, p2=p2, extra=extra,
empty_ok=empty_ok)
# restore commit hooks # restore commit hooks
for name, cmd in commithooks.iteritems(): for name, cmd in commithooks.iteritems():
......
...@@ -43,10 +43,11 @@ ...@@ -43,10 +43,11 @@
return False return False
# HGMERGE takes precedence # HGMERGE takes precedence
if os.environ.get("HGMERGE"): hgmerge = os.environ.get("HGMERGE")
return os.environ.get("HGMERGE") if hgmerge:
return (hgmerge, hgmerge)
# then patterns # then patterns
for pat, tool in ui.configitems("merge-patterns"): for pat, tool in ui.configitems("merge-patterns"):
mf = util.matcher(repo.root, "", [pat], [], [])[1] mf = util.matcher(repo.root, "", [pat], [], [])[1]
if mf(path) and check(tool, pat, symlink, False): if mf(path) and check(tool, pat, symlink, False):
...@@ -48,9 +49,10 @@ ...@@ -48,9 +49,10 @@
# then patterns # then patterns
for pat, tool in ui.configitems("merge-patterns"): for pat, tool in ui.configitems("merge-patterns"):
mf = util.matcher(repo.root, "", [pat], [], [])[1] mf = util.matcher(repo.root, "", [pat], [], [])[1]
if mf(path) and check(tool, pat, symlink, False): if mf(path) and check(tool, pat, symlink, False):
return tool toolpath = _findtool(ui, tool)
return (tool, '"' + toolpath + '"')
# then merge tools # then merge tools
tools = {} tools = {}
...@@ -63,5 +65,4 @@ ...@@ -63,5 +65,4 @@
if ui.config("ui", "merge"): if ui.config("ui", "merge"):
tools.insert(0, (None, ui.config("ui", "merge"))) # highest priority tools.insert(0, (None, ui.config("ui", "merge"))) # highest priority
tools.append((None, "hgmerge")) # the old default, if found tools.append((None, "hgmerge")) # the old default, if found
tools.append((None, "internal:merge")) # internal merge as last resort
for p,t in tools: for p,t in tools:
...@@ -67,6 +68,9 @@ ...@@ -67,6 +68,9 @@
for p,t in tools: for p,t in tools:
if _findtool(ui, t) and check(t, None, symlink, binary): toolpath = _findtool(ui, t)
return 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): def _eoltype(data):
"Guess the EOL type of a file" "Guess the EOL type of a file"
...@@ -124,7 +128,7 @@ ...@@ -124,7 +128,7 @@
fca = fcm.ancestor(fco) or repo.filectx(fw, fileid=nullrev) fca = fcm.ancestor(fco) or repo.filectx(fw, fileid=nullrev)
binary = isbin(fcm) or isbin(fco) or isbin(fca) binary = isbin(fcm) or isbin(fco) or isbin(fca)
symlink = fcm.islink() or fco.islink() 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") % ui.debug(_("picked tool '%s' for %s (binary %s symlink %s)\n") %
(tool, fw, binary, symlink)) (tool, fw, binary, symlink))
...@@ -177,7 +181,6 @@ ...@@ -177,7 +181,6 @@
if tool == "internal:merge": if tool == "internal:merge":
r = simplemerge.simplemerge(a, b, c, label=['local', 'other']) r = simplemerge.simplemerge(a, b, c, label=['local', 'other'])
else: else:
toolpath = _findtool(ui, tool)
args = _toolstr(ui, tool, "args", '$local $base $other') args = _toolstr(ui, tool, "args", '$local $base $other')
if "$output" in args: if "$output" in args:
out, a = a, back # read input from backup, write to original 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