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

login
register
mail settings
Submitter David Schleimer
Date Feb. 10, 2013, 11:29 p.m.
Message ID <56ec15753a5264b0713b.1360538995@dev010.prn1.facebook.com>
Download mbox | patch
Permalink /patch/949/
State Changes Requested
Headers show

Comments

David Schleimer - Feb. 10, 2013, 11:29 p.m.
# HG changeset patch
# User David Schleimer <dschleimer@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.
Pierre-Yves David - Feb. 12, 2013, 2:10 p.m.
On Sun, Feb 10, 2013 at 03:29:55PM -0800, David Schleimer wrote:
> # HG changeset patch
> # User David Schleimer <dschleimer@fb.com>
> # Date 1360330569 28800
> # Node ID 56ec15753a5264b0713bf5cafa484f342d1803c7
> # Parent  f5a6e68310f238e490c6157cf2e4c9725baa1691
> localrepo: update commit to use setter and getter for description

1) The setdescription name is really ugly. I do not have good non ugly alternative in mind yet

This changes (and later related one) can be used in amend and histedit (at
least). Consider updating them too.
That would give you an easy way to validated your new method o:-)
Bryan O'Sullivan - Feb. 12, 2013, 5:58 p.m.
On Tue, Feb 12, 2013 at 6:10 AM, Pierre-Yves David <
pierre-yves.david@logilab.fr> wrote:

> 1) The setdescription name is really ugly. I do not have good non ugly
> alternative in mind yet
>

I think the name is fine. That said, setdesc would also be fine.
Matt Mackall - Feb. 13, 2013, 5:03 a.m.
On Tue, 2013-02-12 at 09:58 -0800, Bryan O'Sullivan wrote:
> On Tue, Feb 12, 2013 at 6:10 AM, Pierre-Yves David <
> pierre-yves.david@logilab.fr> wrote:
> 
> > 1) The setdescription name is really ugly. I do not have good non ugly
> > alternative in mind yet
> >
> 
> I think the name is fine. That said, setdesc would also be fine.

The existing get method is description(), so setdesc is out. This is
fine.

Patch

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 '')