smartlog: use dbm implementation, available on the system

Summary:
`gdbm` is unavailable on Windows. Python provides module called `anydbm` which
abstracts the implementation of `dbm` and is even capable of using a dump
Python-only implementation if nothing is installed.

Test Plan: - rt

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D5154620
This commit is contained in:
Kostia Balytskyi 2017-05-31 04:11:53 -07:00
parent 355573a423
commit 44cd7a5717

View File

@ -26,7 +26,7 @@ to the user.
from __future__ import absolute_import
import contextlib
import gdbm
import anydbm
from itertools import chain
import re
@ -67,8 +67,8 @@ logopts = [opt for opt in commands.logopts if opt[1] != "limit"]
def ancestorcache(path):
# simple cache to speed up revlog.ancestors
try:
db = gdbm.open(path, 'c')
except gdbm.error:
db = anydbm.open(path, 'c')
except anydbm.error:
# database locked, fail gracefully
yield
else: