changeset 286:f992b16d18a1

hg-interdiff: handle single-file diffs
author Nicholas Riley <njriley@uiuc.edu>
date Sun, 13 Jan 2008 08:16:21 -0800
parents 814698eebbaf
children 0a5879ea5416
files examples/hg-interdiff
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/examples/hg-interdiff	Fri Jan 04 22:09:00 2008 +0100
+++ b/examples/hg-interdiff	Sun Jan 13 08:16:21 2008 -0800
@@ -15,6 +15,9 @@
         for f in files:
             path = os.path.join(root, f)
             yield path[len(base)+1:], path
+    else:
+        if os.path.isfile(base):
+            yield '', base
 
 # create list of unique file names under both directories.
 files = dict(walk(sys.argv[1]))
@@ -23,8 +26,11 @@
 files.sort()
 
 def name(base, f):
+    if f:
+        path = os.path.join(base, f)
+    else:
+        path = base
     # interdiff requires two files; use /dev/null if one is missing.
-    path = os.path.join(base, f)
     if os.path.exists(path):
         return path
     return '/dev/null'