Patchwork D1617: rebase: extract _assignworkingcopy

login
register
mail settings
Submitter phabricator
Date Dec. 8, 2017, 7:26 a.m.
Message ID <differential-rev-PHID-DREV-23y4ojhwcjxw2x2a3z2l-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26080/
State Superseded
Headers show

Comments

phabricator - Dec. 8, 2017, 7:26 a.m.
phillco created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Slightly cleaner, and makes it easier to hook this in an extension.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1617

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS




To: phillco, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 9, 2017, 4:42 a.m.
krbullock added inline comments.

INLINE COMMENTS

> rebase.py:393
> +    def _performrebase(self, tr):
> +        self._assignworkingcopy()
> +        repo, ui = self.repo, self.ui

Rather than having this method spookily set self.wctx, why not make `_assignworkingcopy` _return_ the wctx (and rename it accordingly)?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1617

To: phillco, #hg-reviewers, dlax
Cc: krbullock, mercurial-devel
phabricator - Dec. 11, 2017, 6:32 a.m.
phillco added inline comments.

INLINE COMMENTS

> krbullock wrote in rebase.py:393
> Rather than having this method spookily set self.wctx, why not make `_assignworkingcopy` _return_ the wctx (and rename it accordingly)?

Good point, I'll send a followup.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1617

To: phillco, #hg-reviewers, dlax
Cc: krbullock, mercurial-devel

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -381,14 +381,16 @@ 
 
         self.prepared = True
 
-    def _performrebase(self, tr):
-        repo, ui = self.repo, self.ui
-        # Assign a working copy object.
+    def _assignworkingcopy(self):
         if self.inmemory:
             from mercurial.context import overlayworkingctx
             self.wctx = overlayworkingctx(self.repo)
         else:
             self.wctx = self.repo[None]
+
+    def _performrebase(self, tr):
+        self._assignworkingcopy()
+        repo, ui = self.repo, self.ui
         if self.keepbranchesf:
             # insert _savebranch at the start of extrafns so if
             # there's a user-provided extrafn it can clobber branch if