All of lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Lamb <slamb@slamb.org>
To: git@vger.kernel.org, Junio C Hamano <junkio@cox.net>
Cc: Scott Lamb <slamb@slamb.org>
Subject: [PATCH 3/4] git-p4import: resume on correct p4 changeset
Date: Sat,  2 Jun 2007 20:58:45 -0700	[thread overview]
Message-ID: <11808431364066-git-send-email-slamb@slamb.org> (raw)
In-Reply-To: <11808431291938-git-send-email-slamb@slamb.org>

This had been resuming on change 222 rather than 22283.

top_change's removal of the last two characters must have predated the use
of rstrip() in get_single(). A regexp should be less fragile, or at least
more obvious when it breaks.

Signed-off-by: Scott Lamb <slamb@slamb.org>
---
 git-p4import.py |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/git-p4import.py b/git-p4import.py
index 54e5e9e..e7a52b3 100644
--- a/git-p4import.py
+++ b/git-p4import.py
@@ -237,15 +237,16 @@ class git_command:
     def make_tag(self, name, head):
         self.git(["tag", "-f", name, head])
 
+    _tag_re = re.compile(r'tags/p4/(\d+)')
     def top_change(self, branch):
         try:
             a=self.get_single(["name-rev", "--tags", "refs/heads/%s" % branch])
-            loc = a.find(' tags/') + 6
-            if a[loc:loc+3] != "p4/":
-                raise
-            return int(a[loc+3:][:-2])
-        except:
-            return 0
+        except GitException, e:
+            return 0 # fresh repository
+        m = self._tag_re.search(a)
+        if m is None:
+            raise Exception('unable to parse: %r' % (a,))
+        return int(m.group(1))
 
     def update_index(self):
         files = self.git("ls-files -m -d -o -z".split(" "))
-- 
1.5.2

  reply	other threads:[~2007-06-03  3:59 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-31 16:47 git-p4import.py robustness changes Scott Lamb
2007-05-31 23:53 ` Junio C Hamano
2007-06-02 20:41   ` Scott Lamb
2007-06-02 21:33     ` Junio C Hamano
2007-06-02 23:21       ` Scott Lamb
2007-06-02 23:52         ` Junio C Hamano
2007-06-03 13:11       ` Simon Hausmann
2007-06-03 20:12         ` Scott Lamb
2007-06-04  5:54           ` Shawn O. Pearce
2007-06-04  6:09             ` Dana How
2007-06-04  6:18               ` Shawn O. Pearce
2007-06-04  7:19             ` Scott Lamb
2007-06-05  7:21               ` Simon Hausmann
2007-06-04  8:41           ` Marius Storm-Olsen
2007-06-04  5:56         ` Shawn O. Pearce
2007-06-12 21:46           ` Simon Hausmann
2007-06-13 21:06             ` Scott Lamb
2007-06-13 22:34               ` Simon Hausmann
2007-06-14  5:35             ` Shawn O. Pearce
2007-06-14 21:44               ` Simon Hausmann
2007-06-15  3:13                 ` Shawn O. Pearce
2007-06-15  5:30                 ` Marius Storm-Olsen, mstormo_git
2007-06-03  3:58 ` [PATCH 1/4] git-p4import: fix subcommand error handling Scott Lamb
2007-06-03  3:58   ` [PATCH 2/4] git-p4import: use lists of subcommand arguments Scott Lamb
2007-06-03  3:58     ` Scott Lamb [this message]
2007-06-03  3:58       ` [PATCH 4/4] git-p4import: partial history Scott Lamb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11808431364066-git-send-email-slamb@slamb.org \
    --to=slamb@slamb.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.