subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1420427 - /subversion/trunk/contrib/server-side/svncutter/svncutter
Date Tue, 11 Dec 2012 21:33:32 GMT
Author: esr
Date: Tue Dec 11 21:33:31 2012
New Revision: 1420427

URL: http://svn.apache.org/viewvc?rev=1420427&view=rev
Log:
Change branchdel so that if no nodes in a revision pass, the header doesn't
either.

* contrib/server-side/svncutter/svncutter
  (report, skeleton): Refactored.
  (branchdel): Header-output-suppression logic.
  (read_revision_header): Gather trailing newlines.

Modified:
    subversion/trunk/contrib/server-side/svncutter/svncutter

Modified: subversion/trunk/contrib/server-side/svncutter/svncutter
URL: http://svn.apache.org/viewvc/subversion/trunk/contrib/server-side/svncutter/svncutter?rev=1420427&r1=1420426&r2=1420427&view=diff
==============================================================================
--- subversion/trunk/contrib/server-side/svncutter/svncutter (original)
+++ subversion/trunk/contrib/server-side/svncutter/svncutter Tue Dec 11 21:33:31 2012
@@ -253,6 +253,8 @@ class DumpfileSource(LineBufferedSource)
                 stash += "V %d%s" % (len(properties[key]), os.linesep) 
                 stash += "%s%s" % (properties[key], os.linesep) 
         stash += self.flush()
+        while self.peek() == '\n':
+            stash += self.readline()
         if self.baton:
             self.baton.twirl()
         return (revision, stash, properties)
@@ -447,10 +449,10 @@ def report(source, selection, hook):
     if not source.has_line_buffered():    
         return
     while True:
+        nodecount = 0
         (revision,stash,properties) = source.read_revision_header()
         if revision in selection:
-            sys.stdout.write(stash)
-            emit = True
+            pass
         elif revision == selection.upperbound()+1:
             return
         else:
@@ -465,11 +467,18 @@ def report(source, selection, hook):
                 continue
             elif line.startswith("Revision-number:"):
                 source.push(line)
+                if stash and nodecount == 0:
+                    sys.stdout.write(stash)
                 break
             elif line.startswith("Node-path:"):
+                nodecount += 1
                 source.push(line)
                 (header, properties, content) = source.read_node()
-                hook(header, properties, content)
+                emit = hook(header, properties, content)
+                if emit and stash:
+                    emit = stash + emit
+                    stash = ""
+                sys.stdout.write(emit)
                 continue
             else:
                 sys.stderr.write("svncutter: parse at %s doesn't look right (%s), aborting!\n"
% (revision, repr(line)))
@@ -701,13 +710,15 @@ def setlog(source, logpatch, selection):
 
 def skeletonize(source, selection):
     "Skeletonize a portion of the dump file defined by a revision selection."
-    report(source, selection, lambda h, p, c: sys.stdout.write(h + p))
+    report(source, selection, lambda h, p, c: h + p)
 
 def branchdel(source, selection, branchname):
     "Strip out ops defined by a revision selection and a branch name."
     def __branchdel(header, properties, content):
-        if not re.search("Node-path: " + branchname, header):
-            sys.stdout.write(header + properties + content)
+        if re.search("Node-path: " + branchname, header):
+            return ""
+        else:
+            return header + properties + content
     report(source, selection, __branchdel)
 
 if __name__ == '__main__':



Mime
View raw message