[PATCH] extdiff: add repository root as a variable

Steven Stallion sstallion at gmail.com
Wed Apr 27 21:05:34 CDT 2011


# HG changeset patch
# User Steven Stallion <sstallion at gmail.com>
# Date 1303955746 14400
# Node ID 90ab1937d803b4aadcd7317f1f6e687d96f27399
# Parent  98f79a5c308665e1ce1b020bb66ed37f47f102e6
extdiff: add repository root as a variable

Some external diff tools (notably Plan 9 diff(1)) require the absolute path
to the file being diffed for proper function. A root variable was added to
inform an external tool of the repository root (the tool is invoked with the
cwd set to tmproot).

diff -r 98f79a5c3086 -r 90ab1937d803 hgext/extdiff.py
--- a/hgext/extdiff.py	Tue Apr 26 10:51:19 2011 -0500
+++ b/hgext/extdiff.py	Wed Apr 27 21:55:46 2011 -0400
@@ -40,6 +40,7 @@
   $parent1, $plabel1 - filename, descriptive label of first parent
   $child,   $clabel  - filename, descriptive label of child revision
   $parent2, $plabel2 - filename, descriptive label of second parent
+  $root              - repository root
   $parent is an alias for $parent1.
 
 The extdiff extension will look in your [diff-tools] and [merge-tools]
@@ -204,7 +205,8 @@
         # returned for parent2
         replace = dict(parent=dir1a, parent1=dir1a, parent2=dir1b,
                        plabel1=label1a, plabel2=label1b,
-                       clabel=label2, child=dir2)
+                       clabel=label2, child=dir2,
+                       root=repo.root)
         def quote(match):
             key = match.group()[1:]
             if not do3way and key == 'parent2':
@@ -212,7 +214,7 @@
             return util.shellquote(replace[key])
 
         # Match parent2 first, so 'parent1?' will match both parent1 and parent
-        regex = '\$(parent2|parent1?|child|plabel1|plabel2|clabel)'
+        regex = '\$(parent2|parent1?|child|plabel1|plabel2|clabel|root)'
         if not do3way and not re.search(regex, args):
             args += ' $parent1 $child'
         args = re.sub(regex, quote, args)


More information about the Mercurial-devel mailing list