1. masklinn
  2. sphinx-patchqueue


masklinn  committed 603d407

Fix #10 correctly handle dependencies on queues & patches

* each series file should be a dependency of the document
* each *used* patch of the series should be a dependency of the document
* generated literalinclude-d files however should not be dependencies of the
doc: they're generated from patches & they're removed after build, so they
mark the document as changed every time

Comments (0)

Files changed (1)

File patchqueue.py Modified

View file
  • Ignore whitespace
  • Hide word diff
         if self.index >= len(self.patches):
             raise StopIteration
-        patch = self.patches[self.index]
-        with open(os.path.join(self.path, patch), 'rb') as fp:
+        patch = os.path.join(self.path, self.patches[self.index])
+        self.ui.app.env.note_dependency(patch)
+        with open(patch, 'rb') as fp:
             patchbackend = mercurial.patch.fsbackend(self.ui, self.directory)
             res = mercurial.patch.applydiff(
                 self.ui, fp,
         relpath, series_file = env.relfn2path(self.arguments[0])
         patches_dir = os.path.dirname(series_file)
+        env.note_dependency(series_file)
         with open(series_file, 'rb') as f:
             series = env.temp_data[SERIES_KEY] = Series(
                 env.app, patches_dir, [line.strip() for line in f])
                     '', *self.run_content(relative_path, lang=lang),
+            undepend(env, relative_path)
         return [patch_root]
+def undepend(env, relpath):
+    """ LiteralInclude adds the provided file as a dependency to the
+    document. This usually makes sense, but in our case the dependency is
+    generated (from patch files which are the real dependencies) and the
+    LiteralIncluded file is changed by each patch and nuked after the document
+    is built.
+    Thus remove it from the dependency set.
+    """
+    env.dependencies[env.docname].discard(relpath)