[PATCH 05 of 19] localrepo: update commit to use setter and getter for description

David Schleimer dschleimer at fb.com
Sun Feb 10 17:29:55 CST 2013


# HG changeset patch
# User David Schleimer <dschleimer at fb.com>
# Date 1360330569 28800
# Node ID 56ec15753a5264b0713bf5cafa484f342d1803c7
# Parent  f5a6e68310f238e490c6157cf2e4c9725baa1691
localrepo: update commit to use setter and getter for description

In addition to removing a reference to a private variable, this is a
step towards being able to update a context with all the metadata
needed to pass it to localrepo.commitctx.  This will eventually allow
merge to return context objects instead of statistics, which supports
some interesting optimizations.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -974,6 +974,8 @@
         return self._date
     def description(self):
         return self._text
+    def setdescription(self, text):
+        self._text = text
     def files(self):
         return sorted(self._status[0] + self._status[1] + self._status[2])
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1244,8 +1244,8 @@
                                    "(see hg help resolve)"))
 
             if editor:
-                cctx._text = editor(self, cctx, subs)
-            edited = (text != cctx._text)
+                cctx.setdescription(editor(self, cctx, subs))
+            edited = (text != cctx.description())
 
             # commit subs and write new state
             if subs:
@@ -1253,14 +1253,14 @@
                     sub = wctx.sub(s)
                     self.ui.status(_('committing subrepository %s\n') %
                         subrepo.subrelpath(sub))
-                    sr = sub.commit(cctx._text, user, date)
+                    sr = sub.commit(cctx.description(), user, date)
                     newstate[s] = (newstate[s][0], sr)
                 subrepo.writestate(self, newstate)
 
             # Save commit message in case this transaction gets rolled back
             # (e.g. by a pretxncommit hook).  Leave the content alone on
             # the assumption that the user will use the same editor again.
-            msgfn = self.savecommitmessage(cctx._text)
+            msgfn = self.savecommitmessage(cctx.description())
 
             p1, p2 = self.dirstate.parents()
             hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')


More information about the Mercurial-devel mailing list