Patchwork [1,of,2] rebase: rename "target" to "dest" in variable names

login
register
mail settings
Submitter via Mercurial-devel
Date May 12, 2017, 5:13 p.m.
Message ID <274ef5ba4e1f09935f8d.1494609236@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/20586/
State Accepted
Headers show

Comments

via Mercurial-devel - May 12, 2017, 5:13 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1494567483 25200
#      Thu May 11 22:38:03 2017 -0700
# Node ID 274ef5ba4e1f09935f8db9afb5491b6974312edf
# Parent  3de4c61b50870668bbbe4da0a9a2cd5f7f42fbfe
rebase: rename "target" to "dest" in variable names

It took me a while to figure out that "target" was actually what's
passed to --dest.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -139,9 +139,9 @@ 
         self.state = {}
         self.activebookmark = None
         self.currentbookmarks = None
-        self.target = None
+        self.dest = None
         self.skipped = set()
-        self.targetancestors = set()
+        self.destancestors = set()
 
         self.collapsef = opts.get('collapse', False)
         self.collapsemsg = cmdutil.logmessage(ui, opts)
@@ -171,7 +171,7 @@ 
     def _writestatus(self, f):
         repo = self.repo.unfiltered()
         f.write(repo[self.originalwd].hex() + '\n')
-        f.write(repo[self.target].hex() + '\n')
+        f.write(repo[self.dest].hex() + '\n')
         f.write(repo[self.external].hex() + '\n')
         f.write('%d\n' % int(self.collapsef))
         f.write('%d\n' % int(self.keepf))
@@ -194,7 +194,7 @@ 
         """Restore a previously stored status"""
         repo = self.repo
         keepbranches = None
-        target = None
+        dest = None
         collapse = False
         external = nullrev
         activebookmark = None
@@ -206,7 +206,7 @@ 
                 if i == 0:
                     originalwd = repo[l].rev()
                 elif i == 1:
-                    target = repo[l].rev()
+                    dest = repo[l].rev()
                 elif i == 2:
                     external = repo[l].rev()
                 elif i == 3:
@@ -242,7 +242,7 @@ 
         skipped = set()
         # recompute the set of skipped revs
         if not collapse:
-            seen = set([target])
+            seen = set([dest])
             for old, new in sorted(state.items()):
                 if new != revtodo and new in seen:
                     skipped.add(old)
@@ -253,7 +253,7 @@ 
         _setrebasesetvisibility(repo, set(state.keys()) | set([originalwd]))
 
         self.originalwd = originalwd
-        self.target = target
+        self.dest = dest
         self.state = state
         self.skipped = skipped
         self.collapsef = collapse
@@ -262,12 +262,12 @@ 
         self.external = external
         self.activebookmark = activebookmark
 
-    def _handleskippingobsolete(self, rebaserevs, obsoleterevs, target):
+    def _handleskippingobsolete(self, rebaserevs, obsoleterevs, dest):
         """Compute structures necessary for skipping obsolete revisions
 
         rebaserevs:     iterable of all revisions that are to be rebased
         obsoleterevs:   iterable of all obsolete revisions in rebaseset
-        target:         a destination revision for the rebase operation
+        dest:           a destination revision for the rebase operation
         """
         self.obsoletenotrebased = {}
         if not self.ui.configbool('experimental', 'rebaseskipobsolete',
@@ -276,7 +276,7 @@ 
         rebaseset = set(rebaserevs)
         obsoleteset = set(obsoleterevs)
         self.obsoletenotrebased = _computeobsoletenotrebased(self.repo,
-                                    obsoleteset, target)
+                                    obsoleteset, dest)
         skippedset = set(self.obsoletenotrebased)
         _checkobsrebase(self.repo, self.ui, obsoleteset, rebaseset, skippedset)
 
@@ -296,11 +296,11 @@ 
                 hint = _('use "hg rebase --abort" to clear broken state')
                 raise error.Abort(msg, hint=hint)
         if isabort:
-            return abort(self.repo, self.originalwd, self.target,
+            return abort(self.repo, self.originalwd, self.dest,
                          self.state, activebookmark=self.activebookmark)
 
         obsrevs = (r for r, st in self.state.items() if st == revprecursor)
-        self._handleskippingobsolete(self.state.keys(), obsrevs, self.target)
+        self._handleskippingobsolete(self.state.keys(), obsrevs, self.dest)
 
     def _preparenewrebase(self, dest, rebaseset):
         if dest is None:
@@ -332,13 +332,13 @@ 
                                   % root,
                                   hint=_("see 'hg help phases' for details"))
 
-        (self.originalwd, self.target, self.state) = result
+        (self.originalwd, self.dest, self.state) = result
         if self.collapsef:
-            self.targetancestors = self.repo.changelog.ancestors(
-                                        [self.target],
+            self.destancestors = self.repo.changelog.ancestors(
+                                        [self.dest],
                                         inclusive=True)
             self.external = externalparent(self.repo, self.state,
-                                              self.targetancestors)
+                                              self.destancestors)
 
         if dest.closesbranch() and not self.keepbranchesf:
             self.ui.status(_('reopening closed branch head %s\n') % dest)
@@ -359,9 +359,9 @@ 
                             'branches'))
 
         # Rebase
-        if not self.targetancestors:
-            self.targetancestors = repo.changelog.ancestors([self.target],
-                                                               inclusive=True)
+        if not self.destancestors:
+            self.destancestors = repo.changelog.ancestors([self.dest],
+                                                          inclusive=True)
 
         # Keep track of the current bookmarks in order to reset them later
         self.currentbookmarks = repo._bookmarks.copy()
@@ -389,9 +389,9 @@ 
                 ui.status(_('rebasing %s\n') % desc)
                 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, ctx)),
                             _('changesets'), total)
-                p1, p2, base = defineparents(repo, rev, self.target,
+                p1, p2, base = defineparents(repo, rev, self.dest,
                                              self.state,
-                                             self.targetancestors,
+                                             self.destancestors,
                                              self.obsoletenotrebased)
                 self.storestatus(tr=tr)
                 storecollapsemsg(repo, self.collapsemsg)
@@ -402,7 +402,7 @@ 
                         ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
                                      'rebase')
                         stats = rebasenode(repo, rev, p1, base, self.state,
-                                           self.collapsef, self.target)
+                                           self.collapsef, self.dest)
                         if stats and stats[3] > 0:
                             raise error.InterventionRequired(
                                 _('unresolved conflicts (see hg '
@@ -440,11 +440,11 @@ 
             elif self.state[rev] == revignored:
                 ui.status(_('not rebasing ignored %s\n') % desc)
             elif self.state[rev] == revprecursor:
-                targetctx = repo[self.obsoletenotrebased[rev]]
-                desctarget = '%d:%s "%s"' % (targetctx.rev(), targetctx,
-                             targetctx.description().split('\n', 1)[0])
+                destctx = repo[self.obsoletenotrebased[rev]]
+                descdest = '%d:%s "%s"' % (destctx.rev(), destctx,
+                           destctx.description().split('\n', 1)[0])
                 msg = _('note: not rebasing %s, already in destination as %s\n')
-                ui.status(msg % (desc, desctarget))
+                ui.status(msg % (desc, descdest))
             elif self.state[rev] == revpruned:
                 msg = _('note: not rebasing %s, it has no successor\n')
                 ui.status(msg % desc)
@@ -459,8 +459,8 @@ 
         repo, ui, opts = self.repo, self.ui, self.opts
         if self.collapsef and not self.keepopen:
             p1, p2, _base = defineparents(repo, min(self.state),
-                                          self.target, self.state,
-                                          self.targetancestors,
+                                          self.dest, self.state,
+                                          self.destancestors,
                                           self.obsoletenotrebased)
             editopt = opts.get('edit')
             editform = 'rebase.collapse'
@@ -494,7 +494,7 @@ 
                 raise
 
             if newnode is None:
-                newrev = self.target
+                newrev = self.dest
             else:
                 newrev = repo[newnode].rev()
             for oldrev in self.state.iterkeys():
@@ -515,7 +515,7 @@ 
                     nstate[repo[k].node()] = repo[succ].node()
             # XXX this is the same as dest.node() for the non-continue path --
             # this should probably be cleaned up
-            targetnode = repo[self.target].node()
+            destnode = repo[self.dest].node()
 
         # restore original working directory
         # (we do this before stripping)
@@ -531,7 +531,7 @@ 
 
         if self.currentbookmarks:
             with repo.transaction('bookmark') as tr:
-                updatebookmarks(repo, targetnode, nstate,
+                updatebookmarks(repo, destnode, nstate,
                                 self.currentbookmarks, tr)
                 if self.activebookmark not in repo._bookmarks:
                     # active bookmark was divergent one and has been deleted
@@ -846,9 +846,9 @@ 
 
     return dest, rebaseset
 
-def externalparent(repo, state, targetancestors):
+def externalparent(repo, state, destancestors):
     """Return the revision that should be used as the second parent
-    when the revisions in state is collapsed on top of targetancestors.
+    when the revisions in state is collapsed on top of destancestors.
     Abort if there is more than one parent.
     """
     parents = set()
@@ -858,7 +858,7 @@ 
             continue
         for p in repo[rev].parents():
             if (p.rev() not in state
-                        and p.rev() not in targetancestors):
+                        and p.rev() not in destancestors):
                 parents.add(p.rev())
     if not parents:
         return nullrev
@@ -866,7 +866,7 @@ 
         return parents.pop()
     raise error.Abort(_('unable to collapse on top of %s, there is more '
                        'than one external parent: %s') %
-                     (max(targetancestors),
+                     (max(destancestors),
                       ', '.join(str(p) for p in sorted(parents))))
 
 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None,
@@ -883,8 +883,8 @@ 
     if extrafn:
         extrafn(ctx, extra)
 
-    targetphase = max(ctx.phase(), phases.draft)
-    overrides = {('phases', 'new-commit'): targetphase}
+    destphase = max(ctx.phase(), phases.draft)
+    overrides = {('phases', 'new-commit'): destphase}
     with repo.ui.configoverride(overrides, 'rebase'):
         if keepbranch:
             repo.ui.setconfig('ui', 'allowemptycommit', True)
@@ -897,10 +897,10 @@ 
     repo.dirstate.setbranch(repo[newnode].branch())
     return newnode
 
-def rebasenode(repo, rev, p1, base, state, collapse, target):
+def rebasenode(repo, rev, p1, base, state, collapse, dest):
     'Rebase a single revision rev on top of p1 using base as merge ancestor'
     # Merge phase
-    # Update to target and merge it with local
+    # Update to destination and merge it with local
     if repo['.'].rev() != p1:
         repo.ui.debug(" update to %d:%s\n" % (p1, repo[p1]))
         mergemod.update(repo, p1, False, True)
@@ -915,7 +915,7 @@ 
     stats = mergemod.update(repo, rev, True, True, base, collapse,
                             labels=['dest', 'source'])
     if collapse:
-        copies.duplicatecopies(repo, rev, target)
+        copies.duplicatecopies(repo, rev, dest)
     else:
         # If we're not using --collapse, we need to
         # duplicate copies between the revision we're
@@ -923,7 +923,7 @@ 
         # duplicate any copies that have already been
         # performed in the destination.
         p1rev = repo[rev].p1().rev()
-        copies.duplicatecopies(repo, rev, p1rev, skiprev=target)
+        copies.duplicatecopies(repo, rev, p1rev, skiprev=dest)
     return stats
 
 def nearestrebased(repo, rev, state):
@@ -958,7 +958,7 @@ 
               "experimental.allowdivergence=True")
         raise error.Abort(msg % (",".join(divhashes),), hint=h)
 
-def defineparents(repo, rev, target, state, targetancestors,
+def defineparents(repo, rev, dest, state, destancestors,
                   obsoletenotrebased):
     'Return the new parent relationship of the revision that will be rebased'
     parents = repo[rev].parents()
@@ -966,26 +966,26 @@ 
     rp1 = None
 
     p1n = parents[0].rev()
-    if p1n in targetancestors:
-        p1 = target
+    if p1n in destancestors:
+        p1 = dest
     elif p1n in state:
         if state[p1n] == nullmerge:
-            p1 = target
+            p1 = dest
         elif state[p1n] in revskipped:
             p1 = nearestrebased(repo, p1n, state)
             if p1 is None:
-                p1 = target
+                p1 = dest
         else:
             p1 = state[p1n]
     else: # p1n external
-        p1 = target
+        p1 = dest
         p2 = p1n
 
-    if len(parents) == 2 and parents[1].rev() not in targetancestors:
+    if len(parents) == 2 and parents[1].rev() not in destancestors:
         p2n = parents[1].rev()
         # interesting second parent
         if p2n in state:
-            if p1 == target: # p1n in targetancestors or external
+            if p1 == dest: # p1n in destancestors or external
                 p1 = state[p2n]
                 if p1 == revprecursor:
                     rp1 = obsoletenotrebased[p2n]
@@ -993,7 +993,7 @@ 
                 p2 = nearestrebased(repo, p2n, state)
                 if p2 is None:
                     # no ancestors rebased yet, detach
-                    p2 = target
+                    p2 = dest
             else:
                 p2 = state[p2n]
         else: # p2n external
@@ -1109,14 +1109,14 @@ 
         mq.seriesdirty = True
         mq.savedirty()
 
-def updatebookmarks(repo, targetnode, nstate, originalbookmarks, tr):
+def updatebookmarks(repo, destnode, nstate, originalbookmarks, tr):
     'Move bookmarks to their correct changesets, and delete divergent ones'
     marks = repo._bookmarks
     for k, v in originalbookmarks.iteritems():
         if v in nstate:
             # update the bookmarks for revs that have moved
             marks[k] = nstate[v]
-            bookmarks.deletedivergent(repo, [targetnode], k)
+            bookmarks.deletedivergent(repo, [destnode], k)
     marks.recordchange(tr)
 
 def storecollapsemsg(repo, collapsemsg):
@@ -1168,7 +1168,7 @@ 
 
     return False
 
-def abort(repo, originalwd, target, state, activebookmark=None):
+def abort(repo, originalwd, dest, state, activebookmark=None):
     '''Restore the repository to its original state.  Additional args:
 
     activebookmark: the name of the bookmark that should be active after the
@@ -1176,9 +1176,9 @@ 
 
     try:
         # If the first commits in the rebased set get skipped during the rebase,
-        # their values within the state mapping will be the target rev id. The
-        # dstates list must must not contain the target rev (issue4896)
-        dstates = [s for s in state.values() if s >= 0 and s != target]
+        # their values within the state mapping will be the dest rev id. The
+        # dstates list must must not contain the dest rev (issue4896)
+        dstates = [s for s in state.values() if s >= 0 and s != dest]
         immutable = [d for d in dstates if not repo[d].mutable()]
         cleanup = True
         if immutable:
@@ -1197,13 +1197,13 @@ 
 
         if cleanup:
             shouldupdate = False
-            rebased = filter(lambda x: x >= 0 and x != target, state.values())
+            rebased = filter(lambda x: x >= 0 and x != dest, state.values())
             if rebased:
                 strippoints = [
                         c.node() for c in repo.set('roots(%ld)', rebased)]
 
             updateifonnodes = set(rebased)
-            updateifonnodes.add(target)
+            updateifonnodes.add(dest)
             updateifonnodes.add(originalwd)
             shouldupdate = repo['.'].rev() in updateifonnodes