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

Yuya Nishihara yuya at tcha.org
Thu Mar 1 19:26:21 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at 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

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:


More information about the Mercurial-devel mailing list