[Zope3-checkins] CVS: Zope3/src/zope/fssync - README.txt:1.41
fssync.py:1.35 main.py:1.23
Fred L. Drake, Jr.
fred at zope.com
Thu Aug 7 16:06:39 EDT 2003
Update of /cvs-repository/Zope3/src/zope/fssync
In directory cvs.zope.org:/tmp/cvs-serv9358
Modified Files:
README.txt fssync.py main.py
Log Message:
support the -N option for diff:
when the target is a file that is being added/removed, the diff should compare the
new/old file with /dev/null instead of complaining
=== Zope3/src/zope/fssync/README.txt 1.40 => 1.41 ===
--- Zope3/src/zope/fssync/README.txt:1.40 Thu Aug 7 13:41:01 2003
+++ Zope3/src/zope/fssync/README.txt Thu Aug 7 15:06:33 2003
@@ -161,8 +161,6 @@
-3 diffs between original and remote
- -N shows diffs for added/removed files as diffs with ``/dev/null``
-
* Something akin to **cvs -n** update, which shows what update would
do without actually doing it.
=== Zope3/src/zope/fssync/fssync.py 1.34 => 1.35 ===
--- Zope3/src/zope/fssync/fssync.py:1.34 Wed Jul 2 17:13:14 2003
+++ Zope3/src/zope/fssync/fssync.py Thu Aug 7 15:06:33 2003
@@ -45,6 +45,13 @@
from zope.fssync import fsutil
from zope.fssync.snarf import Snarfer, Unsnarfer
+
+if sys.platform[:3].lower() == "win":
+ DEV_NULL = r".\nul"
+else:
+ DEV_NULL = "/dev/null"
+
+
class Network(object):
"""Handle network communication.
@@ -395,36 +402,43 @@
if msg[0] not in "/*":
print msg
- def diff(self, target, mode=1, diffopts=""):
+ def diff(self, target, mode=1, diffopts="", need_original=True):
assert mode == 1, "modes 2 and 3 are not yet supported"
entry = self.metadata.getentry(target)
if not entry:
raise Error("diff target '%s' doesn't exist", target)
- if "flag" in entry:
+ if "flag" in entry and need_original:
raise Error("diff target '%s' is added or deleted", target)
if isdir(target):
- self.dirdiff(target, mode, diffopts)
+ self.dirdiff(target, mode, diffopts, need_original)
return
- if not isfile(target):
- raise Error("diff target '%s' is file nor directory", target)
orig = fsutil.getoriginal(target)
+ if not isfile(target):
+ if entry.get("flag") == "removed":
+ target = DEV_NULL
+ else:
+ raise Error("diff target '%s' is file nor directory", target)
+ have_original = True
if not isfile(orig):
- raise Error("can't find original for diff target '%s'", target)
- if filecmp.cmp(target, orig, shallow=False):
+ if entry.get("flag") != "added":
+ raise Error("can't find original for diff target '%s'", target)
+ have_original = False
+ orig = DEV_NULL
+ if have_original and filecmp.cmp(target, orig, shallow=False):
return
print "Index:", target
sys.stdout.flush()
cmd = ("diff %s %s %s" % (diffopts, quote(orig), quote(target)))
os.system(cmd)
- def dirdiff(self, target, mode=1, diffopts=""):
+ def dirdiff(self, target, mode=1, diffopts="", need_original=True):
assert isdir(target)
names = self.metadata.getnames(target)
for name in names:
t = join(target, name)
e = self.metadata.getentry(t)
- if e and "flag" not in e:
- self.diff(t, mode, diffopts)
+ if e and (("flag" not in e) or not need_original):
+ self.diff(t, mode, diffopts, need_original)
def add(self, path, type=None, factory=None):
if not exists(path):
=== Zope3/src/zope/fssync/main.py 1.22 => 1.23 ===
--- Zope3/src/zope/fssync/main.py:1.22 Fri Jul 25 11:09:26 2003
+++ Zope3/src/zope/fssync/main.py Thu Aug 7 15:06:33 2003
@@ -259,6 +259,7 @@
"""
diffopts = []
mode = 1
+ need_original = True
for o, a in opts:
if o == '-1':
mode = 1
@@ -266,6 +267,8 @@
mode = 2
elif o == '-3':
mode = 3
+ elif o == '-N':
+ need_original = False
elif o in diffflags:
if a:
diffopts.append(o + " " + a)
@@ -273,7 +276,7 @@
diffopts.append(o)
diffopts = " ".join(diffopts)
fs = FSSync()
- fs.multiple(args, fs.diff, mode, diffopts)
+ fs.multiple(args, fs.diff, mode, diffopts, need_original)
def status(opts, args):
"""%(program)s status [TARGET ...]
@@ -323,7 +326,7 @@
"remove": ("", [], remove),
"rm": ("", [], remove),
"r": ("", [], remove),
- "diff": ("bBcC:iuU:", ["brief", "context=", "unified="], diff),
+ "diff": ("bBcC:iNuU:", ["brief", "context=", "unified="], diff),
"status": ("", [], status),
"checkin": ("m:", ["message="], checkin),
"ci": ("m:", ["message="], checkin),
More information about the Zope3-Checkins
mailing list