All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] remote-bzr: fix for disappeared revisions
@ 2013-05-07 23:39 Felipe Contreras
  2013-05-07 23:42 ` Felipe Contreras
  0 siblings, 1 reply; 3+ messages in thread
From: Felipe Contreras @ 2013-05-07 23:39 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

It's possible that the previous tip goes away, we should not assume it's
always present. Fortunately we are only using it to calculate the
progress to display to the user, so only that needs to be fixed.

Also, add a test that triggers this issue.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 15 ++++++++++----
 contrib/remote-helpers/test-bzr.sh    | 37 +++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 0ef30f8..3e452af 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -282,9 +282,13 @@ def export_branch(repo, name):
 
     branch.lock_read()
     revs = branch.iter_merge_sorted_revisions(None, tip, 'exclude', 'forward')
-    tip_revno = branch.revision_id_to_revno(tip)
-    last_revno, _ = branch.last_revision_info()
-    total = last_revno - tip_revno
+    try:
+        tip_revno = branch.revision_id_to_revno(tip)
+        last_revno, _ = branch.last_revision_info()
+        total = last_revno - tip_revno
+    except bzrlib.errors.NoSuchRevision:
+        tip_revno = 0
+        total = 0
 
     for revid, _, seq, _ in revs:
 
@@ -353,7 +357,10 @@ def export_branch(repo, name):
 
         progress = (revno - tip_revno)
         if (progress % 100 == 0):
-            print "progress revision %d '%s' (%d/%d)" % (revno, name, progress, total)
+            if total:
+                print "progress revision %d '%s' (%d/%d)" % (revno, name, progress, total)
+            else:
+                print "progress revision %d '%s' (%d)" % (revno, name, progress)
 
     branch.unlock()
 
diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
index cec55f1..3f417ad 100755
--- a/contrib/remote-helpers/test-bzr.sh
+++ b/contrib/remote-helpers/test-bzr.sh
@@ -300,4 +300,41 @@ test_expect_success 'proper bzr repo' '
   test_cmp ../expected actual
 '
 
+test_expect_success 'strip' '
+  mkdir -p tmp && cd tmp &&
+  test_when_finished "cd .. && rm -rf tmp" &&
+
+  (
+  bzr init bzrrepo &&
+  cd bzrrepo &&
+
+  echo one >> content &&
+  bzr add content &&
+  bzr commit -m one &&
+
+  echo two >> content &&
+  bzr commit -m two
+  ) &&
+
+  git clone "bzr::$PWD/bzrrepo" gitrepo &&
+
+  (
+  cd bzrrepo &&
+  bzr uncommit --force &&
+
+  echo three >> content &&
+  bzr commit -m three &&
+
+  echo four >> content &&
+  bzr commit -m four &&
+  bzr log --line | sed -e "s/^[0-9]\+: //" > ../expected
+  ) &&
+
+  (cd gitrepo &&
+  git fetch &&
+  git log --format="%an %ad %s" --date=short origin/master > ../actual) &&
+
+  test_cmp actual expected
+'
+
 test_done
-- 
1.8.3.rc1.553.gac13664

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] remote-bzr: fix for disappeared revisions
  2013-05-07 23:39 [PATCH] remote-bzr: fix for disappeared revisions Felipe Contreras
@ 2013-05-07 23:42 ` Felipe Contreras
  2013-05-08  5:16   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Felipe Contreras @ 2013-05-07 23:42 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

On Tue, May 7, 2013 at 6:39 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:

> +  (cd gitrepo &&
> +  git fetch &&
> +  git log --format="%an %ad %s" --date=short origin/master > ../actual) &&
> +
> +  test_cmp actual expected

Hmm:

test_cmp expected actual

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] remote-bzr: fix for disappeared revisions
  2013-05-07 23:42 ` Felipe Contreras
@ 2013-05-08  5:16   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-05-08  5:16 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git

Felipe Contreras <felipe.contreras@gmail.com> writes:

> On Tue, May 7, 2013 at 6:39 PM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>
>> +  (cd gitrepo &&
>> +  git fetch &&
>> +  git log --format="%an %ad %s" --date=short origin/master > ../actual) &&
>> +
>> +  test_cmp actual expected
>
> Hmm:
>
> test_cmp expected actual

Yeah, right.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-08  5:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-07 23:39 [PATCH] remote-bzr: fix for disappeared revisions Felipe Contreras
2013-05-07 23:42 ` Felipe Contreras
2013-05-08  5:16   ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.