[PATCH] Meld VC support for svn-1.6.x



Hello,

my distribution just upgraded my svn to 1.6.0 which
changed the output of svn status, adding a column
and lines to describe tree conflicts.

http://subversion.tigris.org/svn_1.6_releasenotes.html

Any repository working copy used with svn 1.6.x
will be silently converted to a new format and not
usable any more with 1.5.x.

You'll have to make a fresh clone with 1.5.x if you
want to still use the old version.

This patch rework svn VC plugin so that both versions
1.5.x and 1.6.x are supported.

The code was parsing svn status output with fixed
string indexes, I changed that to use regexes that
work for the 2 svn versions.

I tested it working with 1.5.4 and 1.6.0 with:
- new files unknown to svn
- new files added
- modified files
- removed files

But not with tree conflicts

-- 
Vincent Legoll
Index: vc/svn.py
===================================================================
--- vc/svn.py	(revision 1285)
+++ vc/svn.py	(working copy)
@@ -22,6 +22,7 @@
 ### THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import os
+import re
 import errno
 import _vc
 
@@ -72,10 +73,30 @@
                     raise
 
         matches = []
+
+        re_status_vc = re.compile(r'^(.) +\d+ +(\?|(?:\d+)) +[^ ]+ +([^ ].*)$')
+        re_status_non_vc = re.compile(r'^(.) +([^ ].*)$')
+        re_status_tree_conflict = re.compile(r'^ +> +.*')
+
         for line in entries:
-            line = line.strip("\n")
-            if len(line) > 40:
-                matches.append( (line[40:], line[0], line[17:26].strip()))
+            # svn-1.6.x changed 'status' command output
+            # adding tree-conflict lines, c.f.:
+            # http://subversion.tigris.org/svn_1.6_releasenotes.html
+            m = re_status_tree_conflict.match(line)
+            if m:
+                # skip this line
+                continue
+            # A svn controlled file
+            m = re_status_vc.match(line)
+            if m:
+                matches.append((m.group(3), m.group(1), m.group(2)))
+                continue
+            # A new file, unknown to svn
+            m = re_status_non_vc.match(line)
+            if m:
+                matches.append((m.group(2), m.group(1), ""))
+                continue
+
         matches.sort()
         return matches
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]