merge with main
authorThomas Arendsen Hein <thomas@intevation.de>
Wed, 06 Feb 2008 09:11:36 +0100
changeset 6036 c9f615ab3082
parent 6035 df659eb23360 (current diff)
parent 6026 b7f44f01a632 (diff)
child 6037 dd3267698d84
merge with main
--- a/hgext/keyword.py	Tue Feb 05 09:30:08 2008 +0100
+++ b/hgext/keyword.py	Wed Feb 06 09:11:36 2008 +0100
@@ -86,10 +86,13 @@
 
 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 @@
         '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 @@
             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 @@
     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 @@
         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 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 @@
                              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():
--- a/mercurial/filemerge.py	Tue Feb 05 09:30:08 2008 +0100
+++ b/mercurial/filemerge.py	Wed Feb 06 09:11:36 2008 +0100
@@ -43,14 +43,16 @@
         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 @@
     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 @@
     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