Patchwork tagmerge: use workingfilectx to write merged tags

login
register
mail settings
Submitter Phillip Cohen
Date July 11, 2017, 11:49 p.m.
Message ID <9ed38e65a34d2a4660fe.1499816966@phillco-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/22241/
State Accepted
Headers show

Comments

Phillip Cohen - July 11, 2017, 11:49 p.m.
# HG changeset patch
# User Phil Cohen <phillco@fb.com>
# Date 1499816895 25200
#      Tue Jul 11 16:48:15 2017 -0700
# Node ID 9ed38e65a34d2a4660fe17b6e5d6cb2ec4d949c1
# Parent  062c1bde178118b7c4d5abb1ead16ac8ad494280
tagmerge: use workingfilectx to write merged tags

This function already does an excellent job of reading from context objects;
we simply need to change the single write call to eliminate all uses of the
wvfs.

As with past changes, the effect should be a no-op but opens the door to
in-memory merge later by using different context objects.
Yuya Nishihara - July 14, 2017, 12:57 p.m.
On Tue, 11 Jul 2017 16:49:26 -0700, Phil Cohen wrote:
> # HG changeset patch
> # User Phil Cohen <phillco@fb.com>
> # Date 1499816895 25200
> #      Tue Jul 11 16:48:15 2017 -0700
> # Node ID 9ed38e65a34d2a4660fe17b6e5d6cb2ec4d949c1
> # Parent  062c1bde178118b7c4d5abb1ead16ac8ad494280
> tagmerge: use workingfilectx to write merged tags

Looks good. Queued, thanks.

Patch

diff --git a/mercurial/tagmerge.py b/mercurial/tagmerge.py
--- a/mercurial/tagmerge.py
+++ b/mercurial/tagmerge.py
@@ -136,7 +136,7 @@ 
             prevlinenum = linenum
     return groupednodes
 
-def writemergedtags(repo, mergedtags):
+def writemergedtags(fcd, mergedtags):
     '''
     write the merged tags while trying to minimize the diff to the first parent
 
@@ -169,9 +169,7 @@ 
     # finally we can join the sorted groups to get the final contents of the
     # merged .hgtags file, and then write it to disk
     mergedtagstring = '\n'.join([tags for rank, tags in finaltags if tags])
-    fp = repo.wvfs('.hgtags', 'wb')
-    fp.write(mergedtagstring + '\n')
-    fp.close()
+    fcd.write(mergedtagstring + '\n', fcd.flags())
 
 def singletagmerge(p1nodes, p2nodes):
     '''
@@ -268,7 +266,7 @@ 
             % (numconflicts, ', '.join(sorted(conflictedtags))))
         return True, 1
 
-    writemergedtags(repo, mergedtags)
+    writemergedtags(fcd, mergedtags)
     ui.note(_('.hgtags merged successfully\n'))
     return False, 0