meld r1334 - trunk/vc



Author: vincele
Date: Sat Apr 11 22:19:40 2009
New Revision: 1334
URL: http://svn.gnome.org/viewvc/meld?rev=1334&view=rev

Log:
Add support for svn-1.6.x and better detection of svn mv'ed files

svn-1.6.x 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
- moved files


Modified:
   trunk/vc/svn.py

Modified: trunk/vc/svn.py
==============================================================================
--- trunk/vc/svn.py	(original)
+++ trunk/vc/svn.py	Sat Apr 11 22:19:40 2009
@@ -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,36 @@
                     raise
 
         matches = []
+
+        re_status_moved = re.compile(r'^(A) +[+] +- +([?]) +[?] +([^ ].*)$')
+        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 moved file
+            m = re_status_moved.match(line)
+            if m:
+                matches.append((m.group(3), m.group(1), m.group(2)))
+                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]