Patchwork [02,of,10] py3: use startswith() to check existence of trailing '\n' in .hgtags file

login
register
mail settings
Submitter Yuya Nishihara
Date March 2, 2018, 12:26 a.m.
Message ID <d44f1bec9f60ebec416b.1519950381@mimosa>
Download mbox | patch
Permalink /patch/28626/
State Accepted
Headers show

Comments

Yuya Nishihara - March 2, 2018, 12:26 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1519939965 18000
#      Thu Mar 01 16:32:45 2018 -0500
# Node ID d44f1bec9f60ebec416be5a7cd44aa386e04da64
# Parent  8d4520c4501899f53310e536e6bfd174cc58493a
py3: use startswith() to check existence of trailing '\n' in .hgtags file

Patch

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -559,7 +559,7 @@  def _tag(repo, names, node, message, loc
 
     def writetags(fp, names, munge, prevtags):
         fp.seek(0, 2)
-        if prevtags and prevtags[-1] != '\n':
+        if prevtags and not prevtags.endswith('\n'):
             fp.write('\n')
         for name in names:
             if munge: