[Svnmerge] [PATCH] fix remaining test failures on Windows

lsuvkne at onemodel.org lsuvkne at onemodel.org
Mon Jul 9 14:02:53 PDT 2007


In my email with the performance patch, I said the tests passed on linux
and windows. I should have said "as well as they did before."  This
patch, in combination with those other two, makes all the tests pass.

The problem is mostly with line terminators. 10 tests fail on windows. 
8 are with things like this:
    ======================================================================
    FAIL: Check that reflected revisions are recognized properly for bidirectional m
    erges.
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "C:\sandboxes\svnmergeStuff\svnmerge_test.py", line 817, in testBidirecti
    onalMerges
        match=r"Committed revision 17")
      File "C:\sandboxes\svnmergeStuff\svnmerge_test.py", line 454, in launch
        return TestCase_SvnMerge.launch(self, cmd, *args, **kwargs)
      File "C:\sandboxes\svnmergeStuff\svnmerge_test.py", line 241, in launch
        return self._parseoutput(ret, out, **kwargs)
      File "C:\sandboxes\svnmergeStuff\svnmerge_test.py", line 225, in _parseoutput
        "svnmerge failed, with this output:\n%s" % out)
    AssertionError: svnmerge failed, with this output:
    svn: Commit failed (details follow):
    svn: Inconsistent line ending style
    
  Another test fails due to a regular expression not accounting for
line terminator differences, and another due to quoted arguments being
broken up because of spaces, unless they are in double-quotes.  All are
now fixed.

I debated whether to submit this, because it feels kludgy.  At first I
wondered if it were just when the tests run.  But I found that it can be
duplicated in a very simple manual svnmerge.py usage scenario on
Windows, so anyone could get the error "Inconsistent line ending style". 
(Anyone have a guess how many svnmerge.py users there are under Windows? 
We will have some here or I wouldn't have worried about it.)  The code
comments indicate roughly how to duplicate the problem manually.  So
even though it's inelegant, maybe it's better than the error message 
Tracking down the root cause would be even better, of course, if someone
wants to do that...  :)

So here it is, for what it may be worth...

Thanks & best regards,

-Luke

[[[
Fix so tests will pass on Windows.

* contrib/client‑side/svnmerge/svnmerge.py
  (fix_line_terminators): New function. 
  (action_merge, action_block, action_unblock, action_rollback,
action_uninit): Change all line terminators to unix-style before writing
svnmerge-commit-message.txt files.

* contrib/client‑side/svnmerge/svnmerge_test.py
  (testTransitiveMerge): Use double-quotes around checkin comments
with whitespace so they aren't broken up by Windows into separate
parameters.
  (testInitAndRollback): Fix regular expression to allow for non-unix
line terminators.

Patch by:  Luke Call <lsuvkne at onemodel.org>
Reviewed by: ?
]]]                                    
-------------- next part --------------
--- /home/callla/dnload/subversion/trunk/contrib/client-side/svnmerge/svnmerge_test.py	2007-07-09 08:57:30.000000000 -0600
+++ svnmerge_test.py	2007-07-09 10:12:29.000000000 -0600
@@ -564,39 +620,39 @@
         os.chdir("trunk")
         self.launch("svn up")
         self.svnmerge("init ../test-branch")
-        self.launch("svn ci -m 'init test-branch -> trunk'",
+        self.launch('svn ci -m "init test-branch -> trunk"',
             match=r"Committed revision 14")

         os.chdir("../test-branch")
         self.svnmerge("init -r 1-6 ../testYYY-branch")
-        self.launch("svn ci -m 'init testYYY-branch -> test-branch'",
+        self.launch('svn ci -m "init testYYY-branch -> test-branch"',
             match=r"Committed revision 15")

         os.chdir("../testYYY-branch")
         open("test4", "w").write("test4")
         self.launch("svn add test4")
-        self.launch("svn ci -m 'add test4'",
+        self.launch('svn ci -m "add test4"',
             match=r"Committed revision 16")

         os.chdir("../test-branch")
         self.svnmerge("block -r 16")
-        self.launch("svn ci -m 'block r16'",
+        self.launch('svn ci -m "block r16"',
             match=r"Committed revision 17")

         #os.chdir("../test-branch")
         open("test5", "w").write("test5")
         self.launch("svn add test5")
-        self.launch("svn ci -m 'add test5'",
+        self.launch('svn ci -m "add test5"',
             match=r"Committed revision 18")

         os.chdir("../trunk")
         self.svnmerge("block -r 18")
-        self.launch("svn ci -m 'block r18'",
+        self.launch('svn ci -m "block r18"',
             match=r"Committed revision 19")

         #os.chdir("../trunk")
         self.svnmerge("merge -r 17")
-        self.launch("svn ci -m 'merge r17 from test-branch'",
+        self.launch('svn ci -m "merge r17 from test-branch"',
             match=r"Committed revision 20")

         p = self.getBlockedProperty()
@@ -987,9 +1043,7 @@
         os.remove("svnmerge-commit-message.txt")
 
         # Svnmerge rollback r5-7
-        expected_output = r"""
-D    test2
-D    test3"""
+        expected_output = "D\s+test2\s+D\s+test3"
         self.svnmerge("rollback -vv -S ../trunk -r5-7",
                       match = expected_output)
 
-------------- next part --------------
--- /home/callla/dnload/subversion/trunk/contrib/client-side/svnmerge/svnmerge.py	2007-07-07 20:27:59.000000000 -0600
+++ svnmerge.py	2007-07-09 09:05:36.000000000 -0600
@@ -1098,6 +1162,38 @@
     ret.reverse()
     return ret
 
+def fix_line_terminators(filename):
+    ''' Avoid the error on windows when the commit failed with:  "svn: 
+    Inconsistent line ending style" (both w/ tests and manual runs).
+    So make them consistent, whatever os we're on (didn't test outside of 
+    windows XP & linux).
+    (Perhaps this problem could also happen by combining historical 
+    comments, where the comments were originally 
+    created on a different platform from the currently executing one.
+    Normal use of this script does potentially combine such comments.)
+    
+    One can duplicate the issue manually on windows by simply:  create a new 
+    repository, create/add a directory with a file in it (1 branch), create 
+    another directory & copy 1st one to it (another branch), do an 'svnmerge 
+    init' then commit, change a file on the other branch, then 'svnmerge 
+    merge' to get changes from one branch to the other, and check in: that 
+    gets the error, on windows. Not sure why. Seems like some other 
+    bug in svnmerge.py, but this works around it for now, usably if 
+    developers on windows use something that understands unix-style linefeeds 
+    when viewing the file svnmerge-commit-message.txt. todo: Revisit.
+    '''
+    
+    try:
+        f = open(filename,'r')
+        file_contents = f.read()  # don't know the practical limit of read(), but tested w/ a file over 4MB, hopefully our comments won't get that big. If size were an issue, we'd could do it one line at a time, but being careful to remove (only?) the line terminator, and replace it with os.sep.
+        f.close()
+        new_contents = file_contents.replace("\r\n", "\n")
+        f = open(filename,'wb')
+        f.write(new_contents)
+    finally:
+        f.close()
+        
+
 def display_revisions(revs, display_style, revisions_msg, source_url):
     """Show REVS as dictated by DISPLAY_STYLE, either numerically, in
     log format, or as diffs.  When displaying revisions numerically,
@@ -1313,6 +1409,9 @@
             print >>f, construct_merged_log_message(opts["source-url"], revs),
 
         f.close()
+        
+        fix_line_terminators(opts["commit-file"])
+        
         report('wrote commit message to "%s"' % opts["commit-file"])
 
 def action_block(branch_dir, branch_props):
@@ -1348,7 +1447,9 @@
                                                     revs_to_block),
 
         f.close()
+        fix_line_terminators(opts["commit-file"])
         report('wrote commit message to "%s"' % opts["commit-file"])
+ 
 
 def action_unblock(branch_dir, branch_props):
     """Unblock revisions."""
@@ -1378,6 +1479,7 @@
             print >>f, construct_merged_log_message(opts["source-url"],
                                                     revs_to_unblock),
         f.close()
+        fix_line_terminators(opts["commit-file"])
         report('wrote commit message to "%s"' % opts["commit-file"])
 
 def action_rollback(branch_dir, branch_props):
@@ -1452,6 +1934,7 @@
         print >>f, '%s' % opts["source-url"]
 
         f.close()
+        fix_line_terminators(opts["commit-file"])
         report('wrote commit message to "%s"' % opts["commit-file"])
 
     # Update the set of merged revisions.
@@ -1484,6 +1967,7 @@
         print >>f, 'Removed merge tracking for "%s" for ' % NAME
         print >>f, '%s' % opts["source-url"]
         f.close()
+        fix_line_terminators(opts["commit-file"])
         report('wrote commit message to "%s"' % opts["commit-file"])
 
 ###############################################################################


More information about the Svnmerge mailing list