##// END OF EJS Templates
rebase: move updatedirstate into cmdutil so it can be shared
Matt Mackall -
r15214:231aac52 default
parent child Browse files
Show More
@@ -15,7 +15,7 b' http://mercurial.selenic.com/wiki/Rebase'
15 15 '''
16 16
17 17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
18 from mercurial import extensions, copies, patch
18 from mercurial import extensions, patch
19 19 from mercurial.commands import templateopts
20 20 from mercurial.node import nullrev
21 21 from mercurial.lock import release
@@ -215,7 +215,7 b' def rebase(ui, repo, **opts):'
215 215 'resolve, then hg rebase --continue)'))
216 216 finally:
217 217 ui.setconfig('ui', 'forcemerge', '')
218 updatedirstate(repo, rev, target, p2)
218 cmdutil.duplicatecopies(repo, rev, target, p2)
219 219 if not collapsef:
220 220 newrev = concludenode(repo, rev, p1, p2, extrafn=extrafn)
221 221 else:
@@ -301,20 +301,6 b' def checkexternal(repo, state, targetanc'
301 301 external = p.rev()
302 302 return external
303 303
304 def updatedirstate(repo, rev, p1, p2):
305 """Keep track of renamed files in the revision that is going to be rebased
306 """
307 # Here we simulate the copies and renames in the source changeset
308 cop, diver = copies.copies(repo, repo[rev], repo[p1], repo[p2], True)
309 m1 = repo[rev].manifest()
310 m2 = repo[p1].manifest()
311 for k, v in cop.iteritems():
312 if k in m1:
313 if v in m1 or v in m2:
314 repo.dirstate.copy(v, k)
315 if v in m2 and v not in m1 and k in m2:
316 repo.dirstate.remove(v)
317
318 304 def concludenode(repo, rev, p1, p2, commitmsg=None, extrafn=None):
319 305 'Commit the changes and store useful information in extra'
320 306 try:
@@ -8,7 +8,7 b''
8 8 from node import hex, nullid, nullrev, short
9 9 from i18n import _
10 10 import os, sys, errno, re, tempfile
11 import util, scmutil, templater, patch, error, templatekw, revlog
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies
12 12 import match as matchmod
13 13 import subrepo
14 14
@@ -1176,6 +1176,19 b' def add(ui, repo, match, dryrun, listsub'
1176 1176 bad.extend(f for f in rejected if f in match.files())
1177 1177 return bad
1178 1178
1179 def duplicatecopies(repo, rev, p1, p2):
1180 "Reproduce copies found in the source revision in the dirstate for grafts"
1181 # Here we simulate the copies and renames in the source changeset
1182 cop, diver = copies.copies(repo, repo[rev], repo[p1], repo[p2], True)
1183 m1 = repo[rev].manifest()
1184 m2 = repo[p1].manifest()
1185 for k, v in cop.iteritems():
1186 if k in m1:
1187 if v in m1 or v in m2:
1188 repo.dirstate.copy(v, k)
1189 if v in m2 and v not in m1 and k in m2:
1190 repo.dirstate.remove(v)
1191
1179 1192 def commit(ui, repo, commitfunc, pats, opts):
1180 1193 '''commit the specified files or all outstanding changes'''
1181 1194 date = opts.get('date')
General Comments 0
You need to be logged in to leave comments. Login now