mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
convert: mercurial_source: also search for copies in modified files
There are some corner cases where we may have a copy in a file that isn't in the added list: - the result of a hg copy --after --force - after a merge across a (local) rename
This commit is contained in:
parent
6309fee56a
commit
7dac6f1262
@ -187,12 +187,11 @@ class mercurial_source(converter_source):
|
||||
m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3]
|
||||
changes = [(name, rev) for name in m + a + r]
|
||||
changes.sort()
|
||||
return (changes, self.getcopies(ctx))
|
||||
return (changes, self.getcopies(ctx, m + a))
|
||||
|
||||
def getcopies(self, ctx):
|
||||
added = self.repo.status(ctx.parents()[0].node(), ctx.node())[1]
|
||||
def getcopies(self, ctx, files):
|
||||
copies = {}
|
||||
for name in added:
|
||||
for name in files:
|
||||
try:
|
||||
copies[name] = ctx.filectx(name).renamed()[0]
|
||||
except TypeError:
|
||||
|
33
tests/test-convert-hg-source
Executable file
33
tests/test-convert-hg-source
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "[extensions]" >> $HGRCPATH
|
||||
echo "hgext.convert=" >> $HGRCPATH
|
||||
|
||||
hg init orig
|
||||
cd orig
|
||||
|
||||
echo foo > foo
|
||||
echo bar > bar
|
||||
hg ci -qAm 'add foo bar' -d '0 0'
|
||||
|
||||
echo >> foo
|
||||
hg ci -m 'change foo'
|
||||
|
||||
hg up -qC 0
|
||||
hg copy --after --force foo bar
|
||||
hg copy foo baz
|
||||
hg ci -m 'make bar and baz copies of foo' -d '1 0'
|
||||
|
||||
hg merge
|
||||
hg ci -m 'merge local copy' -d '2 0'
|
||||
|
||||
hg up -C 1
|
||||
hg merge 2
|
||||
hg ci -m 'merge remote copy' -d '3 0'
|
||||
|
||||
cd ..
|
||||
hg convert --datesort orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
|
||||
cd new
|
||||
hg out ../orig
|
||||
|
||||
true
|
19
tests/test-convert-hg-source.out
Normal file
19
tests/test-convert-hg-source.out
Normal file
@ -0,0 +1,19 @@
|
||||
merging baz and foo
|
||||
1 files updated, 1 files merged, 0 files removed, 0 files unresolved
|
||||
(branch merge, don't forget to commit)
|
||||
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
||||
merging foo and baz
|
||||
1 files updated, 1 files merged, 0 files removed, 0 files unresolved
|
||||
(branch merge, don't forget to commit)
|
||||
initializing destination new repository
|
||||
scanning source...
|
||||
sorting...
|
||||
converting...
|
||||
4 add foo bar
|
||||
3 change foo
|
||||
2 make bar and baz copies of foo
|
||||
1 merge local copy
|
||||
0 merge remote copy
|
||||
comparing with ../orig
|
||||
searching for changes
|
||||
no changes found
|
Loading…
Reference in New Issue
Block a user