Patchwork [4,of,6,V2] context: add workingcommitctx for exact context to be committed

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Dec. 31, 2014, 8:58 a.m.
Message ID <61c95f20082157684270.1420016289@feefifofum>
Download mbox | patch
Permalink /patch/7279/
State Accepted
Commit 745e3b48563247f040943d8acff654df21736c53
Headers show

Comments

Katsunori FUJIWARA - Dec. 31, 2014, 8:58 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1420016143 -32400
#      Wed Dec 31 17:55:43 2014 +0900
# Node ID 61c95f20082157684270ad05f52f0890e3c4f544
# Parent  a16fd7cabd7e8934c45a83f4dd81d820c7217816
context: add workingcommitctx for exact context to be committed

Before this patch, "workingctx" is also used for the context to be
committed. But "workingctx" works incorrectly in some cases.

For example, even when only some of changed files in the working
directory are committed, "status()" on "workingctx" object for
committing recognizes files not to be committed as changed, too.

As the preparation for fixing these issues, this patch chooses adding
new class "workingcommitctx" for exact context to be committed,
because switching by the flag (like "self._fixedstatus" or so) in some
code paths of "workingctx" is less readable and maintenancable.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1557,6 +1557,18 @@ 
         """wraps repo.wwrite"""
         self._repo.wwrite(self._path, data, flags)
 
+class workingcommitctx(workingctx):
+    """A workingcommitctx object makes access to data related to
+    the revision being committed convenient.
+
+    This hides changes in the working directory, if they aren't
+    committed in this context.
+    """
+    def __init__(self, repo, changes,
+                 text="", user=None, date=None, extra=None):
+        super(workingctx, self).__init__(repo, text, user, date, extra,
+                                         changes)
+
 class memctx(committablectx):
     """Use memctx to perform in-memory commits via localrepo.commitctx().
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1343,7 +1343,8 @@ 
                     elif f not in self.dirstate:
                         fail(f, _("file not tracked!"))
 
-            cctx = context.workingctx(self, text, user, date, extra, status)
+            cctx = context.workingcommitctx(self, status,
+                                            text, user, date, extra)
 
             if (not force and not extra.get("close") and not merge
                 and not cctx.files()