Mercurial > hg-stable
changeset 15214:231aac5280ba
rebase: move updatedirstate into cmdutil so it can be shared
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 09 Oct 2011 16:14:37 -0500 |
parents | 15f15f3b405d |
children | c41078b9d0b8 |
files | hgext/rebase.py mercurial/cmdutil.py |
diffstat | 2 files changed, 16 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/rebase.py Sun Oct 09 11:03:57 2011 -0500 +++ b/hgext/rebase.py Sun Oct 09 16:14:37 2011 -0500 @@ -15,7 +15,7 @@ ''' from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks -from mercurial import extensions, copies, patch +from mercurial import extensions, patch from mercurial.commands import templateopts from mercurial.node import nullrev from mercurial.lock import release @@ -215,7 +215,7 @@ 'resolve, then hg rebase --continue)')) finally: ui.setconfig('ui', 'forcemerge', '') - updatedirstate(repo, rev, target, p2) + cmdutil.duplicatecopies(repo, rev, target, p2) if not collapsef: newrev = concludenode(repo, rev, p1, p2, extrafn=extrafn) else: @@ -301,20 +301,6 @@ external = p.rev() return external -def updatedirstate(repo, rev, p1, p2): - """Keep track of renamed files in the revision that is going to be rebased - """ - # Here we simulate the copies and renames in the source changeset - cop, diver = copies.copies(repo, repo[rev], repo[p1], repo[p2], True) - m1 = repo[rev].manifest() - m2 = repo[p1].manifest() - for k, v in cop.iteritems(): - if k in m1: - if v in m1 or v in m2: - repo.dirstate.copy(v, k) - if v in m2 and v not in m1 and k in m2: - repo.dirstate.remove(v) - def concludenode(repo, rev, p1, p2, commitmsg=None, extrafn=None): 'Commit the changes and store useful information in extra' try:
--- a/mercurial/cmdutil.py Sun Oct 09 11:03:57 2011 -0500 +++ b/mercurial/cmdutil.py Sun Oct 09 16:14:37 2011 -0500 @@ -8,7 +8,7 @@ from node import hex, nullid, nullrev, short from i18n import _ import os, sys, errno, re, tempfile -import util, scmutil, templater, patch, error, templatekw, revlog +import util, scmutil, templater, patch, error, templatekw, revlog, copies import match as matchmod import subrepo @@ -1176,6 +1176,19 @@ bad.extend(f for f in rejected if f in match.files()) return bad +def duplicatecopies(repo, rev, p1, p2): + "Reproduce copies found in the source revision in the dirstate for grafts" + # Here we simulate the copies and renames in the source changeset + cop, diver = copies.copies(repo, repo[rev], repo[p1], repo[p2], True) + m1 = repo[rev].manifest() + m2 = repo[p1].manifest() + for k, v in cop.iteritems(): + if k in m1: + if v in m1 or v in m2: + repo.dirstate.copy(v, k) + if v in m2 and v not in m1 and k in m2: + repo.dirstate.remove(v) + def commit(ui, repo, commitfunc, pats, opts): '''commit the specified files or all outstanding changes''' date = opts.get('date')