This change makes the order of the arguments to Tree.add() consistent with the rest of Dulwich - name, mode, hexsha. The old ordering is still supported but using it will display a deprecation warning.
Cheers, Jelmer
# Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: [email protected] # target_branch: file:///home/jelmer/src/dulwich/trunk/ # testament_sha1: 770c7613d4287d26542e001ffb4a95e3d96e973b # timestamp: 2011-03-13 17:42:48 +0100 # base_revision_id: git-v1:8a2f5cefc0322bc1396c7d7d265e3af7dbf23378 # # Begin patch === modified file 'NEWS' --- NEWS 2011-03-06 03:48:23 +0000 +++ NEWS 2011-03-13 16:40:09 +0000 @@ -16,6 +16,12 @@ * Sphinxified documentation. (Lukasz Balcerzak) + API CHANGES + + * The order of the parameters to Tree.add(name, mode, sha) has changed, and + is now consistent with the rest of Dulwich. Existing code will still + work but print a DeprecationWarning. (Jelmer Vernooij, #663550) + 0.7.0 2011-01-21 FEATURES === modified file 'docs/tutorial/object-store.txt' --- docs/tutorial/object-store.txt 2011-01-24 16:36:50 +0000 +++ docs/tutorial/object-store.txt 2011-03-13 16:40:09 +0000 @@ -27,7 +27,7 @@ >>> from dulwich.objects import Tree >>> tree = Tree() - >>> tree.add(0100644, "spam", blob.id) + >>> tree.add("spam", 0100644, blob.id) Note that "0100644" is the octal form for a regular file with common permissions. You can hardcode them or you can use the ``stat`` module. === modified file 'dulwich/index.py' --- dulwich/index.py 2010-05-24 17:21:02 +0000 +++ dulwich/index.py 2011-03-13 16:40:09 +0000 @@ -330,7 +330,7 @@ sha = build_tree(pathjoin(path, basename)) else: (mode, sha) = entry - tree.add(mode, basename, sha) + tree.add(basename, mode, sha) object_store.add_object(tree) return tree.id return build_tree("") === modified file 'dulwich/objects.py' --- dulwich/objects.py 2011-03-06 03:48:23 +0000 +++ dulwich/objects.py 2011-03-13 16:40:09 +0000 @@ -27,6 +27,7 @@ import os import posixpath import stat +import warnings import zlib from dulwich.errors import ( @@ -819,14 +820,18 @@ self._ensure_parsed() return iter(self._entries) - def add(self, mode, name, hexsha): + def add(self, name, mode, hexsha): """Add an entry to the tree. - :param mode: The mode of the entry as an integral type. Not all possible - modes are supported by git; see check() for details. + :param mode: The mode of the entry as an integral type. Not all + possible modes are supported by git; see check() for details. :param name: The name of the entry, as a string. :param hexsha: The hex SHA of the entry as a string. """ + if type(name) is int and type(mode) is str: + (name, mode) = (mode, name) + warnings.warn("Please use Tree.add(name, mode, hexsha)", + category=DeprecationWarning, stacklevel=2) self._ensure_parsed() self._entries[name] = mode, hexsha self._needs_serialization = True === modified file 'dulwich/tests/test_fastexport.py' --- dulwich/tests/test_fastexport.py 2010-12-12 05:15:03 +0000 +++ dulwich/tests/test_fastexport.py 2011-03-13 16:40:09 +0000 @@ -61,7 +61,7 @@ b = Blob() b.data = "FOO" t = Tree() - t.add(stat.S_IFREG | 0644, "foo", b.id) + t.add("foo", stat.S_IFREG | 0644, b.id) c = Commit() c.committer = c.author = "Jelmer <jelmer@host>" c.author_time = c.commit_time = 1271345553 === modified file 'dulwich/tests/test_objects.py' --- dulwich/tests/test_objects.py 2010-12-19 15:56:03 +0000 +++ dulwich/tests/test_objects.py 2011-03-13 16:40:09 +0000 @@ -26,6 +26,7 @@ import datetime import os import stat +import warnings from dulwich.errors import ( ObjectFormatException, @@ -404,6 +405,26 @@ class TreeTests(ShaFileCheckTests): + def test_add(self): + myhexsha = "d80c186a03f423a81b39df39dc87fd269736ca86" + x = Tree() + x.add("myname", 0100755, myhexsha) + self.assertEquals(x["myname"], (0100755, myhexsha)) + self.assertEquals('100755 myname\0' + hex_to_sha(myhexsha), + x.as_raw_string()) + + def test_add_old_order(self): + myhexsha = "d80c186a03f423a81b39df39dc87fd269736ca86" + x = Tree() + warnings.simplefilter("ignore", DeprecationWarning) + try: + x.add(0100755, "myname", myhexsha) + finally: + warnings.resetwarnings() + self.assertEquals(x["myname"], (0100755, myhexsha)) + self.assertEquals('100755 myname\0' + hex_to_sha(myhexsha), + x.as_raw_string()) + def test_simple(self): myhexsha = "d80c186a03f423a81b39df39dc87fd269736ca86" x = Tree() === modified file 'dulwich/tests/test_patch.py' --- dulwich/tests/test_patch.py 2010-12-18 16:48:28 +0000 +++ dulwich/tests/test_patch.py 2011-03-13 16:40:09 +0000 @@ -256,13 +256,13 @@ changed2 = Blob.from_string("unchanged\nadded\n") unchanged = Blob.from_string("unchanged\n") tree1 = Tree() - tree1.add(0644, "removed.txt", removed.id) - tree1.add(0644, "changed.txt", changed1.id) - tree1.add(0644, "unchanged.txt", changed1.id) + tree1.add("removed.txt", 0644, removed.id) + tree1.add("changed.txt", 0644, changed1.id) + tree1.add("unchanged.txt", 0644, changed1.id) tree2 = Tree() - tree2.add(0644, "added.txt", added.id) - tree2.add(0644, "changed.txt", changed2.id) - tree2.add(0644, "unchanged.txt", changed1.id) + tree2.add("added.txt", 0644, added.id) + tree2.add("changed.txt", 0644, changed2.id) + tree2.add("unchanged.txt", 0644, changed1.id) store.add_objects([(o, None) for o in [ tree1, tree2, added, removed, changed1, changed2, unchanged]]) write_tree_diff(f, store, tree1.id, tree2.id) # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWTpZaogABfffgERUWP///3/x 3Y6////0YAou+rK2hOlAAKG6WkGmjIpRQLhKEmieRExhU2KfpNTYpp6aj1A9RpoPUBtR6npGQJSk 9TaT0002kkAaAAANGgNNAAAA4yZNGIaaGAmhiaNMmIGRhNGmmEGTCRESYTRTNMKT9GVP00hHlNPU 0xB6jIaHqeoxAOMmTRiGmhgJoYmjTJiBkYTRpphBkwkiAQAIgNEyZTSek0bU2kGTEADQZHgBFPPZ VYo2PMTqkxwFZXMNl8Db+4ONrXmu8y5aN3fZhyZiAtfK2w2DpzViXuWFMWBjp6aZePHCLkIIJZ5t G10Ilb6zpNyM3cutSOSQGjIEEEIPkM4a7prvNCX5JciTGwbG2NNg2Hhcv+aO8Fzvc7qwYbnxDZic Gc5Vc5zerHIZEKFqRKPCkhBXywdZMNBXq5S4sqyrMfn7GLvLMXVTLvyFvTab85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ohFsBUwqAOTOmkgdCNZQG5Y9p0YZgvJ0AovYSCZzByM77IUPaEqJrndKBTFMTQqe10 oIGF7bkjpakjBA2mxDW3gUZy7DxbYHD4rTztBmxC8srlQvg+PoVHyEWK6zit0gZeVF0SguH+/PQs 30CDH4efhAZkmQaKYHerOvVYH+fA6K67XhJfYEi9jxYUmSCAjiK89CIQYMV7yqZMLDxmgMIY+jgW EjHC4woFwipStZKoYNujTeJZR710Fi6SbJxOmXi7px7UI9f4pBdyll6L1CG1Qp2GxVxmFIDzilPl uI8YpZoPTrwxDqcFkzWinfERioXE0DxyphZsteohMBuaxEV2msPiIJSiFyCqTFhJqMSUJPKPXvQ+ QWhunQTUBKd7q2l89RoqRsQQtlksoUn4bCiTHdbiYV8UGPlotupBevyDr8T1c/YyF1nPMrThdwj4 CDsMtkwh7GdiurU/kAKHbQ1Ov4GC3jK+SEK9A0l0o2miBEEJjXERqK4C5H/F3JFOFCQOllqiAA==
signature.asc
Description: Digital signature
_______________________________________________ Mailing list: https://launchpad.net/~dulwich-users Post to : [email protected] Unsubscribe : https://launchpad.net/~dulwich-users More help : https://help.launchpad.net/ListHelp

