]> Kevux Git Server - rit/commitdiff
remote-hg: trivial cleanup
authorFelipe Contreras <felipe.contreras@gmail.com>
Sat, 25 May 2013 02:30:01 +0000 (21:30 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 May 2013 15:02:24 +0000 (08:02 -0700)
It's better to catch the exception later on.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/remote-helpers/git-remote-hg

index 1e61f43..b08f909 100755 (executable)
@@ -185,10 +185,7 @@ class Marks:
         return rev in self.marks
 
     def get_tip(self, branch):
-        try:
-            return str(self.tips[branch])
-        except KeyError:
-            return None
+        return str(self.tips[branch])
 
     def set_tip(self, branch, tip):
         self.tips[branch] = tip
@@ -433,10 +430,10 @@ def export_ref(repo, name, kind, head):
     global prefix, marks, mode
 
     ename = '%s/%s' % (kind, name)
-    tip = marks.get_tip(ename)
-    if tip and tip in repo:
+    try:
+        tip = marks.get_tip(ename)
         tip = repo[tip].rev()
-    else:
+    except:
         tip = 0
 
     revs = xrange(tip, head.rev() + 1)