New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new remote bzr branch when it doesn't exist on push #8

Open
dequis opened this Issue Sep 22, 2014 · 8 comments

Comments

Projects
None yet
6 participants
@dequis
Contributor

dequis commented Sep 22, 2014

When pushing, if the remote bzr branch does not exist, this error appears:

$ git push bzr-dequis bzr-test
Traceback (most recent call last):
  File "/home/dx/bin/git-remote-bzr", line 981, in <module>
    sys.exit(main(sys.argv))
  File "/home/dx/bin/git-remote-bzr", line 967, in main
    do_export(parser)
  File "/home/dx/bin/git-remote-bzr", line 682, in do_export
    branch = get_remote_branch(name)
  File "/home/dx/bin/git-remote-bzr", line 787, in get_remote_branch
    remote_branch = bzrlib.branch.Branch.open(branches[name],
KeyError: 'bzr-test'
error: failed to push some refs to 'bzr::bzr+ssh://dequis.org/home/dx/web/bzr/bitlbee'

I tried patching it, my (failed) attempt is at dequis@7365028 - a bit hacky (getting url from sys.argv[2]) and doesn't really work, other than creating an empty branch that can't get pushed to, while never reporting any errors on "git push":

$ git push bzr-dequis bzr-test
To bzr::bzr+ssh://dequis.org/home/dx/web/bzr/bitlbee
   bf4be5b..bf4be5b  bzr-test -> bzr-test

That short commit hash is my current HEAD commit. It shows this exact same output every time, even if the remote doesn't exist or after running it twice in a row.

The bzr log output in the bzr-test directory in the remote repo is empty.

The bzr log output in .git/bzr/bzr-dequis/clone/bzr-test shows 1046 revisions, the last one being HEAD.

I have no idea what I'm doing.

@baby-gnu

This comment has been minimized.

Show comment
Hide comment
@baby-gnu

baby-gnu Feb 27, 2015

I have a similar problem when I want to contribute to launchpad.

The clone is OK:

$ git clone bzr::lp:ubumirror
Cloning into 'ubumirror'...
Checking connectivity... done.

Now I create a new git branch and makes some changes

$ git checkout -b test master
$ echo "Test file" > test
$ git add test
$ git commit -m "Test commit"

I add my personal not yet existing launchpad repository:

$ git remote add perso bzr::lp:~mylogin/ubumirror
$ git push perso test
Traceback (most recent call last):
  File "/usr/bin/git-remote-bzr", line 1022, in <module>
    sys.exit(main(sys.argv))
  File "/usr/bin/git-remote-bzr", line 994, in main
    repo = get_repo(url, alias)
  File "/usr/bin/git-remote-bzr", line 870, in get_repo
    origin = bzrlib.bzrdir.BzrDir.open(url, possible_transports=transports)
  File "/usr/lib/python2.7/dist-packages/bzrlib/controldir.py", line 687, in open
    t = _mod_transport.get_transport(base, possible_transports)
  File "/usr/lib/python2.7/dist-packages/bzrlib/transport/__init__.py", line 1680, in get_transport
    return get_transport_from_url(location_to_url(base), possible_transports)
  File "/usr/lib/python2.7/dist-packages/bzrlib/transport/__init__.py", line 1602, in location_to_url
    location = directories.dereference(location)
  File "/usr/lib/python2.7/dist-packages/bzrlib/directory_service.py", line 66, in dereference
    return service().look_up(name, url)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_directory.py", line 68, in look_up
    return self._resolve(url)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_directory.py", line 165, in _resolve
    result = self._resolve_locally(path, url, _request_factory)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_directory.py", line 93, in _resolve_locally
    return self._resolve_via_xmlrpc(path, url, _request_factory)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_directory.py", line 103, in _resolve_via_xmlrpc
    path=url, extra=fault.faultString)
bzrlib.errors.InvalidURL: Invalid url supplied to transport: "lp:~mylogin/ubumirror": ~mylogin/ubumirror is too short to be a branch name. Try '~<owner>/+junk/<branch>', '~<owner>/<product>/<branch> or '~<owner>/<distribution>/<series>/<sourcepackage>/<branch>'.

baby-gnu commented Feb 27, 2015

I have a similar problem when I want to contribute to launchpad.

The clone is OK:

$ git clone bzr::lp:ubumirror
Cloning into 'ubumirror'...
Checking connectivity... done.

Now I create a new git branch and makes some changes

$ git checkout -b test master
$ echo "Test file" > test
$ git add test
$ git commit -m "Test commit"

I add my personal not yet existing launchpad repository:

$ git remote add perso bzr::lp:~mylogin/ubumirror
$ git push perso test
Traceback (most recent call last):
  File "/usr/bin/git-remote-bzr", line 1022, in <module>
    sys.exit(main(sys.argv))
  File "/usr/bin/git-remote-bzr", line 994, in main
    repo = get_repo(url, alias)
  File "/usr/bin/git-remote-bzr", line 870, in get_repo
    origin = bzrlib.bzrdir.BzrDir.open(url, possible_transports=transports)
  File "/usr/lib/python2.7/dist-packages/bzrlib/controldir.py", line 687, in open
    t = _mod_transport.get_transport(base, possible_transports)
  File "/usr/lib/python2.7/dist-packages/bzrlib/transport/__init__.py", line 1680, in get_transport
    return get_transport_from_url(location_to_url(base), possible_transports)
  File "/usr/lib/python2.7/dist-packages/bzrlib/transport/__init__.py", line 1602, in location_to_url
    location = directories.dereference(location)
  File "/usr/lib/python2.7/dist-packages/bzrlib/directory_service.py", line 66, in dereference
    return service().look_up(name, url)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_directory.py", line 68, in look_up
    return self._resolve(url)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_directory.py", line 165, in _resolve
    result = self._resolve_locally(path, url, _request_factory)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_directory.py", line 93, in _resolve_locally
    return self._resolve_via_xmlrpc(path, url, _request_factory)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_directory.py", line 103, in _resolve_via_xmlrpc
    path=url, extra=fault.faultString)
bzrlib.errors.InvalidURL: Invalid url supplied to transport: "lp:~mylogin/ubumirror": ~mylogin/ubumirror is too short to be a branch name. Try '~<owner>/+junk/<branch>', '~<owner>/<product>/<branch> or '~<owner>/<distribution>/<series>/<sourcepackage>/<branch>'.
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 5, 2015

@baby-gnu in your case it looks like you just set the remote wrong. Instead of git remote add perso bzr::lp:~mylogin/ubumirror, you should do git remote add perso bzr::lp:~mylogin/ubumirror/my-branch-name and that should resolve that specific issue. However then you'll just get bzrlib.errors.NotBranchError: Not a branch: "bzr+ssh://bazaar.launchpad.net/~mylogin/ubumirror/my-branch-name/". unless you create that branch first.

ghost commented Mar 5, 2015

@baby-gnu in your case it looks like you just set the remote wrong. Instead of git remote add perso bzr::lp:~mylogin/ubumirror, you should do git remote add perso bzr::lp:~mylogin/ubumirror/my-branch-name and that should resolve that specific issue. However then you'll just get bzrlib.errors.NotBranchError: Not a branch: "bzr+ssh://bazaar.launchpad.net/~mylogin/ubumirror/my-branch-name/". unless you create that branch first.

@baby-gnu

This comment has been minimized.

Show comment
Hide comment
@baby-gnu

baby-gnu Mar 6, 2015

@Robru thanks for the explanation.

So, if I understand correctly, I can not have one git repository to track several remote bzr branches?

As my remote branch was not created, I used git-bzr-ng which successfully created the remote branch.

To not pollute this issue, I openned #12.

Regards.

baby-gnu commented Mar 6, 2015

@Robru thanks for the explanation.

So, if I understand correctly, I can not have one git repository to track several remote bzr branches?

As my remote branch was not created, I used git-bzr-ng which successfully created the remote branch.

To not pollute this issue, I openned #12.

Regards.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 6, 2015

@baby-gnu. I don't actually know, I wasn't able to get this to work. I've recently tried https://github.com/zyga/git-lp and it seems to work much better with the launchpad workflow.

ghost commented Mar 6, 2015

@baby-gnu. I don't actually know, I wasn't able to get this to work. I've recently tried https://github.com/zyga/git-lp and it seems to work much better with the launchpad workflow.

@christofferholmstedt

This comment has been minimized.

Show comment
Hide comment
@christofferholmstedt

christofferholmstedt Mar 22, 2015

I'm experiencing this as well. I have cloned the Inkscape repository "lp:inkscape" and want to push either to "lp:~inkscape.dev/inkscape/<new_branch_name>" or "lp:~christoffer-holmstedt/inkscape/<new_branch_name>". Adding them as remote and then pushing doesn't work.

If this doesn't work I'm not sure which workflows are supported with the git-remote-bzr helper. I will have to look into this later on.

christofferholmstedt commented Mar 22, 2015

I'm experiencing this as well. I have cloned the Inkscape repository "lp:inkscape" and want to push either to "lp:~inkscape.dev/inkscape/<new_branch_name>" or "lp:~christoffer-holmstedt/inkscape/<new_branch_name>". Adding them as remote and then pushing doesn't work.

If this doesn't work I'm not sure which workflows are supported with the git-remote-bzr helper. I will have to look into this later on.

@larsks

This comment has been minimized.

Show comment
Hide comment
@larsks

larsks Jun 3, 2015

👍

I was just trying to figure out this issue. I would like to push a PR to a launchpad project, but given a remote like:

$ git remote -v
[...]
lp  bzr::lp:~larsks/project/my-test-branch (fetch)
lp  bzr::lp:~larsks/project/my-test-branch (push)

Attempts to push my changes:

$ git push lp master

Result in:

bzrlib.errors.NotBranchError: Not a branch: "bzr+ssh://bazaar.launchpad.net/~larsks/project/my-test-branch/".

I ended up just using the bzr command to clone the remote project, then git format-patch to move my changes over, then bzr push to create the branch and submit my changes...but I wish I could do this directly from git.

Once the remote branch was created I am able to pushand pull without a problem using git-bzr-remote.

larsks commented Jun 3, 2015

👍

I was just trying to figure out this issue. I would like to push a PR to a launchpad project, but given a remote like:

$ git remote -v
[...]
lp  bzr::lp:~larsks/project/my-test-branch (fetch)
lp  bzr::lp:~larsks/project/my-test-branch (push)

Attempts to push my changes:

$ git push lp master

Result in:

bzrlib.errors.NotBranchError: Not a branch: "bzr+ssh://bazaar.launchpad.net/~larsks/project/my-test-branch/".

I ended up just using the bzr command to clone the remote project, then git format-patch to move my changes over, then bzr push to create the branch and submit my changes...but I wish I could do this directly from git.

Once the remote branch was created I am able to pushand pull without a problem using git-bzr-remote.

@khurshid-alam

This comment has been minimized.

Show comment
Hide comment
@khurshid-alam

khurshid-alam Dec 4, 2015

git-bzr-ng is better in this case where it can create remote branch if it doesn't exist.

khurshid-alam commented Dec 4, 2015

git-bzr-ng is better in this case where it can create remote branch if it doesn't exist.

mnauw added a commit to mnauw/git-remote-bzr that referenced this issue Oct 23, 2016

@mnauw

This comment has been minimized.

Show comment
Hide comment
@mnauw

mnauw Oct 23, 2016

The above commit (supported by preceding ones) will now create a branch when needed on push. As such, the following launchpad workflow is possible using git-remote-bzr:

$ git clone bzr::lp:project
$ git remote add perso bzr::lp:~user/project/feature
$ git push perso master

Note that the remote url will have to contain the full branch name (as also mentioned in earlier comments). Upgrading to latest HEAD in that commit's repo additionally supports the following:

$ git checkout -b feature master
# work on feature
$ git push perso feature:master

While the difference is marginal, it is is slightly cleaner in that the perso remote's single branch is then usually referred to as master.

mnauw commented Oct 23, 2016

The above commit (supported by preceding ones) will now create a branch when needed on push. As such, the following launchpad workflow is possible using git-remote-bzr:

$ git clone bzr::lp:project
$ git remote add perso bzr::lp:~user/project/feature
$ git push perso master

Note that the remote url will have to contain the full branch name (as also mentioned in earlier comments). Upgrading to latest HEAD in that commit's repo additionally supports the following:

$ git checkout -b feature master
# work on feature
$ git push perso feature:master

While the difference is marginal, it is is slightly cleaner in that the perso remote's single branch is then usually referred to as master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment