changeset 27167:3fe8cb40c9c5

commands: inline definition of localrepo.parents() and drop the method (API) localrepo.parents() has relatively few users, and most of those were actually implicitly looking at the wctx, which is now made explicit via repo[None].
author Augie Fackler <augie@google.com>
date Wed, 11 Nov 2015 20:07:15 -0500
parents 263db31329a6
children 8a829fc84bb3
files hgext/rebase.py mercurial/commands.py mercurial/localrepo.py
diffstat 3 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Wed Nov 11 20:02:05 2015 -0500
+++ b/hgext/rebase.py	Wed Nov 11 20:07:15 2015 -0500
@@ -441,7 +441,7 @@
                                              targetancestors)
                 storestatus(repo, originalwd, target, state, collapsef, keepf,
                             keepbranchesf, external, activebookmark)
-                if len(repo.parents()) == 2:
+                if len(repo[None].parents()) == 2:
                     repo.ui.debug('resuming interrupted rebase\n')
                 else:
                     try:
@@ -930,7 +930,7 @@
 def needupdate(repo, state):
     '''check whether we should `update --clean` away from a merge, or if
     somehow the working dir got forcibly updated, e.g. by older hg'''
-    parents = [p.rev() for p in repo.parents()]
+    parents = [p.rev() for p in repo[None].parents()]
 
     # Are we in a merge state at all?
     if len(parents) < 2:
--- a/mercurial/commands.py	Wed Nov 11 20:02:05 2015 -0500
+++ b/mercurial/commands.py	Wed Nov 11 20:07:15 2015 -0500
@@ -1190,7 +1190,7 @@
             ui.status(_('reset working directory to branch %s\n') % label)
         elif label:
             if not opts.get('force') and label in repo.branchmap():
-                if label not in [p.branch() for p in repo.parents()]:
+                if label not in [p.branch() for p in repo[None].parents()]:
                     raise error.Abort(_('a branch of the same name already'
                                        ' exists'),
                                      # i18n: "it" refers to an existing branch
@@ -1600,8 +1600,8 @@
         if not bheads:
             raise error.Abort(_('can only close branch heads'))
         elif opts.get('amend'):
-            if repo.parents()[0].p1().branch() != branch and \
-                    repo.parents()[0].p2().branch() != branch:
+            if repo[None].parents()[0].p1().branch() != branch and \
+                    repo[None].parents()[0].p2().branch() != branch:
                 raise error.Abort(_('can only close branch heads'))
 
     if opts.get('amend'):
@@ -4545,7 +4545,7 @@
                 tr = repo.transaction('import')
             else:
                 dsguard = cmdutil.dirstateguard(repo, 'import')
-            parents = repo.parents()
+            parents = repo[None].parents()
             for patchurl in patches:
                 if patchurl == '-':
                     ui.status(_('applying patch from stdin\n'))
@@ -4565,7 +4565,7 @@
                         haspatch = True
                         ui.note(msg + '\n')
                     if update or opts.get('exact'):
-                        parents = repo.parents()
+                        parents = repo[None].parents()
                     else:
                         parents = [repo[node]]
                     if rej:
--- a/mercurial/localrepo.py	Wed Nov 11 20:02:05 2015 -0500
+++ b/mercurial/localrepo.py	Wed Nov 11 20:07:15 2015 -0500
@@ -852,10 +852,6 @@
     def changectx(self, changeid):
         return self[changeid]
 
-    def parents(self, changeid=None):
-        '''get list of changectxs for parents of changeid'''
-        return self[changeid].parents()
-
     def setparents(self, p1, p2=nullid):
         self.dirstate.beginparentchange()
         copies = self.dirstate.setparents(p1, p2)
@@ -1170,7 +1166,7 @@
                         % self.dirstate.branch())
 
             self.dirstate.invalidate()
-            parents = tuple([p.rev() for p in self.parents()])
+            parents = tuple([p.rev() for p in self[None].parents()])
             if len(parents) > 1:
                 ui.status(_('working directory now based on '
                             'revisions %d and %d\n') % parents)