No API to create a branch reference without opening it

Bug #139109 reported by David Allouche
2
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Wishlist
Unassigned

Bug Description

The code to create a branch reference on disk is in bzrlib.branch.BranchReference.initialize. After creating the branch reference, it opens it.

For testing, it is sometimes desirable to create a branch reference that cannot be opened (e.g. pointing to http://example.com/branch).

Currently, bzrlib does not provide a way to create a branch reference on disk without opening it. The two options I can see are: 1. reimplementing branch reference creation in the test code 2. subclassing BranchReferenceFormat and overriding open() to be a no-op, so initialize() do not actually open the reference.

Both solutions are hackish.

Extracting the branch reference creation code into BranchReferenceFormat.initialize_without_opening would solve this problem.

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 139109] No API to create a branch reference without opening it

> Currently, bzrlib does not provide a way to create a branch reference on
> disk without opening it. The two options I can see are: 1.
> reimplementing branch reference creation in the test code 2. subclassing
> BranchReferenceFormat and overriding open() to be a no-op, so
> initialize() do not actually open the reference.
>
> Both solutions are hackish.

Another temporary solution would be to call the current code, and
expect that it will fail after creating the reference but before
opening the refererent. I haven't checked that works, but it's
probably cleaner than the alternatives.

> Extracting the branch reference creation code into
> BranchReferenceFormat.initialize_without_opening would solve this
> problem.

That sounds good to me; patch welcome.

--
Martin

Martin Pool (mbp)
Changed in bzr:
importance: Undecided → Wishlist
status: New → Triaged
Curtis Hovey (sinzui)
tags: added: tech-debt
Martin Pool (mbp)
Changed in bzr:
status: Triaged → Confirmed
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.