tree-less merges

Aaron Bentley aaron.bentley at utoronto.ca
Wed Nov 21 21:42:04 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Hudson wrote:
> Aaron Bentley wrote:
>>> Here's a diff
>>
>> Actually I think you forgot to attach the diff.
> 
> Darn!  Trying again.

Here's the sanity check you asked for...

So I also did a merge of the diff refactoring, and then got the diff
passing.  (Before I knew you were doing that.)  It's at my branch:
http://panoramicfeedback.com/opensource/bzr/repo/transform_preview

I've attached a merge directive.

You can see that I've avoided using the private API, except for
_limbo_name.  Aside from _limbo_name, everything you need should be
exposed via the public API, so it would be better to use that.

+    def kind(self, file_id):
+        trans_id = self._transform._r_new_id.get(file_id)
+        if trans_id is None:

You must not assume that a file is unchanged if it has no trans_id
listed in _r_new_id.  _r_new_id is a listing of file-ids that are not
present in the original tree.  In the general case, this does not say
anything about whether the contents have been changed.  It's a much
better idea to follow the example of get_file_mtime and use
trans_id_file_id(file_id).

+            return self._transform._tree.kind(file_id)
+        return self._transform.final_kind(trans_id)

As long as you get the correct trans_id, you can just call final_kind
here.  You don't need conditional logic.

The "final" methods (final_name, final_parent, etc) return the values
that the files will have after the transform is complete.  If that value
has not been changed, it will be the same as in the initial tree.

+    def get_file(self, file_id):
+        trans_id = self._transform._r_new_id.get(file_id)
+        if trans_id is None:
+            return self._transform._tree.get_file(file_id)

While a full implementation of Tree would need to support retrieving
unchanged files, PreviewTree is currently intended only for use with
diff, so it will never be queried about old files.  That's why my
version of get_file doesn't currently do
self._transform._tree.get_file(file_id).

+        return open(self._transform._limbo_files[trans_id])

You should open files in binary mode so that this works properly on windows.

I'll take your test changes, but I'll stop here and let you continue.
Of course, if you have any questions, please ask.

If you want to overwrite your version with mine, you can do "bzr pull
- --overwrite
http://panoramicfeedback.com/opensource/bzr/repo/transform_preview"

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHRKYs0F+nu1YWqI0RAogEAJ4/GXiP9A/pZbDWURJF/ZAmdGWsXwCfWJe2
FbJzt5noTgnXbrsoxf13/Gs=
=96Oq
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: transform-preview-3.diff
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20071121/03ae4043/attachment-0001.diff 


More information about the bazaar mailing list