[meld] Validate bzr status lines to avoid shelved item bug (closes bgo#675312)



commit 139b2dd0fe64ee104e7abf97aded11a44948f37f
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Tue May 15 07:55:46 2012 +1000

    Validate bzr status lines to avoid shelved item bug (closes bgo#675312)
    
    In bzr 2.3+, shelved items cause the status listing to include an extra
    line at the end indicating their presence. This patch adds some simple
    regex-based validation of status lines to avoid including any spurious
    items in our status results.
    
    Patch from Per ÃngstrÃm.

 meld/vc/bzr.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/meld/vc/bzr.py b/meld/vc/bzr.py
index a5b2883..aaeee6a 100644
--- a/meld/vc/bzr.py
+++ b/meld/vc/bzr.py
@@ -25,6 +25,7 @@
 import os
 import errno
 import _vc
+import re
 
 class Vc(_vc.CachedVc):
 
@@ -36,6 +37,7 @@ class Vc(_vc.CachedVc):
 
     # We use None here to indicate flags that we don't deal with or care about
     state_1_map = {
+        " ": None,               # First status column empty
         "+": None,               # File versioned
         "-": None,               # File unversioned
         "R": None,               # File renamed
@@ -46,11 +48,14 @@ class Vc(_vc.CachedVc):
     }
 
     state_2_map = {
+        " ": _vc.STATE_NORMAL,   # Second status column empty
         "N": _vc.STATE_NEW,      # File created
         "D": _vc.STATE_REMOVED,  # File deleted
         "K": None,               # File kind changed
         "M": _vc.STATE_MODIFIED, # File modified
     }
+    
+    valid_status_re = r'[%s][%s]\*?\s+' % (''.join(state_1_map.keys()), ''.join(state_2_map.keys()))
 
     def commit_command(self, message):
         return [self.CMD] + self.CMDARGS + ["commit", "-m", message]
@@ -88,7 +93,8 @@ class Vc(_vc.CachedVc):
         tree_state = {}
         for entry in entries:
             state_string, name = entry[:3], entry[4:]
-
+            if not re.match(self.valid_status_re, state_string):
+                continue
             # TODO: We don't do anything with exec bit changes.
             path = os.path.join(branch_root, name.strip())
             state = self.state_1_map.get(state_string[0], None)



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