[Zope3-checkins] CVS: Zope3/src/zope/fssync - fssync.py:1.12 main.py:1.6
Guido van Rossum
guido@python.org
Tue, 13 May 2003 16:28:02 -0400
Update of /cvs-repository/Zope3/src/zope/fssync
In directory cvs.zope.org:/tmp/cvs-serv8161
Modified Files:
fssync.py main.py
Log Message:
Minimal support for diff command.
=== Zope3/src/zope/fssync/fssync.py 1.11 => 1.12 ===
--- Zope3/src/zope/fssync/fssync.py:1.11 Tue May 13 16:05:17 2003
+++ Zope3/src/zope/fssync/fssync.py Tue May 13 16:28:01 2003
@@ -17,6 +17,7 @@
"""
import os
+import sys
import base64
import shutil
import urllib
@@ -394,6 +395,17 @@
finally:
if isfile(zipfile):
os.remove(zipfile)
+
+ def diff(self, target, mode=1, diffopts=""):
+ assert mode == 1, "modes 2 and 3 are not yet supported"
+ if isdir(target):
+ raise Error("recursive diff not yet supported")
+ head, tail = self.split(target)
+ orig = join(head, "@@Zope", "Original", tail)
+ print "Index:", target
+ sys.stdout.flush()
+ os.system("diff %s %s %s" %
+ (diffopts, commands.mkarg(orig), commands.mkarg(target)))
def add(self, path):
if not exists(path):
=== Zope3/src/zope/fssync/main.py 1.5 => 1.6 ===
--- Zope3/src/zope/fssync/main.py:1.5 Tue May 13 16:05:17 2003
+++ Zope3/src/zope/fssync/main.py Tue May 13 16:28:01 2003
@@ -147,6 +147,29 @@
for a in args:
fs.remove(a)
+diffflags = ["-b", "-B", "--brief", "-c", "-C", "--context=",
+ "-i", "-u", "-U", "--unified"]
+def diff(opts, args):
+ diffopts = []
+ mode = 1
+ for o, a in opts:
+ if o == '-1':
+ mode = 1
+ elif o == '-2':
+ mode = 2
+ elif o == '-3':
+ mode = 3
+ elif o in diffflags:
+ if a:
+ diffopts.append(o + " " + a)
+ else:
+ diffopts.append(o)
+ diffopts = " ".join(diffopts)
+ fs = FSSync()
+ def calldiff(arg):
+ fs.diff(arg, mode, diffopts)
+ fs.multiple(args, calldiff)
+
command_table = {
"checkout": ("", [], checkout),
"co": ("", [], checkout),
@@ -156,6 +179,7 @@
"remove": ("", [], remove),
"rm": ("", [], remove),
"r": ("", [], remove),
+ "diff": ("bBcC:iuU:", ["brief", "context=", "unified="], diff),
}
if __name__ == "__main__":