Patchwork [1,of,5,STABLE] merge: move merge state file path into a constant

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 26, 2014, 10:58 p.m.
Message ID <a0c9e2941511a01624a0.1393455483@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3775/
State Superseded
Commit 4c4cd64c754b4bad3876423ec11c2ccb0a74ba1d
Headers show

Comments

Pierre-Yves David - Feb. 26, 2014, 10:58 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1393377289 28800
#      Tue Feb 25 17:14:49 2014 -0800
# Branch stable
# Node ID a0c9e2941511a01624a0a75c000190f4ce3ed467
# Parent  35ac807f941c514470de2c2708a5886f8b61f089
merge: move merge state file path into a constant

We are about to change the format. Having the file path in a single place make
it easier to update the filename for the new version.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -11,10 +11,12 @@  from mercurial import obsolete
 import error, util, filemerge, copies, subrepo, worker, dicthelpers
 import errno, os, shutil
 
 class mergestate(object):
     '''track 3-way merge state of individual files'''
+    statepath = "merge/state"
+
     def __init__(self, repo):
         self._repo = repo
         self._dirty = False
         self._read()
     def reset(self, node=None):
@@ -24,11 +26,11 @@  class mergestate(object):
         shutil.rmtree(self._repo.join("merge"), True)
         self._dirty = False
     def _read(self):
         self._state = {}
         try:
-            f = self._repo.opener("merge/state")
+            f = self._repo.opener(self.statepath)
             for i, l in enumerate(f):
                 if i == 0:
                     self._local = bin(l[:-1])
                 else:
                     bits = l[:-1].split("\0")
@@ -38,11 +40,11 @@  class mergestate(object):
             if err.errno != errno.ENOENT:
                 raise
         self._dirty = False
     def commit(self):
         if self._dirty:
-            f = self._repo.opener("merge/state", "w")
+            f = self._repo.opener(self.statepath, "w")
             f.write(hex(self._local) + "\n")
             for d, v in self._state.iteritems():
                 f.write("\0".join([d] + v) + "\n")
             f.close()
             self._dirty = False