[PATCH] tagmerge: use workingfilectx to write merged tags

Phil Cohen phillco at fb.com
Tue Jul 11 23:49:26 UTC 2017


# HG changeset patch
# User Phil Cohen <phillco at 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.

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
 


More information about the Mercurial-devel mailing list