Rev 1431: Support creating mergeinfo properties. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Thu Jul 3 23:31:17 BST 2008


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

------------------------------------------------------------
revno: 1431
revision-id: jelmer at samba.org-20080703223116-qdllxs4qgtn0pck3
parent: jelmer at samba.org-20080703222442-ns861ruy52rgwv3q
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-07-04 00:31:16 +0200
message:
  Support creating mergeinfo properties.
modified:
  properties.py                  util.py-20080502170127-o220e9py99vt69s6-1
  tests/test_properties.py       test_properties.py-20080703215223-t5ydp87wwi7dtyas-1
=== modified file 'properties.py'
--- a/properties.py	2008-07-03 22:24:42 +0000
+++ b/properties.py	2008-07-03 22:31:16 +0000
@@ -13,6 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+from bzrlib import urlutils
 from bzrlib.errors import BzrError
 
 
@@ -90,6 +91,19 @@
     return ret
 
 
+def generate_mergeinfo_property(merges):
+    def formatrange((start, end)):
+        if start == end:
+            return "%d" % (start, )
+        else:
+            return "%d-%d" % (start, end)
+    text = ""
+    for (path, ranges) in merges.items():
+        assert path.startswith("/")
+        text += "%s:%s\n" % (path, ",".join(map(formatrange, ranges)))
+    return text
+
+
 PROP_EXECUTABLE = 'svn:executable'
 PROP_EXECUTABLE_VALUE = '*'
 PROP_EXTERNALS = 'svn:externals'

=== modified file 'tests/test_properties.py'
--- a/tests/test_properties.py	2008-07-03 22:24:42 +0000
+++ b/tests/test_properties.py	2008-07-03 22:31:16 +0000
@@ -75,12 +75,12 @@
 
     def test_parse_invalid_missing_url(self):
         """No URL specified."""
-        self.assertRaises(InvalidExternalsDescription, 
+        self.assertRaises(properties.InvalidExternalsDescription, 
             lambda: properties.parse_externals_description("http://example.com/", "bla"))
             
     def test_parse_invalid_too_much_data(self):
         """No URL specified."""
-        self.assertRaises(InvalidExternalsDescription, 
+        self.assertRaises(properties.InvalidExternalsDescription, 
             lambda: properties.parse_externals_description(None, "bla -R40 http://bla/"))
  
 
@@ -94,3 +94,15 @@
     def test_empty(self):
         self.assertEquals({}, properties.parse_mergeinfo_property(""))
        
+
+class MergeInfoPropertyCreatorTests(TestCase):
+    def test_simple_range(self):
+        self.assertEquals("/trunk:1-2\n", properties.generate_mergeinfo_property({"/trunk": [(1,2)]}))
+
+    def test_simple_individual(self):
+        self.assertEquals("/trunk:1\n", properties.generate_mergeinfo_property({"/trunk": [(1,1)]}))
+
+    def test_empty(self):
+        self.assertEquals("", properties.generate_mergeinfo_property({}))
+
+




More information about the bazaar-commits mailing list