[Zope3-checkins] CVS: Zope3/src/zope/fssync - fssync.py:1.36 main.py:1.25 zsync.txt:1.7

Fred L. Drake, Jr. fred at zope.com
Thu Aug 7 19:08:45 EDT 2003


Update of /cvs-repository/Zope3/src/zope/fssync
In directory cvs.zope.org:/tmp/cvs-serv6067

Modified Files:
	fssync.py main.py zsync.txt 
Log Message:
implement a "revert" command similar to Subversion's

=== Zope3/src/zope/fssync/fssync.py 1.35 => 1.36 ===
--- Zope3/src/zope/fssync/fssync.py:1.35	Thu Aug  7 15:06:33 2003
+++ Zope3/src/zope/fssync/fssync.py	Thu Aug  7 18:08:39 2003
@@ -398,6 +398,41 @@
             if isdir(tmpdir):
                 shutil.rmtree(tmpdir)
 
+    def revert(self, target):
+        entry = self.metadata.getentry(target)
+        if not entry:
+            raise Error("nothing known about", target)
+        flag = entry.get("flag")
+        orig = fsutil.getoriginal(target)
+        if flag == "added":
+            entry.clear()
+        elif flag == "removed":
+            if exists(orig):
+                shutil.copyfile(orig, target)
+            del entry["flag"]
+        elif "conflict" in entry:
+            if exists(orig):
+                shutil.copyfile(orig, target)
+            del entry["conflict"]
+        elif isfile(orig):
+            if filecmp.cmp(target, orig, shallow=False):
+                return
+            shutil.copyfile(orig, target)
+        elif isdir(target):
+            # XXX how to recurse?
+            self.dirrevert(target)
+        self.metadata.flush()
+        self.reporter("Reverted " + target)
+
+    def dirrevert(self, target):
+        assert isdir(target)
+        names = self.metadata.getnames(target)
+        for name in names:
+            t = join(target, name)
+            e = self.metadata.getentry(t)
+            if e:
+                self.revert(t)
+
     def reporter(self, msg):
         if msg[0] not in "/*":
             print msg


=== Zope3/src/zope/fssync/main.py 1.24 => 1.25 ===
--- Zope3/src/zope/fssync/main.py:1.24	Thu Aug  7 16:38:02 2003
+++ Zope3/src/zope/fssync/main.py	Thu Aug  7 18:08:39 2003
@@ -312,6 +312,17 @@
     fs = FSSync(rooturl=rooturl)
     fs.checkin(target, message)
 
+def revert(opts, args):
+    """%(program)s revert [TARGET ...]
+
+    Revert changes to targets.  Modified files are overwritten by the
+    unmodified copy cached in @@Zope/Original/ and scheduled additions
+    and deletions are de-scheduled.  Additions that are de-scheduled
+    do not cause the working copy of the file to be removed.
+    """
+    fs = FSSync()
+    fs.multiple(args, fs.revert)
+
 def extract_message(opts, cmd):
     L = []
     message = None
@@ -349,6 +360,7 @@
     "status":   ("", [], status),
     "checkin":  ("F:m:", ["file=", "message="], checkin),
     "ci":       ("F:m:", ["file=", "message="], checkin),
+    "revert":   ("", [], revert),
     }
 
 if __name__ == "__main__":


=== Zope3/src/zope/fssync/zsync.txt 1.6 => 1.7 ===
--- Zope3/src/zope/fssync/zsync.txt:1.6	Thu Aug  7 16:47:24 2003
+++ Zope3/src/zope/fssync/zsync.txt	Thu Aug  7 18:08:39 2003
@@ -57,6 +57,9 @@
   not made to the object database itself until the next **zsync
   commit**.
 
+**revert**
+  Restore targets to their unmodified state.
+
 **status** (stat)
   Show the current status of the target material; whether it has been
   changed in the local representation, has been removed or added, or
@@ -254,6 +257,24 @@
 
 The **remove** command has no specific options.  It requires at least
 one *path* argument.
+
+
+The **zsync revert** Command
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Synopsis
+++++++++
+
+**revert** [*path* ...]
+
+Description
++++++++++++
+
+Restore targets to their unmodified state.  Files which have been
+modified are overwritten by pristine copies of the data from
+``@@Zope/Original/`` and scheduled additions and deletions are
+de-scheduled.  Additions that are de-scheduled do not cause the
+working copy of the file to be removed.
 
 
 The **zsync status** Command




More information about the Zope3-Checkins mailing list