changeset 767:da9f47555926

git_handler.load_map: use None as the uninitialized condition If there are no elements in the map, we would have tried loading it over and over again. With this, we only try loading it once.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 03 Sep 2014 20:29:01 +0200
parents 389676318d4c
children 86efc570f41d
files hggit/git_handler.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -110,19 +110,19 @@
 
         self.branch_bookmark_suffix = ui.config('git', 'branch_bookmark_suffix')
 
-        self._map_git_real = {}
-        self._map_hg_real = {}
+        self._map_git_real = None
+        self._map_hg_real = None
         self.load_tags()
 
     @property
     def _map_git(self):
-      if not self._map_git_real:
+      if self._map_git_real is None:
         self.load_map()
       return self._map_git_real
 
     @property
     def _map_hg(self):
-      if not self._map_hg_real:
+      if self._map_hg_real is None:
         self.load_map()
       return self._map_hg_real
 
@@ -159,8 +159,10 @@
         return self._map_hg.get(hgsha)
 
     def load_map(self):
-        if os.path.exists(self.repo.join(self.mapfile)):
-            for line in self.repo.opener(self.mapfile):
+        self._map_git_real = {}
+        self._map_hg_real = {}
+        if os.path.exists(self.repo.join(self.map_file)):
+            for line in self.repo.opener(self.map_file):
                 gitsha, hgsha = line.strip().split(' ', 1)
                 self._map_git_real[gitsha] = hgsha
                 self._map_hg_real[hgsha] = gitsha