##// END OF EJS Templates
rebase: rename "target" to "dest" in variable names...
Martin von Zweigbergk -
r32248:b47e6b0b default
parent child Browse files
Show More
@@ -139,9 +139,9 b' class rebaseruntime(object):'
139 139 self.state = {}
140 140 self.activebookmark = None
141 141 self.currentbookmarks = None
142 self.target = None
142 self.dest = None
143 143 self.skipped = set()
144 self.targetancestors = set()
144 self.destancestors = set()
145 145
146 146 self.collapsef = opts.get('collapse', False)
147 147 self.collapsemsg = cmdutil.logmessage(ui, opts)
@@ -171,7 +171,7 b' class rebaseruntime(object):'
171 171 def _writestatus(self, f):
172 172 repo = self.repo.unfiltered()
173 173 f.write(repo[self.originalwd].hex() + '\n')
174 f.write(repo[self.target].hex() + '\n')
174 f.write(repo[self.dest].hex() + '\n')
175 175 f.write(repo[self.external].hex() + '\n')
176 176 f.write('%d\n' % int(self.collapsef))
177 177 f.write('%d\n' % int(self.keepf))
@@ -194,7 +194,7 b' class rebaseruntime(object):'
194 194 """Restore a previously stored status"""
195 195 repo = self.repo
196 196 keepbranches = None
197 target = None
197 dest = None
198 198 collapse = False
199 199 external = nullrev
200 200 activebookmark = None
@@ -206,7 +206,7 b' class rebaseruntime(object):'
206 206 if i == 0:
207 207 originalwd = repo[l].rev()
208 208 elif i == 1:
209 target = repo[l].rev()
209 dest = repo[l].rev()
210 210 elif i == 2:
211 211 external = repo[l].rev()
212 212 elif i == 3:
@@ -242,7 +242,7 b' class rebaseruntime(object):'
242 242 skipped = set()
243 243 # recompute the set of skipped revs
244 244 if not collapse:
245 seen = set([target])
245 seen = set([dest])
246 246 for old, new in sorted(state.items()):
247 247 if new != revtodo and new in seen:
248 248 skipped.add(old)
@@ -253,7 +253,7 b' class rebaseruntime(object):'
253 253 _setrebasesetvisibility(repo, set(state.keys()) | set([originalwd]))
254 254
255 255 self.originalwd = originalwd
256 self.target = target
256 self.dest = dest
257 257 self.state = state
258 258 self.skipped = skipped
259 259 self.collapsef = collapse
@@ -262,12 +262,12 b' class rebaseruntime(object):'
262 262 self.external = external
263 263 self.activebookmark = activebookmark
264 264
265 def _handleskippingobsolete(self, rebaserevs, obsoleterevs, target):
265 def _handleskippingobsolete(self, rebaserevs, obsoleterevs, dest):
266 266 """Compute structures necessary for skipping obsolete revisions
267 267
268 268 rebaserevs: iterable of all revisions that are to be rebased
269 269 obsoleterevs: iterable of all obsolete revisions in rebaseset
270 target: a destination revision for the rebase operation
270 dest: a destination revision for the rebase operation
271 271 """
272 272 self.obsoletenotrebased = {}
273 273 if not self.ui.configbool('experimental', 'rebaseskipobsolete',
@@ -276,7 +276,7 b' class rebaseruntime(object):'
276 276 rebaseset = set(rebaserevs)
277 277 obsoleteset = set(obsoleterevs)
278 278 self.obsoletenotrebased = _computeobsoletenotrebased(self.repo,
279 obsoleteset, target)
279 obsoleteset, dest)
280 280 skippedset = set(self.obsoletenotrebased)
281 281 _checkobsrebase(self.repo, self.ui, obsoleteset, rebaseset, skippedset)
282 282
@@ -296,11 +296,11 b' class rebaseruntime(object):'
296 296 hint = _('use "hg rebase --abort" to clear broken state')
297 297 raise error.Abort(msg, hint=hint)
298 298 if isabort:
299 return abort(self.repo, self.originalwd, self.target,
299 return abort(self.repo, self.originalwd, self.dest,
300 300 self.state, activebookmark=self.activebookmark)
301 301
302 302 obsrevs = (r for r, st in self.state.items() if st == revprecursor)
303 self._handleskippingobsolete(self.state.keys(), obsrevs, self.target)
303 self._handleskippingobsolete(self.state.keys(), obsrevs, self.dest)
304 304
305 305 def _preparenewrebase(self, dest, rebaseset):
306 306 if dest is None:
@@ -332,13 +332,13 b' class rebaseruntime(object):'
332 332 % root,
333 333 hint=_("see 'hg help phases' for details"))
334 334
335 (self.originalwd, self.target, self.state) = result
335 (self.originalwd, self.dest, self.state) = result
336 336 if self.collapsef:
337 self.targetancestors = self.repo.changelog.ancestors(
338 [self.target],
337 self.destancestors = self.repo.changelog.ancestors(
338 [self.dest],
339 339 inclusive=True)
340 340 self.external = externalparent(self.repo, self.state,
341 self.targetancestors)
341 self.destancestors)
342 342
343 343 if dest.closesbranch() and not self.keepbranchesf:
344 344 self.ui.status(_('reopening closed branch head %s\n') % dest)
@@ -359,9 +359,9 b' class rebaseruntime(object):'
359 359 'branches'))
360 360
361 361 # Rebase
362 if not self.targetancestors:
363 self.targetancestors = repo.changelog.ancestors([self.target],
364 inclusive=True)
362 if not self.destancestors:
363 self.destancestors = repo.changelog.ancestors([self.dest],
364 inclusive=True)
365 365
366 366 # Keep track of the current bookmarks in order to reset them later
367 367 self.currentbookmarks = repo._bookmarks.copy()
@@ -389,9 +389,9 b' class rebaseruntime(object):'
389 389 ui.status(_('rebasing %s\n') % desc)
390 390 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, ctx)),
391 391 _('changesets'), total)
392 p1, p2, base = defineparents(repo, rev, self.target,
392 p1, p2, base = defineparents(repo, rev, self.dest,
393 393 self.state,
394 self.targetancestors,
394 self.destancestors,
395 395 self.obsoletenotrebased)
396 396 self.storestatus(tr=tr)
397 397 storecollapsemsg(repo, self.collapsemsg)
@@ -402,7 +402,7 b' class rebaseruntime(object):'
402 402 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
403 403 'rebase')
404 404 stats = rebasenode(repo, rev, p1, base, self.state,
405 self.collapsef, self.target)
405 self.collapsef, self.dest)
406 406 if stats and stats[3] > 0:
407 407 raise error.InterventionRequired(
408 408 _('unresolved conflicts (see hg '
@@ -440,11 +440,11 b' class rebaseruntime(object):'
440 440 elif self.state[rev] == revignored:
441 441 ui.status(_('not rebasing ignored %s\n') % desc)
442 442 elif self.state[rev] == revprecursor:
443 targetctx = repo[self.obsoletenotrebased[rev]]
444 desctarget = '%d:%s "%s"' % (targetctx.rev(), targetctx,
445 targetctx.description().split('\n', 1)[0])
443 destctx = repo[self.obsoletenotrebased[rev]]
444 descdest = '%d:%s "%s"' % (destctx.rev(), destctx,
445 destctx.description().split('\n', 1)[0])
446 446 msg = _('note: not rebasing %s, already in destination as %s\n')
447 ui.status(msg % (desc, desctarget))
447 ui.status(msg % (desc, descdest))
448 448 elif self.state[rev] == revpruned:
449 449 msg = _('note: not rebasing %s, it has no successor\n')
450 450 ui.status(msg % desc)
@@ -459,8 +459,8 b' class rebaseruntime(object):'
459 459 repo, ui, opts = self.repo, self.ui, self.opts
460 460 if self.collapsef and not self.keepopen:
461 461 p1, p2, _base = defineparents(repo, min(self.state),
462 self.target, self.state,
463 self.targetancestors,
462 self.dest, self.state,
463 self.destancestors,
464 464 self.obsoletenotrebased)
465 465 editopt = opts.get('edit')
466 466 editform = 'rebase.collapse'
@@ -494,7 +494,7 b' class rebaseruntime(object):'
494 494 raise
495 495
496 496 if newnode is None:
497 newrev = self.target
497 newrev = self.dest
498 498 else:
499 499 newrev = repo[newnode].rev()
500 500 for oldrev in self.state.iterkeys():
@@ -515,7 +515,7 b' class rebaseruntime(object):'
515 515 nstate[repo[k].node()] = repo[succ].node()
516 516 # XXX this is the same as dest.node() for the non-continue path --
517 517 # this should probably be cleaned up
518 targetnode = repo[self.target].node()
518 destnode = repo[self.dest].node()
519 519
520 520 # restore original working directory
521 521 # (we do this before stripping)
@@ -531,7 +531,7 b' class rebaseruntime(object):'
531 531
532 532 if self.currentbookmarks:
533 533 with repo.transaction('bookmark') as tr:
534 updatebookmarks(repo, targetnode, nstate,
534 updatebookmarks(repo, destnode, nstate,
535 535 self.currentbookmarks, tr)
536 536 if self.activebookmark not in repo._bookmarks:
537 537 # active bookmark was divergent one and has been deleted
@@ -846,9 +846,9 b' def _definesets(ui, repo, destf=None, sr'
846 846
847 847 return dest, rebaseset
848 848
849 def externalparent(repo, state, targetancestors):
849 def externalparent(repo, state, destancestors):
850 850 """Return the revision that should be used as the second parent
851 when the revisions in state is collapsed on top of targetancestors.
851 when the revisions in state is collapsed on top of destancestors.
852 852 Abort if there is more than one parent.
853 853 """
854 854 parents = set()
@@ -858,7 +858,7 b' def externalparent(repo, state, targetan'
858 858 continue
859 859 for p in repo[rev].parents():
860 860 if (p.rev() not in state
861 and p.rev() not in targetancestors):
861 and p.rev() not in destancestors):
862 862 parents.add(p.rev())
863 863 if not parents:
864 864 return nullrev
@@ -866,7 +866,7 b' def externalparent(repo, state, targetan'
866 866 return parents.pop()
867 867 raise error.Abort(_('unable to collapse on top of %s, there is more '
868 868 'than one external parent: %s') %
869 (max(targetancestors),
869 (max(destancestors),
870 870 ', '.join(str(p) for p in sorted(parents))))
871 871
872 872 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None,
@@ -883,8 +883,8 b' def concludenode(repo, rev, p1, p2, comm'
883 883 if extrafn:
884 884 extrafn(ctx, extra)
885 885
886 targetphase = max(ctx.phase(), phases.draft)
887 overrides = {('phases', 'new-commit'): targetphase}
886 destphase = max(ctx.phase(), phases.draft)
887 overrides = {('phases', 'new-commit'): destphase}
888 888 with repo.ui.configoverride(overrides, 'rebase'):
889 889 if keepbranch:
890 890 repo.ui.setconfig('ui', 'allowemptycommit', True)
@@ -897,10 +897,10 b' def concludenode(repo, rev, p1, p2, comm'
897 897 repo.dirstate.setbranch(repo[newnode].branch())
898 898 return newnode
899 899
900 def rebasenode(repo, rev, p1, base, state, collapse, target):
900 def rebasenode(repo, rev, p1, base, state, collapse, dest):
901 901 'Rebase a single revision rev on top of p1 using base as merge ancestor'
902 902 # Merge phase
903 # Update to target and merge it with local
903 # Update to destination and merge it with local
904 904 if repo['.'].rev() != p1:
905 905 repo.ui.debug(" update to %d:%s\n" % (p1, repo[p1]))
906 906 mergemod.update(repo, p1, False, True)
@@ -915,7 +915,7 b' def rebasenode(repo, rev, p1, base, stat'
915 915 stats = mergemod.update(repo, rev, True, True, base, collapse,
916 916 labels=['dest', 'source'])
917 917 if collapse:
918 copies.duplicatecopies(repo, rev, target)
918 copies.duplicatecopies(repo, rev, dest)
919 919 else:
920 920 # If we're not using --collapse, we need to
921 921 # duplicate copies between the revision we're
@@ -923,7 +923,7 b' def rebasenode(repo, rev, p1, base, stat'
923 923 # duplicate any copies that have already been
924 924 # performed in the destination.
925 925 p1rev = repo[rev].p1().rev()
926 copies.duplicatecopies(repo, rev, p1rev, skiprev=target)
926 copies.duplicatecopies(repo, rev, p1rev, skiprev=dest)
927 927 return stats
928 928
929 929 def nearestrebased(repo, rev, state):
@@ -958,7 +958,7 b' def _checkobsrebase(repo, ui, rebaseobsr'
958 958 "experimental.allowdivergence=True")
959 959 raise error.Abort(msg % (",".join(divhashes),), hint=h)
960 960
961 def defineparents(repo, rev, target, state, targetancestors,
961 def defineparents(repo, rev, dest, state, destancestors,
962 962 obsoletenotrebased):
963 963 'Return the new parent relationship of the revision that will be rebased'
964 964 parents = repo[rev].parents()
@@ -966,26 +966,26 b' def defineparents(repo, rev, target, sta'
966 966 rp1 = None
967 967
968 968 p1n = parents[0].rev()
969 if p1n in targetancestors:
970 p1 = target
969 if p1n in destancestors:
970 p1 = dest
971 971 elif p1n in state:
972 972 if state[p1n] == nullmerge:
973 p1 = target
973 p1 = dest
974 974 elif state[p1n] in revskipped:
975 975 p1 = nearestrebased(repo, p1n, state)
976 976 if p1 is None:
977 p1 = target
977 p1 = dest
978 978 else:
979 979 p1 = state[p1n]
980 980 else: # p1n external
981 p1 = target
981 p1 = dest
982 982 p2 = p1n
983 983
984 if len(parents) == 2 and parents[1].rev() not in targetancestors:
984 if len(parents) == 2 and parents[1].rev() not in destancestors:
985 985 p2n = parents[1].rev()
986 986 # interesting second parent
987 987 if p2n in state:
988 if p1 == target: # p1n in targetancestors or external
988 if p1 == dest: # p1n in destancestors or external
989 989 p1 = state[p2n]
990 990 if p1 == revprecursor:
991 991 rp1 = obsoletenotrebased[p2n]
@@ -993,7 +993,7 b' def defineparents(repo, rev, target, sta'
993 993 p2 = nearestrebased(repo, p2n, state)
994 994 if p2 is None:
995 995 # no ancestors rebased yet, detach
996 p2 = target
996 p2 = dest
997 997 else:
998 998 p2 = state[p2n]
999 999 else: # p2n external
@@ -1109,14 +1109,14 b' def updatemq(repo, state, skipped, **opt'
1109 1109 mq.seriesdirty = True
1110 1110 mq.savedirty()
1111 1111
1112 def updatebookmarks(repo, targetnode, nstate, originalbookmarks, tr):
1112 def updatebookmarks(repo, destnode, nstate, originalbookmarks, tr):
1113 1113 'Move bookmarks to their correct changesets, and delete divergent ones'
1114 1114 marks = repo._bookmarks
1115 1115 for k, v in originalbookmarks.iteritems():
1116 1116 if v in nstate:
1117 1117 # update the bookmarks for revs that have moved
1118 1118 marks[k] = nstate[v]
1119 bookmarks.deletedivergent(repo, [targetnode], k)
1119 bookmarks.deletedivergent(repo, [destnode], k)
1120 1120 marks.recordchange(tr)
1121 1121
1122 1122 def storecollapsemsg(repo, collapsemsg):
@@ -1168,7 +1168,7 b' def needupdate(repo, state):'
1168 1168
1169 1169 return False
1170 1170
1171 def abort(repo, originalwd, target, state, activebookmark=None):
1171 def abort(repo, originalwd, dest, state, activebookmark=None):
1172 1172 '''Restore the repository to its original state. Additional args:
1173 1173
1174 1174 activebookmark: the name of the bookmark that should be active after the
@@ -1176,9 +1176,9 b' def abort(repo, originalwd, target, stat'
1176 1176
1177 1177 try:
1178 1178 # If the first commits in the rebased set get skipped during the rebase,
1179 # their values within the state mapping will be the target rev id. The
1180 # dstates list must must not contain the target rev (issue4896)
1181 dstates = [s for s in state.values() if s >= 0 and s != target]
1179 # their values within the state mapping will be the dest rev id. The
1180 # dstates list must must not contain the dest rev (issue4896)
1181 dstates = [s for s in state.values() if s >= 0 and s != dest]
1182 1182 immutable = [d for d in dstates if not repo[d].mutable()]
1183 1183 cleanup = True
1184 1184 if immutable:
@@ -1197,13 +1197,13 b' def abort(repo, originalwd, target, stat'
1197 1197
1198 1198 if cleanup:
1199 1199 shouldupdate = False
1200 rebased = filter(lambda x: x >= 0 and x != target, state.values())
1200 rebased = filter(lambda x: x >= 0 and x != dest, state.values())
1201 1201 if rebased:
1202 1202 strippoints = [
1203 1203 c.node() for c in repo.set('roots(%ld)', rebased)]
1204 1204
1205 1205 updateifonnodes = set(rebased)
1206 updateifonnodes.add(target)
1206 updateifonnodes.add(dest)
1207 1207 updateifonnodes.add(originalwd)
1208 1208 shouldupdate = repo['.'].rev() in updateifonnodes
1209 1209
General Comments 0
You need to be logged in to leave comments. Login now