mercurial/mdiff.py
changeset 23299 1f510efcd5f3
parent 23294 ec8c73b02e2e
child 24119 a5a06c9c7407
--- a/mercurial/mdiff.py	Thu Nov 13 00:13:48 2014 -0800
+++ b/mercurial/mdiff.py	Wed Nov 12 23:29:14 2014 -0800
@@ -156,6 +156,13 @@
 
     if not a and not b:
         return ""
+
+    if opts.noprefix:
+        aprefix = bprefix = ''
+    else:
+        aprefix = 'a/'
+        bprefix = 'b/'
+
     epoch = util.datestr((0, 0))
 
     fn1 = util.pconvert(fn1)
@@ -170,17 +177,17 @@
         if a is None:
             l1 = '--- /dev/null%s' % datetag(epoch)
         else:
-            l1 = "--- %s%s" % ("a/" + fn1, datetag(ad, fn1))
-        l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd, fn2))
+            l1 = "--- %s%s%s" % (aprefix, fn1, datetag(ad, fn1))
+        l2 = "+++ %s%s" % (bprefix + fn2, datetag(bd, fn2))
         l3 = "@@ -0,0 +1,%d @@\n" % len(b)
         l = [l1, l2, l3] + ["+" + e for e in b]
     elif not b:
         a = splitnewlines(a)
-        l1 = "--- %s%s" % ("a/" + fn1, datetag(ad, fn1))
+        l1 = "--- %s%s%s" % (aprefix, fn1, datetag(ad, fn1))
         if b is None:
             l2 = '+++ /dev/null%s' % datetag(epoch)
         else:
-            l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd, fn2))
+            l2 = "+++ %s%s%s" % (bprefix, fn2, datetag(bd, fn2))
         l3 = "@@ -1,%d +0,0 @@\n" % len(a)
         l = [l1, l2, l3] + ["-" + e for e in a]
     else:
@@ -190,8 +197,8 @@
         if not l:
             return ""
 
-        l.insert(0, "--- a/%s%s" % (fn1, datetag(ad, fn1)))
-        l.insert(1, "+++ b/%s%s" % (fn2, datetag(bd, fn2)))
+        l.insert(0, "--- %s%s%s" % (aprefix, fn1, datetag(ad, fn1)))
+        l.insert(1, "+++ %s%s%s" % (bprefix, fn2, datetag(bd, fn2)))
 
     for ln in xrange(len(l)):
         if l[ln][-1] != '\n':