[RFC] Bug 440952: "be more helpful when attempting to branch a shared repo"

Brian de Alwis bsd at cs.ubc.ca
Fri Oct 9 18:17:55 BST 2009


On 9-Oct-2009, at 5:22 AM, Vincent Ladeuil wrote:
> That sounds like a very clever way to address the bug.
>
> Did you try to run the test suite to check ?

I hadn't, but just did and there's no difference (8 failures in  
test_http.py, 71 known failures).

> My only concern would be that foreign branches use the same code
> and so would fail to find the file too, but they may be doing so
> in different ways.


Those kinds of interactions are beyond me at the moment.  But it turns  
out it doesn't work when talking to a smart server across bzr+ssh://.

On 9-Oct-2009, at 10:25 AM, John Arbash Meinel wrote:
> I suppose my primary question is whether Branch.find_format() should  
> be
> doing this, or whether BzrDir.open_branch() should.
>
> Namely, if we have a BzrDir object, then we know there *is* a bzrdir
> present at that location, which may have a repository or branch.
>
> Anyway, the layering "feels" better if BzrDir is the one probing if  
> this
> branch location is actually a repository, rather than putting that  
> logic
> into Branch.

I do agree: it does feel like a violation of layering.

So I've tried putting the logic into BzrDir.  Since BzrDir.open_branch 
() is abstract, I had to modify BzrDirMeta1.open_branch() (which was  
straightforward), BzrDirPreSplitOut.open_branch() (which was not, and  
I don't know how to excercise it), and RemoteBrank.open_branch()  
(where I got a bit lost).  Since implementations of BzrDir.open_branch  
must do this test, which is a bit fragile, I looked into trying to  
refactor a common BzrDir.open_branch() that looked something like:

     def open_branch(self, unsupported=False, ignore_fallbacks=False):
        try:
             format = self.find_branch_format()
             self._check_supported(format, unsupported)
             return format.open(self, _found=True,  
ignore_fallbacks=ignore_fallbacks)
         except errors.NotBranchError, e:
             # check if repository and provide indication

This moved find_branch_format() from BzrMetaDir1 to BzrDir, but looked  
pretty straight-forward.  I'm not RemoteBranch-savvy to refactor  
RemoteBranch.open_branch() to fit, so I just stuck in the test at the  
appropriate location.

This approach causes two additional test failures as it increments the  
number of messages sent to the HPSS.

This branch is up separately at lp:~slyguy/bzr/bug-440952-bzrdir

Brian.

-- 
"Amusement to an observing mind is study." - Benjamin Disraeli




More information about the bazaar mailing list