Commit Graph

881 Commits

Author SHA1 Message Date
Pierre-Yves David
d6705ae83d convert-hg: use localrepo.pull
localrepo.pull is going away. See 88d9d4ec499e for details.
2014-10-03 11:19:25 -05:00
Siddharth Agarwal
f149aa54b6 convert: change default for git rename detection to 50%
This default mirrors the default for 'git diff'. Other commands have slightly
different defaults -- for example, the move/copy detection for 'git blame'
assumes that a hunk is moved if more than 40 alphanumeric characters are the
same, or copied if more than 20 alphanumeric characters are the same. 50% seems
to be the most common default, though.
2014-09-23 14:45:23 -07:00
Siddharth Agarwal
f28296d4ee convert: simplify git.similarity parsing 2014-09-23 14:40:32 -07:00
Siddharth Agarwal
c1d6e28494 convert: add support to find git copies from all files in the working copy
I couldn't think of a better name for this option, so I stole the Git one in
the hope that anyone converting a Git repo knows what it means.
2014-09-12 12:28:30 -07:00
Siddharth Agarwal
476da59ea2 convert: add support to detect git renames and copies
Git is fairly unique among VCSes in that it doesn't record copies and renames,
instead choosing to detect them on the fly. Since Mercurial expects copies and
renames to be recorded, it can be valuable to preserve this history while
converting a Git repository to Mercurial. This patch adds a new convert option,
called 'convert.git.similarity', which determines how similar files must be to
be treated as renames or copies.
2014-09-12 11:23:26 -07:00
Siddharth Agarwal
cff27af0c6 convert: for git, factor out code to add entries to a separate function
We're going to call this for multiple files in one iteration in upcoming
patches.
2014-09-11 23:57:49 -07:00
Siddharth Agarwal
02fa27546c convert: for git's getchanges, always split entry line into components
We always need to know whether the entry is a rename or copy, so split it up
unconditionally.
2014-09-11 23:37:47 -07:00
Siddharth Agarwal
1ab3d98437 convert: for git's getchanges, use explicit index for iteration
Upcoming patches will add support for copies and renames, for which we'll need
to access multiple lines of the difftree output at once.
2014-09-11 23:35:19 -07:00
Siddharth Agarwal
1a1fc7e9e2 convert: add initial docs for git sources
Upcoming patches will add config options for git sources. This patch adds a
place to document them.
2014-09-12 10:17:56 -07:00
Augie Fackler
88def43f03 convert: enable deterministic conversion progress bar for svn
This produces slightly bad results when branches are in play, but
overall I think it's probably worthwhile. We might be able to do
better with branches somehow, but I haven't given it any thought.
2014-09-10 10:52:00 -04:00
Augie Fackler
8997a30abc convert: enable deterministic conversion progress bar for git 2014-09-10 10:51:46 -04:00
Augie Fackler
9f56b0fdbf convert: add support for deterministic progress bar on scanning phase
This makes it possible to estimate how long the "scanning source"
phase will take, if the specified source repo type supports a quick
"how many changes" check.
2014-05-26 11:53:12 -04:00
Mads Kiilerich
a390d842c5 convert: don't use multi-argument set.update
Mumble mumble 2.4 mumble.
2014-08-31 11:11:42 +02:00
Mads Kiilerich
0df22182cc convert: introduce --full for converting all files
Convert will normally only process files that were changed in a source
revision, apply the filemap, and record it has a change in the target
repository. (If it ends up not really changing anything, nothing changes.)

That means that _if_ the filemap is changed before continuing an incremental
convert, the change will only kick in when the files it affects are modified in
a source revision and thus processed.

With --full, convert will make a full conversion every time and process
all files in the source repo and remove target repo files that shouldn't be
there. Filemap changes will thus kick in on the first converted revision, no
matter what is changed.

This flag should in most cases not make any difference but will make convert
significantly slower.

Other names has been considered for this feature, such as "resync", "sync",
"checkunmodified", "all" or "allfiles", but I found that they were less obvious
and required more explanation than "full" and were harder to describe
consistently.
2014-08-26 22:03:32 +02:00
Mads Kiilerich
49ef1c4045 convert: refactor hg getchanges and caching 2014-08-26 22:03:32 +02:00
Mads Kiilerich
89154d8277 convert: refactor subversion getchanges and caching 2014-08-26 22:03:32 +02:00
Mads Kiilerich
667168e1ac convert: remove incorrect and unused handling of removed svn directories
Since it was introduced in 670e8681d92a, tidy_dirs has been comparing
the result of os.listdir with a string - which never can be true.
Convert apparently works anyway and there is no test coverage of it.

It also seems like it could make a bigger difference on older svn versions but
is less relevant with more recent versions.

Instead of trying to fix the code, we take the low risk option and remove it.
2014-08-26 22:03:32 +02:00
Mads Kiilerich
4dd236da3f convert: use None value for missing files instead of overloading IOError
The internal API used IOError to indicate that a file should be marked as
removed.

There is some correlation between IOError (especially with ENOENT) and files
that should be removed, but using IOErrors to represent file removal internally
required some hacks.

Instead, use the value None to indicate that the file not is present.

Before, spurious IO errors could cause commits that silently removed files.
They will now be reported like all other IO errors so the root cause can be
fixed.
2014-08-26 22:03:32 +02:00
Mads Kiilerich
e911f62a34 convert: p4: ignore purged files with p4d 2012.2 and later
Perforce has the concept of "+Sn" files where only the last revisions of the
file is stored. In p4d 2012.1 old purged revisions were not included in the
"manifest". With 2012.2 they started being included and convert's getfile
failed to recognize the "purged" flag and saw it as an empty file. That made
test-convert-p4-filetypes.t fail.

There is no point in storing an empty file as placeholder for a purged file so
we restore the old behaviour by checking the flag and letting getfile consider
purged files deleted.

(It is questionable whether it makes sense to convert not-yet-purged +S files
to mercurial ... but that is another question.)
2014-08-25 03:27:51 +02:00
Augie Fackler
1797298fcf cvsps: add two more tiebreakers in cscmp
test-convert-cvs.t has been a little flaky for a while now. Add an
extra tiebreaker in cscmp so that all the cases in the test will sort
reliably.

Without this patch, test-convert-cvs.t failed after 346 runs. With
this patch, I stopped trying to get it to fail after 615 runs. While
not conclusive, that makes me pretty optimistic that this is a working
fix.
2014-08-21 10:07:30 -04:00
Mads Kiilerich
3947517b04 cleanup: remove some unused / duplicate imports 2014-08-15 04:37:45 +02:00
Mads Kiilerich
b778f12731 cleanup: fix some list comprehension redefinitions of existing vars
In all the remaining cases the comprehension variable is used for the same
thing as a previous loop variable.

This will mute some pyflakes "list comprehension redefines" warnings.
2014-08-15 04:37:46 +02:00
FUJIWARA Katsunori
413d1be801 convert: fix argument mismatch at formatting the abort message
This patch fixes argument mismatch at formatting the abort message,
introduced by dcf325a55d85: the last '%s' doesn't have corresponded
argument.

This patch uses "unexpected size" in the abort message, to distinguish
the reason of failure from "unexpected type" failure checked in the
prior code path below:

        if info[1] != type:
            raise util.Abort(_('cannot read %r object at %s') % (type, rev))
2014-08-01 02:14:24 +09:00
Matt Mackall
5fc8526562 merge with stable 2014-07-14 18:53:03 -05:00
FUJIWARA Katsunori
8ae5e732ec convert: detect removal of ".gitmodules" at git source revisions correctly
Before this patch, all operations applied on ".gitmodules" at git
source revisions are treated as modification, even if they are
actually removal of it.

If removal of ".gitmodules" is treated as modification unexpectedly,
"hg convert" is aborted by the exception raised in
"retrievegitmodules()" for ".gitmodules" at the git source revision
removing it, because that revision doesn't have any information of
".gitmodules".

This patch detects removal of ".gitmodules" at git source revisions
correctly.

If ".gitmodules" is removed at the git source revision, this patch
records "hex(nullid)" as the contents hash value for ".hgsub" and
".hgsubstate" at the destination revision.

This patch makes "getfile()" raise IOError also for ".hgstatus" and
".hgsubstate" if the contents hash value is "hex(nullid)", and this
tells removal of ".hgstatus" and ".hgsubstate" at the destination
revision to "localrepository.commitctx()" correctly.

For files other than ".hgstatus" and ".hgsubstate", checking the
contents hash value in "getfile()" may be redundant, because
"catfile()" for them also does so.

But this patch chooses writing it only once at the beginning of
"getfile()", to avoid writing same code twice both for ".hgsub" and
".hgsubstate" separately.
2014-07-14 23:33:59 +09:00
Matt Mackall
2ec4f75e9f p4: accept changesets with no description (issue4282) 2014-06-16 12:04:48 -05:00
Gregory Szorc
5914154230 convert: define norepo in command decorator 2014-05-04 22:02:25 -07:00
Matt Harbison
91d5edadd1 convert: update the transplant, rebase and graft references in 'extra'
This change allows the origin() and destination() revsets to yield the same
results in the new and old repos after a conversion.  Previously, nothing would
be listed for queries in the new repo.

Like the SHA1 updates to the commit messages, this is only operational when the
'convert.hg.saverev=True' option is specified.  If the old reference cannot be
found, it is left as-is.  It seems slightly better to leave stale evidence of
the graft/transplant/rebase than to eliminate it entirely.
2014-06-11 22:19:29 -04:00
Matt Mackall
f3b0b8e4bb merge with stable 2014-06-18 20:59:36 -05:00
Sean Farley
1002b6c612 memfilectx: call super.__init__ instead of duplicating code
This patch changes the calling signature of memfilectx's __init__ to fall in
line with the other file contexts.

Calling code and tests have been updated accordingly.
2013-08-15 16:49:27 -05:00
Mads Kiilerich
d218c1aced convert: only consider shamap revisions converted if they still exists
Rollback or strip could leave a Mercurial repo with a shamap with revisions no
longer in the repository.

To ensure reliable conversions we now check that the commit actually exists and
consider it non-existing if it doesn't exist.
2014-05-19 22:12:31 +02:00
Mads Kiilerich
9d7774aea3 convert: introduce hascommitfrommap sink method
Mercurial has stable revision identifiers and rollback and strip. Revisions
referenced in the shamap are thus not necessarily still present but we can
easily check for it.

Subversion do not have stable identifiers and no rollback or strip(?). We must
thus assume that all revisions referenced from a shamap still must be present.

This method is similar to hascommitforsplicemap but different ...
2014-05-19 22:12:30 +02:00
Mads Kiilerich
a9f54d8782 convert: rename sink hascommit to hascommitforsplicemap
The name 'hascommit' sounds like something generic ... but it might
also throw exceptions in specific cases and it is thus (apparently)
only useful for splicemap.
2014-05-19 22:11:14 +02:00
David Schleimer
ab695e13b2 convert: drastically speed up git conversions
We would formerly exec git cat-file once for every commit, plus once for
every tree and file we wnated to read.  This switches to using git
cat-file's batch mode, which is much, much, much faster.

Using this new code, converting the git git repo to hg ran in 106
minutes on my machine.  Using the stock mercurial, it required 1239
minutes.  I believe this to be typical of the speedups we will see
form this patch.
2014-05-27 21:12:24 -07:00
Mads Kiilerich
f92d923209 convert: backout 41e062383fc9 and 80f42131aca3 -closemap
Closemap solves a very specific use case. It would be better to have a more
generic solution than to have to maintain this forever.

Closemap has not been released yet and removing it now will not break any
backward compatibility contract.

There is no test coverage for closemap but it seems like the same can be
achieved with a simple and much more powerful custom extension:

import hgext.convert.hg
class source(hgext.convert.hg.mercurial_source):
    def getcommit(self, rev):
        c = super(source, self).getcommit(rev)
        if rev in ['''
d643f67092ff123f6a192d52f12e7d123dae229f
3a6a38229d418ba09cb7784c01453a93b4d363f8
facceca31c18f7ef800977055dbcbd7fcb5c5cb2
''']:
            c.extra = c.extra.copy()
            c.extra['close'] = '1'
        return c
hgext.convert.hg.mercurial_source = source
2014-04-16 01:10:08 +02:00
Mads Kiilerich
46b435b7d3 convert: backout 8a62813ea220 and ca6679798c95 - tagmap
Tagmap solves a very specific use case. It would be better to have a more
generic solution than to have to maintain this forever.

Tagmap has not been released yet and removing it now will not break any
backward compatibility contract.

There is no test coverage for tagmap but it seems like the same can be achieved
with a (relatively) simple and much more powerful custom extension:

import hgext.convert.hg
def f(tag):
    return tag.replace('some', 'other')
class source(hgext.convert.hg.mercurial_source):
    def gettags(self):
        return dict((f(tag), node)
                    for tag, node in in super(source, self).gettags().items())
    def getfile(self, name, rev):
        data, flags = super(source, self).getfile(name, rev)
        if name == '.hgtags':
            data = ''.join(l[:41] + f(l[41:]) + '\n' for l in data.splitlines())
        return data, flags
hgext.convert.hg.mercurial_source = source
2014-04-16 01:09:49 +02:00
Mads Kiilerich
0e8795ccd6 spelling: fixes from spell checker 2014-04-13 19:01:00 +02:00
Matt Mackall
9ca3ee752a merge with stable 2014-03-19 16:21:53 -05:00
Mads Kiilerich
f6b400481f convert: more clear documentation of the 'include' default of a 'include .'
At first glance it can be confusing that adding a superfluous include directive
will exclude more files.
2014-03-19 00:19:54 +01:00
lstewart
7eb5e89201 convert: use branchmap to change default branch in destination (issue3469)
The fix for issue2653 broke the ability to map the default branch of a source
repository to a non-default named branch in the destination repository.  Leave
the default behaviour as is, but allow the branch name "None" to be used to map
to a non-default named branch in the destination repository.
2014-01-28 14:00:23 +11:00
Mads Kiilerich
673ec76229 convert: secret config option for disabling debugsvnlog
Subversion issues involving svn log such as 1e493b49245f can be tricky to
debug when it is run in an 'hg debugsvnlog' sub process. Debugging is simpler
when convert only uses one process.

With this change convert will invoke the svn log directly when setting
  [convert]
  svn.debugsvnlog = False

This is intentionally not documented.
2014-02-07 17:29:37 +01:00
Mads Kiilerich
17aeb0d9e4 convert: make subversion revsplit more stable when meeting revisions without @
revsplit would crash for instance if given a subversion string without @ ...
and that could somehow happen when playing around with convert.
2014-02-07 17:28:37 +01:00
Mads Kiilerich
c9112a6b7a convert: drop unused getheads from sinks 2014-02-07 17:26:28 +01:00
Mads Kiilerich
3af50396f2 convert: mercurial source: convert global tags only - not local tags
Mercurial tags can be local (tag -l, stored in .hg/localtags) or global (normal
tags, tracked in .hgtags) ... or extensions can add other kind of tags.

Convert would take all tags (except "tip"), not just the ones from .hgtags, and
put them into .hgtags.

Instead, convert only the global tags that come from .hgtags.
2014-05-16 02:30:27 +02:00
Sean Farley
6aefcf4449 convert: add tagmap option
Tests have been updated.
2014-01-22 15:43:21 -06:00
Sean Farley
a624daee33 convert: add tagmap logic
Previously, there was no way to rewrite tags on the fly while converting. Now,
we add similar logic to branchmap to provide a way to map old tags to new tags.

Currently, this is not enabled since there is not yet a command-line option.
2014-01-22 15:40:17 -06:00
Sean Farley
53fd264a21 convert: avoid updating tags when there is nothing new
Previously, when converting from a mercurial repo there would be an extraneous
commit at the end of the convert process that would rewrite tags. Now, we check
if there are any new tags before doing this rewriting.
2014-01-22 15:31:24 -06:00
Sean Farley
3c22b1037d convert: compare tags from all heads instead of just one
Previously, the hg sink for puttags would just use one head for getting the old
tags which would sometimes lead to tags disappearing. Now, we iterate over all
heads and merge the results.
2014-01-22 17:38:05 -06:00
Sean Farley
e7a8a8092c convert: add closemap option
Tests have been updated.
2014-01-21 11:35:17 -06:00
Sean Farley
5507a20bc9 convert: add parseclosemap method
This is a copy of the parsesplicemap method and will serve as a way to specify
which changesets to close while converting.
2014-01-21 11:20:14 -06:00