hgk: don't break on repositories with obsolete changesets
authorAndrew Shadura <andrew@shadura.me>
Sun, 28 Sep 2014 15:21:29 +0200
changeset 22580 271a1ddad1fb
parent 22579 36a940d82f88
child 22581 c5ece02fb211
hgk: don't break on repositories with obsolete changesets Check the existence of a changeset before adding it to the list returned by debug-rev-list command.
hgext/hgk.py
--- a/hgext/hgk.py	Thu Sep 18 11:43:47 2014 -0700
+++ b/hgext/hgk.py	Sun Sep 28 15:21:29 2014 +0200
@@ -204,10 +204,12 @@
                     l[chunk - x:] = [0] * (chunk - x)
                     break
                 if full is not None:
-                    l[x] = repo[i + x]
-                    l[x].changeset() # force reading
+                    if (i + x) in repo:
+                        l[x] = repo[i + x]
+                        l[x].changeset() # force reading
                 else:
-                    l[x] = 1
+                    if (i + x) in repo:
+                        l[x] = 1
             for x in xrange(chunk - 1, -1, -1):
                 if l[x] != 0:
                     yield (i + x, full is not None and l[x] or None)
@@ -259,6 +261,8 @@
     # walk the repository looking for commits that are in our
     # reachability graph
     for i, ctx in chlogwalk():
+        if i not in repo:
+            continue
         n = repo.changelog.node(i)
         mask = is_reachable(want_sha1, reachable, n)
         if mask: