##// END OF EJS Templates
duplicatecopies: move from cmdutil to copies...
Matt Mackall -
r22901:722117c8 default
parent child Browse files
Show More
@@ -234,7 +234,7 b' def applychanges(ui, repo, ctx, opts):'
234 repo.dirstate.endparentchange()
234 repo.dirstate.endparentchange()
235 repo.dirstate.write()
235 repo.dirstate.write()
236 # fix up dirstate for copies and renames
236 # fix up dirstate for copies and renames
237 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
237 copies.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
238 return stats
238 return stats
239
239
240 def collapse(repo, first, last, commitopts):
240 def collapse(repo, first, last, commitopts):
@@ -16,6 +16,7 b' http://mercurial.selenic.com/wiki/Rebase'
16
16
17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
18 from mercurial import extensions, patch, scmutil, phases, obsolete, error
18 from mercurial import extensions, patch, scmutil, phases, obsolete, error
19 from mercurial import copies
19 from mercurial.commands import templateopts
20 from mercurial.commands import templateopts
20 from mercurial.node import nullrev
21 from mercurial.node import nullrev
21 from mercurial.lock import release
22 from mercurial.lock import release
@@ -382,7 +383,7 b' def rebase(ui, repo, **opts):'
382 finally:
383 finally:
383 ui.setconfig('ui', 'forcemerge', '', 'rebase')
384 ui.setconfig('ui', 'forcemerge', '', 'rebase')
384 if collapsef:
385 if collapsef:
385 cmdutil.duplicatecopies(repo, rev, target)
386 copies.duplicatecopies(repo, rev, target)
386 else:
387 else:
387 # If we're not using --collapse, we need to
388 # If we're not using --collapse, we need to
388 # duplicate copies between the revision we're
389 # duplicate copies between the revision we're
@@ -390,7 +391,7 b' def rebase(ui, repo, **opts):'
390 # duplicate any copies that have already been
391 # duplicate any copies that have already been
391 # performed in the destination.
392 # performed in the destination.
392 p1rev = repo[rev].p1().rev()
393 p1rev = repo[rev].p1().rev()
393 cmdutil.duplicatecopies(repo, rev, p1rev, skiprev=target)
394 copies.duplicatecopies(repo, rev, p1rev, skiprev=target)
394 if not collapsef:
395 if not collapsef:
395 merging = repo[p2].rev() != nullrev
396 merging = repo[p2].rev() != nullrev
396 editform = cmdutil.mergeeditform(merging, 'rebase')
397 editform = cmdutil.mergeeditform(merging, 'rebase')
@@ -2105,25 +2105,6 b' def cat(ui, repo, ctx, matcher, prefix, '
2105
2105
2106 return err
2106 return err
2107
2107
2108 def duplicatecopies(repo, rev, fromrev, skiprev=None):
2109 '''reproduce copies from fromrev to rev in the dirstate
2110
2111 If skiprev is specified, it's a revision that should be used to
2112 filter copy records. Any copies that occur between fromrev and
2113 skiprev will not be duplicated, even if they appear in the set of
2114 copies between fromrev and rev.
2115 '''
2116 exclude = {}
2117 if skiprev is not None:
2118 exclude = copies.pathcopies(repo[fromrev], repo[skiprev])
2119 for dst, src in copies.pathcopies(repo[fromrev], repo[rev]).iteritems():
2120 # copies.pathcopies returns backward renames, so dst might not
2121 # actually be in the dirstate
2122 if dst in exclude:
2123 continue
2124 if repo.dirstate[dst] in "nma":
2125 repo.dirstate.copy(src, dst)
2126
2127 def commit(ui, repo, commitfunc, pats, opts):
2108 def commit(ui, repo, commitfunc, pats, opts):
2128 '''commit the specified files or all outstanding changes'''
2109 '''commit the specified files or all outstanding changes'''
2129 date = opts.get('date')
2110 date = opts.get('date')
@@ -18,7 +18,7 b' import extensions'
18 from hgweb import server as hgweb_server
18 from hgweb import server as hgweb_server
19 import merge as mergemod
19 import merge as mergemod
20 import minirst, revset, fileset
20 import minirst, revset, fileset
21 import dagparser, context, simplemerge, graphmod
21 import dagparser, context, simplemerge, graphmod, copies
22 import random
22 import random
23 import setdiscovery, treediscovery, dagutil, pvec, localrepo
23 import setdiscovery, treediscovery, dagutil, pvec, localrepo
24 import phases, obsolete, exchange
24 import phases, obsolete, exchange
@@ -3490,7 +3490,7 b' def graft(ui, repo, *revs, **opts):'
3490 repo.setparents(current.node(), nullid)
3490 repo.setparents(current.node(), nullid)
3491 repo.dirstate.write()
3491 repo.dirstate.write()
3492 # fix up dirstate for copies and renames
3492 # fix up dirstate for copies and renames
3493 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
3493 copies.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
3494 repo.dirstate.endparentchange()
3494 repo.dirstate.endparentchange()
3495 finally:
3495 finally:
3496 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3496 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
@@ -420,3 +420,22 b' def checkcopies(ctx, f, m1, m2, ca, limi'
420
420
421 if of in ma:
421 if of in ma:
422 diverge.setdefault(of, []).append(f)
422 diverge.setdefault(of, []).append(f)
423
424 def duplicatecopies(repo, rev, fromrev, skiprev=None):
425 '''reproduce copies from fromrev to rev in the dirstate
426
427 If skiprev is specified, it's a revision that should be used to
428 filter copy records. Any copies that occur between fromrev and
429 skiprev will not be duplicated, even if they appear in the set of
430 copies between fromrev and rev.
431 '''
432 exclude = {}
433 if skiprev is not None:
434 exclude = pathcopies(repo[fromrev], repo[skiprev])
435 for dst, src in pathcopies(repo[fromrev], repo[rev]).iteritems():
436 # copies.pathcopies returns backward renames, so dst might not
437 # actually be in the dirstate
438 if dst in exclude:
439 continue
440 if repo.dirstate[dst] in "nma":
441 repo.dirstate.copy(src, dst)
General Comments 0
You need to be logged in to leave comments. Login now