Using Bazaar programatically
Gertjan Klein
gklein at xs4all.nl
Sat Feb 9 09:40:15 GMT 2008
Robert Collins wrote:
>On Sat, 2008-02-09 at 08:22 +0100, Gertjan Klein wrote:
>> As smart_add is a method
>> of the working tree, which has an implied base directory, I am tempted
>> to think this is a bug. Would you agree?
>
>It is; it only recently got migrated there and obviously we have not
>done as good a job of the migration as might be desired :).
Thanks for confirming that. Would it make sense for me to use the
development version of bazaar (assuming this bug will get fixed)?
I have found other puzzling behaviour. Using almost the same test
program as I posted before (pasted below), I found that I can
programatically add files to a maximum of one subdirectory deep only (so
my response to James Westby was spoken too soon).
Testing is done on a newly versioned directory each time (i.e., I remove
the .bzr directory and run "bzr init" before each test).
If I add a file *one* subdirectory deep, my test prints:
Current directory: C:\dev\bzr\cache
smart_add: result: ([u'ENSEMBLE', u'ENSEMBLE/Documatic.txt'], {})
commit: result: gklein at xs4all.nl-20080209093146-fp4rsyrkhrdr94f3
If, in the exact same test, I add a file *two* subdirectories deep, I
get the "paths not versioned" traceback:
>Current directory: C:\dev\bzr\cache
>smart_add: result: ([u'ENSEMBLE', u'ENSEMBLE/GJ', u'ENSEMBLE/GJ/Documatic.txt'], {})
>Traceback (most recent call last):
> File "C:\Temp\commit_test.py", line 22, in <module>
> test()
> File "C:\Temp\commit_test.py", line 18, in test
> res = wtree.commit(message, specific_files=files)
> File "<string>", line 4, in commit_write_locked
> File "C:\dev\Python\Python25\Lib\site-packages\bzrlib\workingtree_4.py", line 246, in commit
> result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
> File "<string>", line 4, in commit_write_locked
> File "C:\dev\Python\Python25\Lib\site-packages\bzrlib\mutabletree.py", line 187, in commit
> revprops=revprops, *args, **kwargs)
> File "C:\dev\Python\Python25\Lib\site-packages\bzrlib\commit.py", line 315, in commit
> specific_files, [self.basis_tree, self.work_tree])
> File "C:\dev\Python\Python25\Lib\site-packages\bzrlib\tree.py", line 596, in find_ids_across_trees
> require_versioned)
> File "C:\dev\Python\Python25\Lib\site-packages\bzrlib\tree.py", line 623, in _find_ids_across_trees
> raise errors.PathsNotVersionedError(not_versioned)
>bzrlib.errors.PathsNotVersionedError: Path(s) are not versioned: ENSEMBLE\GJ\Documatic.txt
Oddly, the smart_add results indicate that the full path (i.e., both
subdirectories) *are* added. I am, again, tempted to think of this as a
bug. Would you agree?
Regards,
Gertjan.
----------
import os
from bzrlib import workingtree
def test():
dir = r'C:\dev\bzr\cache'
os.chdir(dir)
print 'Current directory: %s' % os.getcwd()
# This one works:
#file = r'ENSEMBLE\Documatic.txt'
# This one doesn't:
file = r'ENSEMBLE\GJ\Documatic.txt'
files = [file]
message = "Test commit"
wtree = workingtree.WorkingTree.open(dir)
res = wtree.smart_add(files)
print 'smart_add: result: %s' % str(res)
res = wtree.commit(message, specific_files=files)
print 'commit: result: %s' % str(res)
if __name__ == '__main__':
test()
--
Gertjan Klein <gklein at xs4all.nl>
More information about the bazaar
mailing list