Rev 1746: Cope with file properties being modified by other parties than bzr-svn. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Sun Nov 9 18:33:16 GMT 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/trunk

------------------------------------------------------------
revno: 1746
revision-id: jelmer at samba.org-20081109183314-hotooz35p7sapkej
parent: jelmer at samba.org-20081109164122-e48e1e7ka277ef8l
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sun 2008-11-09 19:33:14 +0100
message:
  Cope with file properties being modified by other parties than bzr-svn.
modified:
  NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  mapping.py                     mapping.py-20080128201303-6cp01phc0dmc0kiv-1
=== modified file 'NEWS'
--- a/NEWS	2008-11-08 21:11:28 +0000
+++ b/NEWS	2008-11-09 18:33:14 +0000
@@ -10,6 +10,9 @@
 
    * Fix knit corruption because text revisions weren't stored properly. (#277043)
 
+   * Cope with file properties being modified by other parties than 
+     bzr-svn. (#295284)
+
 bzr-svn 0.4.14	2008-11-03
 
   BUG FIXES

=== modified file 'fetch.py'
--- a/fetch.py	2008-11-09 05:06:06 +0000
+++ b/fetch.py	2008-11-09 18:33:14 +0000
@@ -120,12 +120,6 @@
         return self._open_directory(path, base_revnum)
 
     def change_prop(self, name, value):
-        if self.path == "":
-            # Replay lazy_dict, since it may be more expensive
-            if type(self.editor.revmeta.fileprops) != dict:
-                self.editor.revmeta.fileprops = {}
-            self.editor.revmeta.fileprops[name] = (None, value)
-
         if name in (properties.PROP_ENTRY_COMMITTED_DATE,
                     properties.PROP_ENTRY_COMMITTED_REV,
                     properties.PROP_ENTRY_LAST_AUTHOR,

=== modified file 'mapping.py'
--- a/mapping.py	2008-11-09 05:06:06 +0000
+++ b/mapping.py	2008-11-09 18:33:14 +0000
@@ -51,6 +51,15 @@
 SVN_REVPROP_BZR_TEXT_PARENTS = 'bzr:text-parents'
 
 
+def find_new_lines((oldvalue, newvalue)):
+    if oldvalue is None:
+        oldvalue = ""
+    if not newvalue.startswith(oldvalue):
+        raise ValueError("Existing contents were changed")
+    appended = newvalue[len(oldvalue):]
+    return appended.splitlines()
+
+
 def escape_svn_path(x):
     """Escape a Subversion path for use in a revision identifier.
 
@@ -541,7 +550,15 @@
     def get_rhs_parents(self, branch_path, revprops, fileprops):
         bzr_merges = fileprops.get(SVN_PROP_BZR_ANCESTRY+str(self.scheme), None)
         if bzr_merges is not None:
-            return parse_merge_property(bzr_merges[1].splitlines()[-1])
+            try:
+                new_lines = find_new_lines(bzr_merges)
+            except ValueError, e:
+                mutter(str(e))
+                return ()
+            if len(new_lines) != 1:
+                mutter("unexpected number of lines in bzr merge property: %r" % new_lines)
+                return ()
+            return parse_merge_property(new_lines[0])
 
         return ()
 
@@ -598,12 +615,18 @@
         if text is None:
             return (None, None)
 
-        lines = text[1].splitlines()
-        if len(lines) == 0:
-            return (None, None)
-
-        try:
-            return parse_revid_property(lines[-1])
+        try:
+            new_lines = find_new_lines(text)
+        except ValueError, e:
+            mutter(str(e))
+            return (None, None)
+
+        if len(new_lines) != 1:
+            mutter("unexpected number of lines: %r" % new_lines)
+            return (None, None)
+
+        try:
+            return parse_revid_property(new_lines[0])
         except errors.InvalidPropertyValue, e:
             mutter(str(e))
             return (None, None)




More information about the bazaar-commits mailing list