# [PATCH 0/2] remote-bzr: couple of fixes

4 messages from 2013-05-04 to 2013-05-04. Participants: Felipe Contreras.
Thread: https://gitlist.dev/t/33721

## Felipe Contreras, 2013-05-04 00:22

Subject: [PATCH 0/2] remote-bzr: couple of fixes
Message-ID: <1367626957-13858-1-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1367626957-13858-1-git-send-email-felipe.contreras%40gmail.com

```
Hi,

A few fixes to be applied on top of the massive changes already queued. Nothing major.

Felipe Contreras (2):
  remote-bzr: convert all unicode keys to str
  remote-bzr: avoid bad refs

 contrib/remote-helpers/git-remote-bzr | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

-- 
1.8.3.rc0.401.g45bba44

```

## Felipe Contreras, 2013-05-04 00:22

Subject: [PATCH 1/2] remote-bzr: convert all unicode keys to str
Message-ID: <1367626957-13858-2-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1367626957-13858-2-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1367626957-13858-1-git-send-email-felipe.contreras@gmail.com>

```
Otherwise some versions of bazaar might barf.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 161f831..bbaaa8f 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -95,7 +95,7 @@ class Marks:
         return self.marks[rev]
 
     def to_rev(self, mark):
-        return self.rev_marks[mark]
+        return str(self.rev_marks[mark])
 
     def next_mark(self):
         self.last_mark += 1
@@ -621,7 +621,7 @@ def parse_commit(parser):
         files[path] = f
 
     committer, date, tz = committer
-    parents = [str(mark_to_rev(p)) for p in parents]
+    parents = [mark_to_rev(p) for p in parents]
     revid = bzrlib.generate_ids.gen_revision_id(committer, date)
     props = {}
     props['branch-nick'] = branch.nick
-- 
1.8.3.rc0.401.g45bba44

```

## Felipe Contreras, 2013-05-04 00:22

Subject: [PATCH 2/2] remote-bzr: avoid bad refs
Message-ID: <1367626957-13858-3-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1367626957-13858-3-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1367626957-13858-1-git-send-email-felipe.contreras@gmail.com>

```
Turns out fast-export throws bad 'reset' commands because of a behavior
in transport-helper that is not even needed.

We should ignore them, otherwise we will threat them as branches and
fail.

This was fixed in v1.8.2, but some people use this script in older
versions of git.

Also, check if the ref was a tag, and skip it for now.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index bbaaa8f..1f48b00 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -682,23 +682,31 @@ def do_export(parser):
             die('unhandled export command: %s' % line)
 
     for ref, revid in parsed_refs.iteritems():
-        name = ref[len('refs/heads/'):]
-        branch = bzrlib.branch.Branch.open(branches[name])
-        branch.generate_revision_history(revid, marks.get_tip(name))
+        if ref.startswith('refs/heads/'):
+            name = ref[len('refs/heads/'):]
+            branch = bzrlib.branch.Branch.open(branches[name])
+            branch.generate_revision_history(revid, marks.get_tip(name))
 
-        if name in peers:
-            peer = bzrlib.branch.Branch.open(peers[name])
+            if name in peers:
+                peer = bzrlib.branch.Branch.open(peers[name])
             try:
                 peer.bzrdir.push_branch(branch, revision_id=revid)
             except bzrlib.errors.DivergedBranches:
                 print "error %s non-fast forward" % ref
                 continue
 
-        try:
-            wt = branch.bzrdir.open_workingtree()
-            wt.update()
-        except bzrlib.errors.NoWorkingTree:
-            pass
+            try:
+                wt = branch.bzrdir.open_workingtree()
+                wt.update()
+            except bzrlib.errors.NoWorkingTree:
+                pass
+        elif ref.startswith('refs/tags/'):
+            # TODO: implement tag push
+            print "error %s pushing tags not supported" % ref
+            continue
+        else:
+            # transport-helper/fast-export bugs
+            continue
 
         print "ok %s" % ref
 
-- 
1.8.3.rc0.401.g45bba44

```

## Felipe Contreras, 2013-05-04 00:32

Subject: Re: [PATCH 0/2] remote-bzr: couple of fixes
Message-ID: <CAMP44s02Mf2PqGg=zJe-szKdUYb1tg5ryU8ykWcMPTSEB7qsgw@mail.gmail.com>
URL: https://gitlist.dev/e/CAMP44s02Mf2PqGg%3DzJe-szKdUYb1tg5ryU8ykWcMPTSEB7qsgw%40mail.gmail.com
In-Reply-To: <1367626957-13858-1-git-send-email-felipe.contreras@gmail.com>

```
On Fri, May 3, 2013 at 7:22 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> A few fixes to be applied on top of the massive changes already queued. Nothing major.
>
> Felipe Contreras (2):
>   remote-bzr: convert all unicode keys to str
>   remote-bzr: avoid bad refs

There's a problem with the second patch. Re-rolling.

-- 
Felipe Contreras

```
