Patchwork [11,of,19] localrepo: use setters instead of constructor for commit metadata

mail settings
Submitter David Schleimer
Date Feb. 10, 2013, 11:30 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/960/
State Changes Requested
Headers show


David Schleimer - Feb. 10, 2013, 11:30 p.m.
# HG changeset patch
# User David Schleimer <>
# Date 1360330572 28800
# Node ID 272e90e44133f13219edd88cf9d3ecbb87886563
# Parent  b26b1130ee3a34fe74a6302a3b08bbfd446c975b
localrepo: use setters instead of constructor for commit metadata

Instead of including the commit metadata in the constructor for the
context actually used for commit, we later use setters to update the
context with that metadata.  This will allow us to use the commitable
context for another sanity checks, and will make it easier to split
the logic in localrepo.commit() into multiple functions.

This is part of a larger refactoring effort to make memctx easier to


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -1200,7 +1200,7 @@ 
                     elif f not in self.dirstate:
                         fail(f, _("file not tracked!"))
-            cctx = context.workingctx(self, text, user, date, extra, changes)
+            cctx = context.workingctx(self, changes=changes)
             if (not force and not extra.get("close") and not merge
                 and not cctx.files()
@@ -1214,6 +1214,11 @@ 
                 raise util.Abort(_("unresolved merge conflicts "
                                    "(see hg help resolve)"))
+            cctx.setuser(user)
+            cctx.setdate(date)
+            cctx.setextra(extra)
+            cctx.setdescription(text)
             if editor:
                 cctx.setdescription(editor(self, cctx, subs))
             edited = (text != cctx.description())