Patchwork [12,of,12] localrepo: replace status method with a shim

login
register
mail settings
Submitter Sean Farley
Date May 19, 2014, 8:32 p.m.
Message ID <9346b559bf49fd0295a5.1400531539@laptop.local>
Download mbox | patch
Permalink /patch/4814/
State Accepted
Commit 83bbfb23cb24b473286d528ddccbb333329f7f29
Headers show

Comments

Sean Farley - May 19, 2014, 8:32 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1398458695 18000
#      Fri Apr 25 15:44:55 2014 -0500
# Node ID 9346b559bf49fd0295a5ab7aa37e2632d0d21583
# Parent  72fef2b3276cbf1e392ac0f43355fb0437d78f9d
localrepo: replace status method with a shim

This commit can only really be described with a quote from Pulp Fiction:

The path of the righteous man is beset on all sides by the inequities of the
selfish and the tyranny of evil men. Blessed is he, who in the name of charity
and good will, shepherds the weak through the valley of darkness, for he is
truly Mercurial's keeper and the finder of robust methods. And I will strike
down upon thee with great vengeance and furious anger those who would attempt
to poison and destroy Mercurial's codebase. And you will know my name is the
Lord when I lay my vengeance upon thee.

https://www.youtube.com/watch?v=pRE23YfSvc8
Pierre-Yves David - May 20, 2014, 12:16 a.m.
On 05/19/2014 01:32 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1398458695 18000
> #      Fri Apr 25 15:44:55 2014 -0500
> # Node ID 9346b559bf49fd0295a5ab7aa37e2632d0d21583
> # Parent  72fef2b3276cbf1e392ac0f43355fb0437d78f9d
> localrepo: replace status method with a shim

This series looks overall goods to me. I'll test it when matt is done 
reviewing clowncopter.

I would just drop the second paragraph of this changeset description 
(the one line long one)
Christian Ebert - May 20, 2014, 4:36 p.m.
* Pierre-Yves David on Monday, May 19, 2014 at 17:16:24 -0700
> On 05/19/2014 01:32 PM, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1398458695 18000
>> #      Fri Apr 25 15:44:55 2014 -0500
>> # Node ID 9346b559bf49fd0295a5ab7aa37e2632d0d21583
>> # Parent  72fef2b3276cbf1e392ac0f43355fb0437d78f9d
>> localrepo: replace status method with a shim
> 
> This series looks overall goods to me. I'll test it when matt is done
> reviewing clowncopter.
> 
> I would just drop the second paragraph of this changeset description
> (the one line long one)

Hm, I can't spot an overlong line in the second paragraph of this
changeset description. But I thoroughly enjoyed what they call a
Royale with cheese.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1502,72 +1502,13 @@  class localrepository(object):
         return self[node].walk(match)
 
     def status(self, node1='.', node2=None, match=None,
                ignored=False, clean=False, unknown=False,
                listsubrepos=False):
-        """return status of files between two nodes or node and working
-        directory.
-
-        If node1 is None, use the first dirstate parent instead.
-        If node2 is None, compare node1 with working directory.
-        """
-
-        ctx1 = self[node1]
-        ctx2 = self[node2]
-
-        # This next code block is, admittedly, fragile logic that tests for
-        # reversing the contexts and wouldn't need to exist if it weren't for
-        # the fast (and common) code path of comparing the working directory
-        # with its first parent.
-        #
-        # What we're aiming for here is the ability to call:
-        #
-        # workingctx.status(parentctx)
-        #
-        # If we always built the manifest for each context and compared those,
-        # then we'd be done. But the special case of the above call means we
-        # just copy the manifest of the parent.
-        reversed = False
-        if (not isinstance(ctx1, context.changectx)
-            and isinstance(ctx2, context.changectx)):
-            reversed = True
-            ctx1, ctx2 = ctx2, ctx1
-
-        listignored, listclean, listunknown = ignored, clean, unknown
-
-        r = [[], [], [], [], [], [], []]
-        match = ctx2._matchstatus(ctx1, r, match, listignored, listclean,
-                                  listunknown)
-        r = ctx2._prestatus(ctx1, r, match, listignored, listclean, listunknown)
-        r = ctx2._generatestatus(ctx1, r, match, listignored, listclean,
-                                 listunknown)
-        r = ctx2._poststatus(ctx1, r, match, listignored, listclean,
-                             listunknown)
-
-        if reversed:
-            # since we are maintaining whether we reversed ctx1 and ctx2 (due
-            # to comparing the workingctx with its parent), we need to switch
-            # back added files (r[1]) and removed files (r[2])
-            r[1], r[2] = r[2], r[1]
-
-        if listsubrepos:
-            for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
-                rev2 = ctx2.subrev(subpath)
-                try:
-                    submatch = matchmod.narrowmatcher(subpath, match)
-                    s = sub.status(rev2, match=submatch, ignored=listignored,
-                                   clean=listclean, unknown=listunknown,
-                                   listsubrepos=True)
-                    for rfiles, sfiles in zip(r, s):
-                        rfiles.extend("%s/%s" % (subpath, f) for f in sfiles)
-                except error.LookupError:
-                    self.ui.status(_("skipping missing subrepository: %s\n")
-                                   % subpath)
-
-        for l in r:
-            l.sort()
-        return r
+        '''a convenience method that calls node1.status(node2)'''
+        return self[node1].status(node2, match, ignored, clean, unknown,
+                                  listsubrepos)
 
     def heads(self, start=None):
         heads = self.changelog.heads(start)
         # sort the output in rev descending order
         return sorted(heads, key=self.changelog.rev, reverse=True)