Creating a branch other than master using bzr-git

John Arbash Meinel john at arbash-meinel.com
Tue Nov 25 16:41:33 GMT 2008


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

Stephen J. Turnbull wrote:
> Jelmer Vernooij writes:
> 
>  > > Thanks for the information. Seems like the branch could be appended onto
>  > > the URL somehow to indicate what branch. I've seen things like:
>  > 
>  > > /repos/some_project.git/edge
>  > 
>  > > Where "edge" is a branch within the git repository.
> 
>  > The syntax used here should probably be consistent with that used for
>  > multiple branches in the same directory for bazaar itself (which
>  > hasn't been discussed yet). Using slashes seems like a bad idea to me
>  > though; it's ambiguous (what if you have a nested fs branch or a file with
>  > the same name?)
> 
> I agree.  I doubt this is well-thought out even for git, since until
> recently git didn't support submodules at all.
> 
> I would use an URL-based notation, which has some potential for
> avoiding file system encoding lossage (but that's a hard problem).
> 
> I kinda like URL fragment notation (http://repos/myrepo#mybranch) for
> this, but it might be better to use query notation
> (http://repos/myrepo?branch=mybranch), especially since this can be
> generalized to other refs (tags, revnos) in a way that allows them to
> be given different treatment if appropriate.  (No, I have nothing in
> particular in mind.)
> 

So there are a few forms. And I'd like us to consider that it would be
nice if an HTTP request could actually return the right thing for the
given request. Further, we have to consider what it would look like as a
local path.

1) Fragment
http://host/repos#mybranch
.#branch ?
/path/to/repo#branch

In Bash, # is a comment character, and in zsh # is a regex char. Either
way, you would have to escape it to make it work, so those actually become:

.\#branch
/path/to/repo\#branch

Another problem with "#" is that it isn't really designed to allow the
HTTP server to yield a different page. I could be completely wrong, but
I think in general it is meant to handle jumping to a certain point on a
page. Anyway, it could work, but it is a bit tricky.

2) Query
http://host/repos/?branch=mybranch

This is very nice for HTTP, for the local filesystem, again ? is a
special character (glob) so it has to be escaped. I guess on bash if it
doesn't match anything it just gets passed through, but on zsh if it
doesn't match it gives an error right away.

.\?branch=mybranch
/path/to/repo\?branch=mybranch

It is also rather wordy. I suppose ideally we would use context a bit
more, and then something like:

  bzr log mybranch

Is just DWIM. If it finds a file with that name, it gives the log of the
file, else it looks for a branch in local branches, else it looks for a
sibling branch, else ...

It would be nice if we could be a bit more exact in our requests, but
I'll notice that right now we are very precise and people don't like it
because it is "too verbose" to type ../mybranch rather than "mybranch".
(I guess it is also an issue when deeply nested, though I've found
~/dev/bzr/bzr.dev pretty easy to type.)

3) Parameters
The URL spec allows you to use a ";" to specify parameters to each
portion of the path:
http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax
  Each segment can contain parameters separated from it using a
  semicolon (";"), though this is rarely used in practice

This would end up something like:
  http://host/repos;mybranch
or possibly
  http://host/repos;branch=mybranch

Again this doesn't work terribly well in bash/zsh as ';' is the
end-of-command separator, so again you have to escape it.

  bzr log http://host/repos\;mybranch
  bzr log .\;mybranch
  bzr log /path/to/repo\;mybranch

And you still have the "branch=mybranch" is a bit verbose issue.



So in the end, all URL special characters are also shell special
characters, so there isn't a great way to specify these things via
command line. I suppose if we assume that bash behavior is the most
common, then using query syntax at least means that you won't always
have to escape the "?" (as bash will pass it verbatim if it doesn't match).

I believe query form is the nicest for a CGI script to process as well,
so perhaps that is the form we should use. And then special case things
locally so that "bzr log mybranch" gets DWIMed.

One other possibility is to make more use of our "-d" flag, which is
basically a context value. So if you wanted to get the log for a given
file, instead of doing:

  bzr log http://bazaar-vcs.org/bzr/bzr.dev/NEWS

you would do:

  bzr log -d http://bazaar-vcs.org/bzr/bzr.dev NEWS

With the advantage that this scales up to multiple files without having
to repeat the long URL or use {} shell notation.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkksKr0ACgkQJdeBCYSNAAONjACg2iZqoDw1hU13kv80ChuCIbEA
ec0AnjxHb08SrMpyNWH5rPomT2fQBOO1
=gBOO
-----END PGP SIGNATURE-----



More information about the bazaar mailing list