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

David Schleimer dschleimer at fb.com
Sun Feb 10 17:30:01 CST 2013


# HG changeset patch
# User David Schleimer <dschleimer at fb.com>
# 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
use.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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())


More information about the Mercurial-devel mailing list