Patchwork [3,of,5] export: remove useless comparison between file object and string

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 17, 2015, 2:09 p.m.
Message ID <14d8c7b6d03751e3fa78.1450361363@mimosa>
Download mbox | patch
Permalink /patch/12098/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 17, 2015, 2:09 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1450004274 -32400
#      Sun Dec 13 19:57:54 2015 +0900
# Node ID 14d8c7b6d03751e3fa7899c3d45785e40bbf399b
# Parent  f96392009681a7702d6949884415b3c44c365952
export: remove useless comparison between file object and string

It was introduced at 31aa2e5b0750, where "template" argument could be a file
object. After that, a306837f8c87 added "len(template)", so "template" must be
a string now. Therefore, "fp != template" should always be True.

It seems 31aa2e5b0750 was intended to work around a bug in TortoiseHg, and
I'm sure I've fixed it completely in TortoiseHg source.

https://selenic.com/pipermail/mercurial-devel/2011-February/028467.html

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1053,8 +1053,7 @@  def export(repo, revs, template='hg-%h.p
             fp = makefileobj(repo, template, node, desc=desc, total=total,
                              seqno=seqno, revwidth=revwidth, mode='wb',
                              modemap=filemode)
-            if fp != template:
-                shouldclose = True
+            shouldclose = True
         if fp and not getattr(fp, 'name', '<unnamed>').startswith('<'):
             repo.ui.note("%s\n" % fp.name)