[runtime] Avoid busy waiting when using the MONO_DEBUG=suspend-on-sigsegv option.
[mono.git] / scripts / commits-to-changelog.py
index 3de40bbe51ad1dc82fc584ae43f488955b348192..bec87d9e582305395e27b68a6fdc53176549dffa 100755 (executable)
@@ -52,6 +52,8 @@ def changelogs_for_file_pattern (pattern, changed_files):
 def format_paragraph (paragraph):
     lines = []
     words = paragraph.split ()
+    if len (words) == 0:
+        return lines
     current = words [0]
     for word in words [1:]:
         if len (current) + 1 + len (word) <= fill_column:
@@ -247,18 +249,24 @@ def main ():
         global path_to_root
         path_to_root = options.root + "/"
 
+    # MonkeyWrench uses a shared git repo but sets BUILD_REVISION,
+    # if present we use it instead of HEAD
+    HEAD = "HEAD"
+    if 'BUILD_REVISION' in os.environ:
+        HEAD = os.environ['BUILD_REVISION']
+
     #see if git supports %B in --format
-    output = git ("log", "-n1", "--format=%B", "HEAD")
+    output = git ("log", "-n1", "--format=%B", HEAD)
     if output.startswith ("%B"):
         print >> sys.stderr, "Error: git doesn't support %B in --format - install version 1.7.2 or newer"
         exit (1)
 
-    for filename in git ("ls-tree", "-r", "--name-only", "HEAD").splitlines ():
+    for filename in git ("ls-tree", "-r", "--name-only", HEAD).splitlines ():
         if re.search ("(^|/)Change[Ll]og$", filename):
             (path, name) = os.path.split (filename)
             all_changelogs [path] = name
 
-    commits = git ("rev-list", "--no-merges", "HEAD", "^%s" % start_commit).splitlines ()
+    commits = git ("rev-list", "--no-merges", HEAD, "^%s" % start_commit).splitlines ()
 
     touched_changelogs = {}
     for commit in commits:
@@ -266,6 +274,8 @@ def main ():
         if entries == None:
             continue
         for (changelog, lines) in entries.items ():
+            if not os.path.exists (changelog_path (changelog)):
+                continue
             if changelog not in touched_changelogs:
                 touched_changelogs [changelog] = start_changelog (changelog)
             append_lines (touched_changelogs [changelog], lines)