From patchwork Sun Feb 10 23:30:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [11, of, 19] localrepo: use setters instead of constructor for commit metadata From: David Schleimer X-Patchwork-Id: 960 Message-Id: <272e90e44133f13219ed.1360539001@dev010.prn1.facebook.com> To: mercurial-devel@selenic.com Date: Sun, 10 Feb 2013 15:30:01 -0800 # 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 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())