Commits

Anonymous committed 671b9b3

Open proper revision of file from repository

  • Participants
  • Parent commits 4e1435b

Comments (0)

Files changed (1)

File slipper/script.py

     # Get the configuration for that section.
     hg_repos = cp.get(section, 'hg_repos')
     hgweb_url = cp.get(section, 'hgweb_url')
-    cache = cp.get(section, 'cache')
+    cache = cp.get('global', 'cache')
     # Get the text of requested file/revision from repository.
+    # First open the repository and get the log of the requested file.
     repo = localrepository(None, hg_repos)
-    filelog = repo.file(file_path)
-    if filelog.count() == 0:
-        raise ValueError('%s Not found in repository.' % file_path)
-    source_text = filelog.read(filelog.tip())
+    ctx = repo.changectx(revision)
+    filectx = ctx[file_path]
+    source_text = filectx.data()
     # Add a link to the source text.
     source_text += dedent("""\
         
-        .. admonition:: Link to source text
+        .. admonition:: Page source
 
-            Automatically generated from `<%s/file/%s/%s>`__.
+            `<%s/file/%s/%s>`__.
         """ % (hgweb_url, revision, file_path))
     hash = sha(source_text).hexdigest()
     # Look in cache first.