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

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Wed Feb 26 16:58:03 CST 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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


More information about the Mercurial-devel mailing list