diff --git a/hgext3rd/pushrebase.py b/hgext3rd/pushrebase.py --- a/hgext3rd/pushrebase.py +++ b/hgext3rd/pushrebase.py @@ -507,7 +507,18 @@ return bundlefile -def _getrevs(bundle, onto): +def _getrenamesrcs(rev): + '''get all rename sources in a revision''' + srcs = set() + revmf = rev.manifest() + for f in rev.files(): + if f in revmf: + renamed = rev[f].renamed() + if renamed: + srcs.add(renamed[0]) + return srcs + +def _getrevs(bundle, onto, renamesrccache): 'extracts and validates the revs to be imported' validaterevset(bundle, 'bundle()') revs = [bundle[r] for r in bundle.revs('sort(bundle())')] @@ -537,6 +548,13 @@ for bundlerev in revs: bundlefiles.update(bundlerev.files()) + # Also include sources of renames. + bundlerevnode = bundlerev.node() + if bundlerevnode in renamesrccache: + bundlefiles.update(renamesrccache[bundlerevnode]) + else: + bundlefiles.update(_getrenamesrcs(bundlerev)) + def findconflicts(): # Returns all the files touched in the bundle that are also touched # between the old onto (ex: our old bookmark location) and the new @@ -806,6 +824,10 @@ bundlerepocache, preontocache = prefetchcaches(op, params, bundle) + # Create a cache of rename sources while we don't have the lock. + renamesrccache = {bundle[r].node(): _getrenamesrcs(bundle[r]) + for r in bundle.revs('bundle()')} + # Opening the transaction takes the lock, so do it after prepushrebase # and after we've fetched all the cache information we'll need. tr = op.gettransaction() @@ -821,7 +843,7 @@ onto = getontotarget(op, params, bundle) - revs, oldonto = _getrevs(bundle, onto) + revs, oldonto = _getrevs(bundle, onto, renamesrccache) op.repo.hook("prechangegroup", **hookargs) diff --git a/tests/test-pushrebase.t b/tests/test-pushrebase.t --- a/tests/test-pushrebase.t +++ b/tests/test-pushrebase.t @@ -932,57 +932,8 @@ $ hg push -r . --to default pushing to $TESTTMP/server2 (glob) searching for changes - pushing 1 changeset: - 40d149b24655 Copy A to B - 2 new changesets from the server will be downloaded - adding changesets - adding manifests - adding file changes - added 2 changesets with 2 changes to 2 files (+1 heads) - 1 new obsolescence markers - obsoleted 1 changesets - 2 files updated, 0 files merged, 0 files removed, 0 files unresolved - -SUBOPTIMAL: The pushrebased changest lost the content of "Modify A": + abort: conflicting changes in: + A + + [255] - $ hg log -Gr 'all()' -p --config diff.git=1 - @ changeset: 3:b0bbcfeb5f8d - | tag: tip - | user: test - | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: Copy A to B - | - | diff --git a/A b/B - | copy from A - | copy to B - | --- a/A - | +++ b/B - | @@ -1,2 +1,1 @@ - | 1 - | -2 - | - o changeset: 2:986e0f3a27f2 - | parent: 0:a18fe624bf77 - | user: test - | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: Modify A - | - | diff --git a/A b/A - | --- a/A - | +++ b/A - | @@ -1,1 +1,2 @@ - | 1 - | +2 - | - o changeset: 0:a18fe624bf77 - user: test - date: Thu Jan 01 00:00:00 1970 +0000 - summary: A - - diff --git a/A b/A - new file mode 100644 - --- /dev/null - +++ b/A - @@ -0,0 +1,1 @@ - +1 -