Commits

Steve Borho  committed 523b97d

gdialog: support full extdiff settings

Borrow extdiff's code for parsing [extdiff] section to properly
load vdiff options from the user's Mercurial.ini file.

Fixes #125 and probably #126

  • Participants
  • Parent commits 85be601

Comments (0)

Files changed (1)

File hggtk/gdialog.py

 import gtk
 import gobject
 import pango
+import shlex
 
 from mercurial.i18n import _
 from mercurial.node import short
     def test_opt(self, opt):
         return opt in self.opts and self.opts[opt]
 
+    def _parse_extdiff_cmd(self, usercmd):
+        for cmd, path in self.ui.configitems('extdiff'):
+            if cmd.startswith('cmd.'):
+                cmd = cmd[4:]
+                if cmd != usercmd:
+                    continue
+                if not path:
+                    path = cmd
+                diffopts = self.ui.config('extdiff', 'opts.' + cmd, '')
+                diffopts = diffopts and [diffopts] or []
+            elif cmd == usercmd:
+                # command = path opts
+                if path:
+                    diffopts = shlex.split(path)
+                    path = diffopts.pop(0)
+                else:
+                    path, diffopts = cmd, []
+            return path, diffopts
+        return None, None
 
     def _parse_config(self):
         # defaults    
         self.fontcomment = 'monospace 10'
         self.fontdiff = 'monospace 10'
         self.fontlist = 'monospace 9'
-        self.diffopts = ''
+        self.diffopts = []
         self.diffcmd = ''
         self.diffbottom = ''
 
             # default to tortoisehg's configuration
             vdiff = self.ui.config('tortoisehg', 'vdiff', 'vdiff')
             if vdiff:
-                self.diffcmd = self.ui.config('extdiff', 'cmd.'+vdiff) or vdiff
+                self.diffcmd, self.diffopts = self._parse_extdiff_cmd(vdiff)
             else:
                 self.diffcmd = 'diff'
-                if not self.diffopts :
-                    self.diffopts = '-Npru'
+                if not self.diffopts:
+                    self.diffopts = ['-Npru']
 
         if not self.diffbottom:
             self.diffbottom = False
 
     def _diff_file(self, stat, file):
         def dodiff():
-            extdiff.dodiff(self.ui, self.repo, self.diffcmd, [self.diffopts],
+            extdiff.dodiff(self.ui, self.repo, self.diffcmd, self.diffopts,
                             [self.repo.wjoin(file)], self.opts)
 
         if self.diffcmd == 'diff':