Commit Graph

1057 Commits

Author SHA1 Message Date
Eugene Baranov
65bf9615dd convert: handle deleted files when converting from Perforce (issue4743) 2015-07-03 18:10:58 +01:00
Matt Mackall
1899eff59c convert: properly pass null ids through .hgtags (issue4678)
Mercurial uses tags of null to mark deletions, but convert was
silently discarding these because it had no mapping for them. Thus, it
was resurrecting deleted tags.
2015-05-27 14:28:29 -05:00
Matt Mackall
d238a66611 convert: avoid traceback in subversion sink
We've had a couple reports of subversion tracebacks that trigger when
the parents list is empty, and thus block showing what the commit
failure was on the next two lines.
2015-04-27 11:11:26 -05:00
Durham Goode
e31e5da384 convert: add config option for disabling ancestor parent checks
When converting merge commits, convert checks if any of the parents are
ancestors of any of the other parents. To do this, it builds an ancestor list
for every commit in the repository. On large repos this can take a long time
(30min+). Let's add an option for disabling this check to preserve performance.

The downside of this is that it may create unnecessary parent connections when
enabled (which is unfortunate, but not incorrect).

To verify, I ran the convert tests with the flag enabled, and verified the graph
changes were all just to add new parents that were ancestors of existing
parents.
2015-06-29 13:44:24 -07:00
Durham Goode
d70241d991 convert: add config to not convert tags
In some cases we do not want to convert tags from the source repo to be tags in
the target repo (for instance, in a large repository, hgtags cause scaling
issues so we want to avoid them). This adds a config option to disable
converting tags.
2015-06-29 13:40:20 -07:00
Durham Goode
bc1c03c315 convert: improve support for unusual .gitmodules
Previously convert would throw an exception if it encountered a git commit with
a .gitmodules file that was malformed (i.e. was missing, but had submodule
files, or was malformed).

Instead of breaking the convert entirely, let's print error messages and move
on.
2015-06-29 17:19:58 -07:00
Durham Goode
8785908f11 convert: handle .gitmodules with non-tab whitespaces
The old implementation assumed .gitmodules file lines always began
with tabs. It can be any whitespace, so lets trim the lines
appropriately.
2015-06-29 17:19:18 -07:00
Durham Goode
782f192338 convert: fix bug with converting the same commit twice
Convert had a bug where it relied on repo.tip() to be the newly committed
commit. This was not the case if the commit already existed in the repository
(since repo.commitctx() did nothing, the tip() referenced some random other
commit and the revmap got corrupted).

This fixes it by using the node returned by repo.commitctx().
2015-06-29 13:39:05 -07:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Gregory Szorc
3aa1c73868 global: mass rewrite to use modern octal syntax
Python 2.6 introduced a new octal syntax: "0oXXX", replacing "0XXX". The
old syntax is not recognized in Python 3 and will result in a parse
error.

Mass rewrite all instances of the old octal syntax to the new syntax.

This patch was generated by `2to3 -f numliterals -w -n .` and the diff
was selectively recorded to exclude changes to "<N>l" syntax conversion,
which will be handled separately.
2015-06-23 22:30:33 -07:00
Matt Harbison
5776a99bfa convert: update 'intermediate-source' in the destination's extras dictionary 2015-06-15 16:50:31 -04:00
Matt Harbison
5becc4c86f convert: apply the appropriate phases to the destination (issue4165)
If the conversion doesn't change the hash, and the cset is public in the source,
it should be public in the destination.  (This can happen if file remapping is
done that doesn't affect the initial commits.)  This also propagates the secret
phase from the source, regardless of the hash, because presumably the content is
what is secret.  Otherwise, the destination commit stays in the draft phase.

Maybe any draft cset with an unchanged hash should be changed to public, because
it has effectively been shared, but convert pretty strongly implies throwing
away (or at least readonly archiving) the source repo.

The change in the rollback output is because the name of the outer transaction
is now 'convert', which seems more accurate.  Unfortunately, the memctx won't
indicate the hash prior to committing, so the proper phase can't be applied with
the commit.

The repo is already write locked in mercurial_sink.before().
2015-06-14 13:08:11 -04:00
Matt Harbison
a1e5ef1d56 convert: always track the hg source revision in the internal commit object
This will be needed in the next patch to determine if phases need to be
adjusted.  The insertion of the source revision in 'extras{}' is still
controlled by the config property.
2015-06-14 13:04:00 -04:00
Mads Kiilerich
c8659cbb76 convert: optimize convert of files that are unmodified from p2 in merges
Conversion of a merge starts with p1 and re-adds the files that were changed in
the merge or came unmodified from p2. Files that are unmodified from p1 will
thus not be touched and take no time. Files that are unmodified from p2 would be
retrieved and rehashed. They would end up getting the same hash as in p2 and end
up reusing the filelog entry and look like the p1 case ... but it was slow.

Instead, make getchanges also return 'files that are unmodified from p2' so the
sink can reuse the existing p2 entry instead of calling getfile.

Reuse of filelog entries can make a big difference when files are big and with
long revlong chains so they take time to retrieve and hash, or when using an
expensive custom getfile function (think
http://mercurial.selenic.com/wiki/ConvertExtension#Customization with a code
reformatter).

This in combination with changes to reuse filectx entries in
localrepo._filecommit make 'unchanged from p2' almost as fast as 'unchanged
from p1'.

This is so far only implemented for the combination of hg source and hg sink.

This is a refactoring/optimization. It is covered by existing tests and show no
changes - which is a good thing.
2015-03-19 17:40:19 +01:00
Augie Fackler
21638a3adf convert: adjust progress bar for octopus merges (issue4169)
For merges, we walk the files N-1 times, where N is the number of
parents. This means that for an octopus merge with 3 parents and 2
changed files, we actually fetch 6 files. This corrects the progress
output of the convert command when such commits are encountered.
2015-03-12 21:41:50 -04:00
Jordi Gutiérrez Hermoso
8eb132f5ea style: kill ersatz if-else ternary operators
Although Python supports `X = Y if COND else Z`, this was only
introduced in Python 2.5. Since we have to support Python 2.4, it was
a very common thing to write instead `X = COND and Y or Z`, which is a
bit obscure at a glance. It requires some intricate knowledge of
Python to understand how to parse these one-liners.

We change instead all of these one-liners to 4-liners. This was
executed with the following perlism:

    find -name "*.py" -exec perl -pi -e 's,(\s*)([\.\w]+) = \(?(\S+)\s+and\s+(\S*)\)?\s+or\s+(\S*)$,$1if $3:\n$1    $2 = $4\n$1else:\n$1    $2 = $5,' {} \;

I tweaked the following cases from the automatic Perl output:

    prev = (parents and parents[0]) or nullid
    port = (use_ssl and 443 or 80)
    cwd = (pats and repo.getcwd()) or ''
    rename = fctx and webutil.renamelink(fctx) or []
    ctx = fctx and fctx or ctx
    self.base = (mapfile and os.path.dirname(mapfile)) or ''

I also added some newlines wherever they seemd appropriate for readability

There are probably a few ersatz ternary operators still in the code
somewhere, lurking away from the power of a simple regex.
2015-03-13 17:00:06 -04:00
Augie Fackler
087f03a71a cvsps: use a different tiebreaker to avoid flaky test
After adding some sneaky debug printing[0], I determined that this
test flaked when a CVS commit containing two files starts too close to
the end of a second, thus putting file "a" in one second and "b/c" in
the following second. The secondary sort key meant that these changes
sorted in a different order when the timestamps were different than
they did when they matched. As far as I can tell, CVS walks through
the files in a stable order, so by sorting on the filenames in cvsps
we'll get stable output. It's fine for us to switch from sorting on
the branchpoint as a secondary key because this was already the point
when we didn't care, and we're just trying to break ties in a stable
way. It's unclear to be if having the branchpoint present matters
anymore, but it doesn't really hurt to leave it.

With this change in place, I was able to run test-convert-cvs over 650
times in a row without a failure.  test-convert-cvcs-synthetic.t
appears to still be flaky, but I don't think it's *worse* than it was
before - just not better (I observed one flaky failure in 200 runs on
that test).

0: The helpful debug hack ended up being this, in case it's useful to
future flaky test assassins:

 --- a/hgext/convert/cvsps.py
 +++ b/hgext/convert/cvsps.py
 @@ -854,6 +854,8 @@ def debugcvsps(ui, *args, **opts):
              ui.write(('Branch: %s\n' % (cs.branch or 'HEAD')))
              ui.write(('Tag%s: %s \n' % (['', 's'][len(cs.tags) > 1],
                                    ','.join(cs.tags) or '(none)')))
 +            if cs.comment == 'ci1' and (cs.id == 6) == bool(cs.branchpoints):
 +                ui.write('raw timestamp %r\n' % (cs.date,))
              if cs.branchpoints:
                  ui.write(('Branchpoints: %s \n') %
                           ', '.join(sorted(cs.branchpoints)))
2015-03-13 14:20:13 -04:00
Mads Kiilerich
eedb4882ea convert: when converting from monotone, use the number 1 for close in extras
Monotone used '1' for close while core Mercurial use 1. Now, for consistency,
use the same value everywhere. It will be stored as a string anyway and the
change will not make any real difference.

(The actual value of 'close' doesn't matter as long as extras has such a key.)
2015-01-21 00:02:17 +01:00
Mads Kiilerich
dddf142726 convert: replace revision references in messages if they are >= short hashes
Convert will try to find references to revisions in commit messages and replace
them with references to the converted revision. It will take any string that
looks like a hash (and thus also decimal numbers) and look it up in the source
repo. If it finds anything, it will use that in the commit message instead.

It would do that for all hex digit sequences of 6 to 40 characters. That was
usually no problem for small repos where it was unlikely that there would be a
matching 6 'digit' hash prefix. It was also no problem on repos with less than
100000 changesets where numbers with 6 or more digits not would match any
revision number. With more than 100000 revisions random numbers in commit
messages would be replaced with a "random" hash. For example, 'handle 100000
requests' would be changed to to 'handle 9117c6 requests'. Convert could thus
not really be used on real repositories with more than 100000 changesets.

The default hash length shown by Mercurial is 12 'digits'. It is unexpected and
unwanted that convert by default tries to replace revision references that use
less than that amount of 'digits'.

To fix this, don't match strings that are less than the default hash size of 12
characters.
2015-01-30 18:51:20 +01:00
Matt Harbison
b0bba90545 convert: handle LookupError in mercurial_source.lookuprev()
This is in line with the documentation on the base class method, and is related
to issue4496 (but doesn't fix the reporter's problem of not mangling other data
that matches a revision pattern).  Now instead of aborting when there is an
ambiguous source rev, it simply won't update the commit comment.  A warning
message might be nice, but a None return masks whether the problem was no
matching revision, or more than one.

The only other caller of this is the logic that converts tags, but those are
never ambiguous since they are always 40 characters.

A test isn't feasible because there simply aren't enough commits in the test
suite repos to have an ambiguous identifier that is at least 6 characters long,
and it would be too easy for the ambiguity to disappear when unrelated changes
are made.  Instead, I simply ran 'hg --traceback log -r c' on the hg repo, and
handled the error it threw.
2015-01-18 22:21:53 -05:00
Augie Fackler
513b14b586 convert: on svn failure, note libsvn version (issue4043)
We have our own fast-path logic to see if something passes a sniff
test for being a Subversion repository, but it's possible for a user
to svnsync a repo using svn 1.8 and then use svn 1.7 bindings (as in
the bug) to try and convert the repo. If we at least tell the user the
version of libsvn that we used, they might get enough of a hint to
check on their own for format incompatibilities between their
svn{admin,sync} and the libsvn used by hg.
2014-12-12 15:53:17 -05:00
Matt Harbison
ff48d6b214 convert: support incremental conversion with hg subrepos
This was implied in issue3486, which specifically asked for subrepo support in
lfconvert.  Now that lfconvert uses the convert extension internally when going
to normal files, the issue is half fixed.  But now even non largefile repos
benefit when other transformations are needed.

Supporting a full subrepo tree conversion from a single command doesn't seem
reasonable, given the number of options that can be provided, and the
transformations that would need to occur when entering a subrepo (consider
'filemap' paths).  Instead, this allows the user to incrementally convert each
hg subrepo from bottom up like so:

  # so convert knows the dest type when it sees a non empty dest dir
  $ hg init converted

  $ hg convert orig/sub1 converted/sub1
  $ hg convert orig/sub2 converted/sub2
  $ hg convert orig converted

This allows different options to be applied to different subrepos more readily.
It assumes the shamap is in the default location in each converted subrepo for
simplicity.  It also allows for a subrepo to be cloned into place, in case _it_
doesn't need a conversion.  I was able to convert away from using
largefiles/bfiles in several subrepos with this mechanism.
2015-05-29 13:25:34 -04:00
Matt Mackall
06433f790f merge with stable 2015-05-28 16:09:42 -05:00
Augie Fackler
f95a6caba1 extensions: document that testedwith = 'internal' is special
Extension authors (notably at companies using hg) have been
cargo-culting the `testedwith = 'internal'` bit from hg's own
extensions, which then defeats our "file bugs over here" logic in
dispatch. Let's be more aggressive about trying to give extension
authors a hint about what testedwith should say.
2015-04-28 16:44:37 -04:00
Augie Fackler
a5b17bd9d1 cleanup: use __builtins__.any instead of util.any
any() is available in all Python versions we support now.
2015-05-16 14:30:07 -04:00
Thomas Arendsen Hein
64014abd9c convert: use git diff-tree -Cn% instead of --find-copies=n% for older git
The option --find-copies was added in a later git version than the one included
in Debian squeeze-lts (1.7.2.5), probably around 1.7.4.
2014-11-06 09:36:39 +01:00
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
Sean Farley
4b88fb7766 convert: add mapname parameter to checkrevformat
Upcoming patches will add new map files so we change the calling sequence of
checkrevformat so that error messages will let the user know which file has the
wrong rev format.
2014-01-21 11:34:55 -06:00
Sean Farley
dac1309a34 convert: replace old sha1s in the description
This is a simple find-and-replace strategy for matching anything in the
old description of a converted commit and, if that matched sha1 exists
in the mapping, replacing it with the new sha1.

In particular, this is helpful for descriptions that contain tags with
messages such as, "Added tag 1.0 for commit abcde1234567" which will now
be automatically converted.

Tests have been updated accordingly.
2013-04-18 10:05:50 -05:00
Augie Fackler
39437ca6fb Merge with stable. 2013-11-17 17:49:48 -05:00
Mads Kiilerich
71f30fd22f convert: fix svn crash when svn.ra.get_log calls back with orig_paths=None
get_log started calling back with orig_paths=None on Fedora 20 with
subversion-1.8.3. That broke test-convert-svn-source.t .

There used to be some handling of that situation until d17c619e40d5 apparently
broke it. This patch restores what seems to be the most obvious handling of the
situation.
2013-11-16 19:56:30 -05:00
Mads Kiilerich
b0ab086db9 convert: readability and test of rpairs function 2013-11-17 11:18:39 -05:00
Mads Kiilerich
749d4329a5 convert: update source shamap when using filemap, just as when not using filemap
The reverse mapping was introduced in 51f9f23e6ccc to make roundtrip
conversions possible ... but it did not work when using filemap.

Roundtrips with filemaps will of course only work flawlessly if inverse
mappings are used.

Especially, if a lossy convert mapping is used in one direction, then only
linear lines of development can be converted in the other direction. With this
constraint convert will do the right thing by assuming that excluded files
haven't been changed.)

A test case with general coverage of hg-hg roundtrips with filemap is added.

(There a cases where adding records of converted revisions to the shamap in the
source repository doesn't work - especially when converting the same repo to
several other repos and back. It would arguably be better if convert only
updated the shamaps in the target repo but read shamaps from both the source
and and target repo ... but that is a different story. Making the stuff we have
work consistently is step forward no matter what.)
2013-10-03 18:01:21 +02:00
Mads Kiilerich
1692899d8d convert: introduce hg.revs to replace hg.startrev and --rev with a revset
The existing knobs for controlling which revisions to convert were often
insufficient. Revsets is a shiny hammer that provides a better solution.

Revsets has been introduced in --rev handling in a lot of other places while
being more or less backwards compatible. Doing the same here would be a much
more elegant ... but that would unfortunately not work in this case.  "--rev 7"
used to mean revision 0 to 7 - it would be an unacceptable change if it
suddenly just meant revision 7.

Instead we introduce a new configuration setting. It will only work for
Mercurial repositories so adding a new commandline option for it would not be a
nice solution.

There is no way to use the fancy deprecation markup for configuration settings
so we just remove the documentation of hg.startrev.
2013-07-20 00:43:08 +02:00
Mads Kiilerich
b4c87902d8 convert: refactor head calculation for hg sources 2013-10-03 18:01:21 +02:00
Mads Kiilerich
8157f844e6 convert: remove unused and incorrect default handling for revmapfile
destc is not a string and can thus not be os.path.join'ed. Convert would crash
if we ended up there ... but we wouldn't because both the sinks (hg and
subversion) sinks implement .revmapfile and "never" throws exceptions.
2013-07-19 14:20:11 +02:00
Mads Kiilerich
29b14aad65 convert: fix description of 'convert --rev' 2013-07-19 02:32:36 +02:00
Mads Kiilerich
15460985a6 convert: fix crash when existing converted revision didn't come from source
This case can happen when converting from multiple repositories with filemap.
2013-10-02 19:46:48 +02:00
Mads Kiilerich
329d4ea1f9 convert: fix crash when filemap filtering is changed 2013-10-02 19:46:47 +02:00
Augie Fackler
aeb89622cb convert: move import of xml.minidom.dom to its own line for check-code 2013-09-20 10:15:23 -04:00
Frank Kingswood
cded2790ad convert: handle changeset sorting errors without traceback (issue3961) 2013-07-26 14:44:13 +01:00
Matt Mackall
a65a9a8446 convert: catch empty origpaths in svn gettags (issue3941) 2013-07-19 16:45:44 -05:00
Mads Kiilerich
e49b0f2e4b convert: fix bad conversion of copies when hg.startrev is specified
The 'copynode' was looked up in self.keep as if it was a changeset node. It is
however a filelog node, and self.keep would thus fail if it actually looked at
its parameter ... which it only did if a startrev was specified.

Instead we now don't check the copy node - we don't have to. It must have been
copied from one of the parents, and we already check whether one of the parents
have the copy source.

We could perhaps use linkrev to see if the corresponding changeset was
converted ... but that would sometimes be wrong.

The existing test of this was wrong - now it is better, but it seems like it
exposes a 'log' issue.
2013-07-19 01:40:57 +02:00
Szymon Wroblewski
f07e68437b splicemap: support paths with spaces in splicemap (issue3844)
Shlex module was used to split line as suggested. Split operates in POSIX mode.
2013-05-08 20:55:56 +02:00
Matt Mackall
0f25695305 merge with stable 2013-05-05 18:51:34 -05:00
Blesso hrvoje1212@gmail.com
36f0d7039a convert: fix bug of wrong CVS path parsing without port number (issue3678)
The cvsps.py:getrepopath suffers from a string parsing bug (it returns
"user@server/path/to/repository" if the CVSROOT is given like this:
":pserver:user@server/path/to/repository" ), which gives returnes the wrong
value becouse cvsps.py fails to strip the prefix from filenames.
With this patch for the same input we get the correct repo path that is:
"/path/to/repository"
2013-05-03 19:34:59 +02:00
Ben Goswami
bf2e9422e6 splicemap: improve error handling when source is subversion (issue2084)
Implemented error handling on splicemap file when source is
subversion (This checks are similar to when source is hg or git).

The revision string is expected to be of svn:<uuid><path>@<number>
format.

the test case has been enhanced to check this format.
2013-04-25 18:01:00 -07:00
Ben Goswami
d334de37cd splicemap: improve error handling when source is git (issue2084)
Implemented similar error handling that is done for hg in an earlier revision.
These are:
   a. add checking for splicemap file format
   b. add checking for each revision string formats
2013-04-25 16:02:58 -07:00
Ben Goswami
8afeeb7248 splicemap: improve error handling when source is hg (issue2084)
1. Introduced 2 levels of error handling for splicemap files
   a. Check the splicemap file for rules which are same across different
      types of source repos.  This is done through enhancing parsesplicemap
      function
   b. Check revision string formats.  Each repo may have their own format.
      This is done usign checkrevformat function
   c. Implemented the above two for hg
2013-04-25 11:50:26 -07:00
Ben Goswami
e47f0885b5 splicemap: move parsesplicemap to convcmd.py (issue2084)
parsesplicemap is only referenced from convcmd.py
This move is necessary to enable other changes related to
this issue
2013-04-24 18:26:37 -07:00
Constantine Linnick
4d22c22a01 convert: add closesort algorithm to mercurial sources
If you actively work with branches, sometimes you need to close old branches
which last commited hundreds revisions ago. After close you will see long
lines in graph visually spoiling history. This sort only moves closed
revisions as close as possible to parents and does not increase storage size
as datesort do.
2013-03-24 00:06:52 +07:00
Matt Mackall
ce5cc60bf7 convert: stabilize cvsps commitid sort order 2013-02-22 16:40:27 -06:00
Augie Fackler
5c8acaf5b4 git convert: some versions of git use fatal: instead of error:
I saw this behavior with git 1.7.12 on my Mac.
2013-02-08 07:09:48 -06:00
Ross Lagerwall
cb8603510f convert/git: catch errors from modern git-ls-remote (issue3428)
Since git v1.7.8.2-327-g926f1dd (the change was first released in git
1.7.10), git does not return non-zero when "git ls-remote --tags ..."
is run and the repository is damaged. This causes the "damaged
repository with missing commit" test in test-convert-git.t to
unexpectedly succeed.

Fix by aborting if git outputs any lines beginning with "error:",
which required adding some subprocess use in convert/git.py.
2013-02-08 08:02:57 -06:00
Mads Kiilerich
65e8a6dd50 convert: make toposort order stable when multiple orderings are possible
The output of some tests are changed. Not necessarily to the better, just other
valid permutations.
2012-12-13 23:15:51 +01:00
Mads Kiilerich
41b6d5130f convert: report cvsps branchpoints sorted 2013-01-15 02:59:14 +01:00
Mads Kiilerich
0e2ceeaa5d convert: process subversion branch in a sorted order 2013-01-15 02:59:14 +01:00
Mads Kiilerich
527f4a6941 convert: process missing branches in sorted order 2013-01-15 02:59:14 +01:00
Mads Kiilerich
52b725744f convert: process splicemap in sorted order 2013-01-15 02:59:14 +01:00
Kevin Bullock
bd7b56e105 merge with stable 2013-01-14 10:17:06 -06:00
FUJIWARA Katsunori
9fd6562bca convert: correct 'hooks' section name in online help
The section name for hooks is not 'hook', but 'hooks'.
2013-01-14 23:14:45 +09:00
Idan Kamara
547e15c84f cvsps: fix indentation 2013-01-09 21:11:00 +02:00
Bryan O'Sullivan
7b68f267c0 convert: fix most test-check-code-hg violations in cvsps code 2013-01-08 16:26:52 -08:00
Frank Kingswood
41de1ef081 cvsps: use commitids (when present) to detect changesets
Simplify core logic by no longer attempting to work around missing
class attributes. Instead always generate the attributes and ignore
the cache if the attributes are missing
2013-01-08 20:11:20 +00:00
Julian Cowley
15e470ce7f convert: add config option to use the local time zone
The default for the time zone offset in a converted changeset has
always been 0 (UTC).  With this patch, the converted changeset is
modified so that the local offset from UTC is specified as the time
zone offset.

The option is specified as the boolean convert.localtimezone (default
False).  Example usage:

    hg convert -s cvs --config convert.localtimezone=True example-cvs example-hg

IMPORTANT: the patch only applies to conversions from cvs or svn.
The documentation for the option only appears in those two sections
in the convert help text.
2012-11-18 12:26:50 -10:00
Matt Mackall
fd58e8703f i18n: wrap false positives for translation detection 2012-11-25 13:53:47 -06:00
Bryan O'Sullivan
8f2116535a convert: fix a too-long line nag 2012-11-13 13:09:42 -08:00
YaNan Xu
69a8b90589 convert: add support for converting git submodule (issue3528)
Previously, convert aborted upon encountering a git submodule. This patch
changes it so that it now succeeds. It modifies convert_git to manually generate
'.hgsub' and '.hgsubstate' files for each git revision, so as to convert git sub
modules to non-mercurial subrepositories.
2012-10-29 17:40:13 -07:00
Augie Fackler
9766845689 bookmarks: introduce a bmstore to manage bookmark persistence
Bookmarks persistence still showed a fair amount of its legacy as a
monkeypatching extension. This encapsulates all bookmarks
serialization and parsing in a single class, and offers a single
location where other bookmarks storage engines can be substituted
in. As a result, many files no longer import the bookmarks module,
which strikes me as an encapsulation win.

This doesn't do anything to the current bookmark state yet, but I'm
hoping put that in the bmstore class as well.
2012-11-07 16:21:39 -06:00
Gregory Szorc
624f6f242c convert: declare commands using decorator 2014-05-04 21:17:04 -07:00
Huayang
2cbf7a996c convert: normalize paths in filemaps (issue3612)
convert doesn't normalise double slashes in paths. Path normalization
is applied when a path is loaded into filemap and when a file lookup
request is issued to filemap.
2012-10-05 16:27:34 -07:00
Bryan O'Sullivan
dc9ede17dc Merge spelling fixes 2012-09-11 08:36:09 -07:00
timeless@mozdev.org
f659dfb743 spelling: precede 2012-08-17 13:58:18 -07:00
timeless@mozdev.org
5cab7e44e1 spelling: further 2012-08-17 13:58:18 -07:00
timeless@mozdev.org
0dc2f07fe8 spelling: dependent 2012-08-17 13:58:18 -07:00
timeless@mozdev.org
2a09dc2301 spelling: Explicitly 2012-08-17 13:58:18 -07:00
Bryan O'Sullivan
68bb78ae36 Merge with crew-stable 2012-09-04 13:50:50 -07:00
Mads Kiilerich
520076e707 delete some dead comments and docstrings 2012-08-21 02:41:20 +02:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Ross Lagerwall
661779d660 util: replace util.nulldev with os.devnull
Python since 2.4 has supported os.devnull so having util.nulldev
is unnecessary.
2012-08-04 07:14:40 +02:00
Patrick Mezard
e64291c725 convert: use subprocess for all commandline calls
Avoid mixing popen and subprocess calls, it simplifies the command line
generation and quoting issues with redirections.

In practice, it fixes the subversion sink on Windows and probably helps
with monotone and darcs sources.
2012-08-03 21:37:33 +02:00
Patrick Mezard
2a34f7fc18 convert: make commandline.limit_arglist private, simplify 2012-08-03 21:05:01 +02:00
FUJIWARA Katsunori
0cf97588a4 doc: unify section level between help topics
Some help topics use "-" for the top level underlining section mark,
but "-" is used also for the top level categorization in generated
documents: "hg.1.html", for example.

So, TOC in such documents contain "sections in each topics", too.

This patch changes underlining section mark in some help topics to
unify section level in generated documents.

After this patching, levels of each section marks are:

  level0
  """"""
    level1
    ======
      level2
      ------
        level3
        ......
          level4
          ######

And use of section markers in each documents are:

  - mercurial/help/*.txt can use level1 or more
    (now these use level1 and level2)

  - help for core commands can use level2 or more
    (now these use no section marker)

  - descriptions of extensions can use level2 or more
    (now hgext/acl uses level2)

  - help for commands defined in extension can use level4 or more
    (now "convert" of hgext/convert uses level4)

"Level0" is used as top level categorization only in "doc/hg.1.txt"
and the intermediate file generated by "doc/gendoc.py", so end users
don't see it in "hg help" outoput and so on.
2012-07-25 16:40:38 +09:00
Mads Kiilerich
377db36818 help: fix some instances of 'the the' 2012-07-26 02:54:13 +02:00
Patrick Mezard
dc1b580b83 convert/svn: handle non-local svn destination paths (issue3142)
test-convert-svn-sink.t still pass and I tested pushing to an svn+ssh
repository
2012-07-26 12:07:55 +02:00
Patrick Mezard
97e1660f02 convert: remove unused newnames variable in filemap 2012-07-16 15:50:19 +02:00
Matt Mackall
c0bdd10df1 merge with stable 2012-07-15 14:48:50 -05:00
Wagner Bruna
243b1101bd convert: make filemap renames consistently override revision renames
When the source repository had a revision renaming "$new -> $old",
but the filemap a "$old -> $new" rename, the converted revision could
use either $new (deleting the file) or $old (keeping the file) when
getting the file data, depending on the lexicographical order of
those names. So the resulting revision would leave some files
untouched (as expected), but delete others arbitrarely.
2012-07-06 01:14:02 -03:00
Patrick Mezard
e029e6740d convert: keep branch switching merges with ancestors (issue3340)
When running convert with a filemap, merge parents which are ancestors
of other parents are ignored. This is hardly a problem when parents
belong to the same branch, but the result could be confusing when named
branches are involved. With:

  -o-a1-a2-a3...     <- A
    \           \
     b1-b2-b3...-m-  <- B

If all b* revisions are discarded, it is useful to preserve 'm' even if
it is empty after filtering to record the branch switch.

This patch makes filemap preserve "ancestor parents" if there is no
"non-ancestor parent" on the same branch than the merge revision.

Remarks:
- I am not completely convinced by the reasons given above and those
  detailed by Matt in this thread:

http://selenic.com/pipermail/mercurial-devel/2012-May/040627.html

  The properties we try to preserve are not clearly defined. That said,
  I know this patch already helped someone on IRC and the tests output
  look reasonable.

- This is a new version of the original "convert: filemap must preserve
  fast-forward merges" patch. It has exactly the same output for 2
  parents merges, the additional complexity is here to handle more than
  two parents.
2012-06-18 18:19:28 +02:00
Mads Kiilerich
278667f10c convert: check for failed svn import in debugsvnlog and abort cleanly
'hg debugsvnlog' failed with a crash when using the uninitialized transport in
get_log_child if the import of the svn libraries had failed.

'convert' should never get as far as launching 'hg debugsvnlog' if the svn
libraries are missing, but by launching a subprocess there is risk that the
environment is mangled so the second import fails.

It is in principle also possible to launch the command manually.
2012-06-29 01:51:48 +02:00
Mads Kiilerich
37140b89be convert: accept Subversion 'file:///c%3A/svnrepo' syntax on Windows
Subversion can handle ':' quoted as '%3A' but urllib.url2pathname can't and
Mercurial thus rejected some valid subversions URLs.

This particular case will now be handled by some preprocessing before handing
it over to urllib.url2pathname.

This is tested by a0c992a723f9 when test-convert-svn-source.t and
test-convert-svn-move.t can be run on Windows.
2012-06-28 03:41:37 +02:00
Mads Kiilerich
f9f38dc7f8 convert: ignore svn:executable for subversion targets without exec bit support
Calling propset/propdel with subversion 1.6 on FAT gave
  abort: svn exited with status 256
and made test-convert-hg-svn.t and test-convert-svn-sink.t fail. 1.7 worked.

This is a rework of 5ba59c098f03 but ignores the executable bit when it isn't
supported instead of using an approximation.
2012-06-24 17:06:47 +02:00
Martin Geisler
1eafef5082 convert: lowercase status and abort messages 2012-06-12 14:18:18 +02:00
Bryan O'Sullivan
141bd09daa revlog: descendants(*revs) becomes descendants(revs) (API)
Once again making the API more rational, as with ancestors.
2012-06-01 12:45:16 -07:00
Augie Fackler
96d44b39f7 hgext: mark all first-party extensions as such 2012-05-15 14:37:49 -05:00
Brodie Rao
a706d64a2c cleanup: replace naked excepts with except Exception: ... 2012-05-12 16:02:46 +02:00
Brodie Rao
c577fac135 cleanup: replace naked excepts with more specific ones 2012-05-12 16:02:45 +02:00
Brodie Rao
92158e04de cleanup: "raise SomeException()" -> "raise SomeException" 2012-05-12 16:00:58 +02:00
Brodie Rao
a7ef0a0cc5 cleanup: "not x in y" -> "x not in y" 2012-05-12 16:00:57 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
FUJIWARA Katsunori
91701b5919 i18n: use locale insensitive format for datetimes as intermediate representation (issue3398)
on some non "en" locale environments, "hg convert" is aborted, because
"util.parsedate()" fails.

it fails in "memctx.__init__()" called by "putcommit()" of "convert".

in "hg convert", datetimes gotten from source repository
are usually formatted by "util.datestr()" with default format "%a %b
%d %H:%M:%S %Y %1%2".

but on some environments, "%a" and "%b" may cause locale sensitive
string, and such string may cause parse error in "util.parsedate()".

this path uses "%Y-%m-%d %H:%M:%S %1%2" as intermediate representation
format for datetimes, because it consists only of locale insensitive
elements.

datetimes in above format are only used for passing them from
conversion logic to memctx object, so it doesn't have to be formatted
by locale sensitive one.

this patch just avoids locale sensitivity problem of "datestr()" and
"parsedate()" combintion.
2012-04-26 02:41:20 +09:00
Patrick Mezard
3a4d3628f4 convert/svn: make svn sink work with svn 1.7
"svn add file" now fails if "file" is already tracked. To filter them we have
to mirror the svn manifest in the sink.

Tested with svn 1.6.12 and 1.7.4.
2012-04-24 12:50:41 +02:00
Patrick Mezard
6067403d0d convert/svn: do not try converting empty head revisions (issue3347)
Subversion conversion works by picking trunk and branches heads, computing a
revision graph from them and converting the selected commits. By design we fail
to convert empty revisions so we have to be careful when discovering the
revision graph. In this particular issue, the source svn repository was a
partial mirror made by svnsync. The funny part is svnsync preserves all
revisions including empty ones. Also, we trusted ra.stat(path,
stop).created_rev to give us the latest revision with changes in path history
up to stop. This assumption broke at least when path is '', that is the
repository root, which always returned 'stop' revision despited being empty.

The workaround is to first trust ra.stat() but if the returned revision appear
empty, search the whole path history from stop to r1 until some changes are
found.
2012-04-18 14:04:58 +02:00
Patrick Mezard
b8a30fde3a convert/svn: refactor svn_source.latest() with a nested function
We will call it more than once for reasons detailed later.
2012-04-18 14:04:58 +02:00
Patrick Mezard
d11f49e922 convert/svn: clarify svn_source.latest() stop arg default value
stop=0 could pass for a valid default value at first sight.
2012-04-18 14:04:57 +02:00
Matt Mackall
2cf26ea8f0 merge with stable 2012-03-27 16:17:46 -05:00
Matt Mackall
80e06b69f8 merge with stable 2012-03-18 18:21:58 -05:00
Matt Mackall
7e89fda9b9 convert: deal with empty splicemap path (issue3311) 2012-03-16 17:42:21 -05:00
Edouard Gomez
da8b7a73ff convert: support non annotated tags in git backend
Do not blindly filter out non ending ^{} tags. The new logic
is:
 - if both "tag" and "tag^{}" exist, "tag^{}" is what we want
 - if only "tag" exists, "tag" is fine
2012-03-14 01:13:45 +01:00
Matt Mackall
f2a652218a i18n: fix all remaining uses of % inside _() 2012-03-08 13:35:27 -06:00
Patrick Mezard
a8beff44c2 convert: ignore blank lines in mapfiles (issue3286) 2012-02-28 10:06:35 +01:00
Wagner Bruna
526cb26c72 convert: fix typos in error messages 2012-02-24 19:11:35 -02:00
Matt Mackall
7f2d6a6af7 merge with stable 2012-03-08 15:59:33 -06:00
Matt Mackall
38ab0032cb merge with stable 2012-02-28 21:17:53 -06:00
Matt Mackall
ee77ef5137 merge with stable 2012-02-24 16:16:48 -06:00
Augie Fackler
dcc437f837 convert/git: abort if git submodules are detected (issue2150)
This improves the error message when convert encounters a git
submodule. Now, instead of a git-cat-file error, we'll directly report
the lack of support for git submodules.
2012-03-24 22:13:17 -05:00
Patrick Mezard
d410481c55 convert: tolerate spaces between splicemap parent ids (issue3203)
Splicemap lines are documented in hg help convert like:

  key parent1, parent2

but parsed like:

  key, parents = line.strip().rsplit(' ', 1)
  parents = parents.replace(',', ' ').split()

The rsplit() call was introduced to handle spaces in keys for the generic
mapfile format. Spaces can appear in svn identifiers since they contain path
components. This logic makes less sense with splicemap since svn identifiers
can also appear on the right side, even if it is a bit less likely. Given the
parsing is theorically broken, I would rather follow what is documented already
and is correct in the main case where all identifiers are hg hashes. Also,
using svn identifiers in a splicemap sounds difficult as they are not easily
accessible.
2012-02-15 11:21:24 +01:00
Patrick Mezard
4fbe13b66c convert: use splicemap entries when sorting revisions (issue1748)
When sorting revisions before converting them, we have to edit the revision
graph using splicemap entries. Otherwise, a spliced revision may be converted
before its synthetic parents. Invalid splicemap revisions are now detected
before starting the conversion.
2012-02-10 22:34:13 +01:00
Patrick Mezard
a92c89fcd0 convert: turn splicemap into a simple dictionary
Parsing the splicemap as a mapfile was a pain because map does not let us
override its parsing code and splicemap entries are not key/values. Besides we
had no need for mapfiles extra features. Just parse the splicemap and return a
dictionary.
2012-02-10 22:25:49 +01:00
FUJIWARA Katsunori
9c1a460e7a i18n: use util.pconvert() instead of 'str.replace()' for problematic encoding
some problematic encodings use backslash as part of multi-byte characters.

util.pconvert() can treat strings in such encodings correctly, if
win32mbcs is enabled, but str.replace() can not.
2012-02-05 22:58:31 +09:00
Matt Mackall
ee1d294b90 merge with stable 2012-02-16 16:40:29 -06:00
Matt Mackall
bd7d3adcb4 merge with stable 2012-02-10 17:09:23 -06:00
Patrick Mezard
431fc934f5 convert/bzr: ignore nested repos when listing branches (issue3254)
Reported by A.S. Budden <abudden@gmail.com>
2012-02-08 17:45:10 +01:00
Matt Mackall
6715adc25e merge with stable 2012-02-06 15:22:43 -06:00
Patrick Mezard
c32808c5a9 convert/bzr: handle empty bzr repositories (issue3233) 2012-02-02 10:15:13 +01:00
Patrick Mezard
f7231f2104 convert/bzr: convert all branches (issue3229) (BC)
Instead of opening the target bzr checkout as a single branch, we try to open
it as a repository. This has the following effects:
- All branches are now converted
- bzr branch names are preserved. Previously, the selected branch was always
  converted as 'default'. Branches without a name or 'trunk' are mapped to
  'default branch.
- Lightweight checkouts are no longer supported. Maybe they can be, I did not
  try to fix that at all.

Implementation notes:
- This was a quick fix, I have no knowledge of bzr API besides browsing 2.0.3
  sources.
- The fix was only tested on OSX against bzr 2.4.2.
- Tags discovery does not handle collisions. I have no idea how tags work in
  bzr so maybe such collisions are not possible.
2012-02-02 10:15:12 +01:00
Patrick Mezard
ad5523f701 convert/bzr: expect unicode metadata, encode in UTF-8 (issue3232)
Before this patch, metadata and file names were interpreted like:
- unicode objects were converted to UTF-8
- non unicode objects were left unchanged

Looking at the code and bzr being known for transcoding filenames, we expect
everything to be returned as unicode objects, and we want to encode them in
UTF-8, like the subversion source does. To do that, we just remove the custom
implementation of .recode().
2012-02-02 10:15:04 +01:00
Jesus Espino Garcia
16484a55ad convert: subversion convert abort on revision not found (issue 3205) 2012-01-21 13:31:41 +01:00
Martin Geisler
ba8731035e Use explicit integer division
Found by running the test suite with the -3 flag to show places where
we have int / int division that can be replaced with int // int.
2012-01-08 18:15:54 +01:00
Martin Geisler
fa50c1a5a0 cvsps: pull function definition out of loop 2012-01-08 17:57:25 +01:00
Martin Geisler
d8334151e6 Remove FSF mailing address from GPL headers
The GPLv3 FAQ suggests to upgrade by

  [...] replace all your existing v2 license notices (usually at the
  top of each file) with the new recommended text available on the GNU
  licenses howto. It's more future-proof because it no longer includes
  the FSF's postal mailing address.

This removes the postal address, but leaves the version number at 2+.
2012-01-06 16:27:13 +01:00
Matt Mackall
649efc7475 merge with stable 2011-12-30 17:04:36 -06:00
Matt Mackall
f3ededa444 convert: improve exception reporting for SVN logstream
- catch all exceptions
- pickle a stringified version of the exception
- use a normal abort

Hopefully this will result in less mysterious convert exceptions
2011-12-30 15:47:58 -06:00
Wagner Bruna
307a2fdf03 convert: tolerate trailing spaces on map files
A convert run with a branchmap made with

echo default namedbranch > branchmap

on Windows fails silently and surprisingly; it actually
adds a space after 'namedbranch', so it ends up mapping
"default namedbranch" to "".

This also affects splicemaps, since the same parser is used
for both.
2011-12-02 21:38:57 -02:00
Patrick Mezard
1d6a6d6bd8 convert/svn: fix URL quoting issue with svn 1.7
As of svn 1.7, many svn calls expect "canonical" paths. In theory, we should
call svn.core.*canonicalize() on all paths before passing them to the API.
Instead, we assume the base url is canonical and copy the behaviour of svn URL
encoding function so we can extend it safely with new components.
2011-12-01 20:42:24 +01:00
Matt Mackall
8fc7c196b4 convert: handle trailing slashes in filemap better (issue3124) 2011-11-23 16:25:44 -06:00
Patrick Mezard
26d7e04e93 convert/bzr: correctly handle divergent nested renames (issue3089)
With renames like:

  a   -> b
  a/c -> a/c

We were ignoring or duplicating the second one instead of leaving files
unchanged or moving them to their proper destination only.

To avoid this, we process the files in reverse lexicographic order, from most
to least specific change, and ignore files already processed.

v2:
- Add a test
- Change "reverse=1" into "reverse=True"
2011-11-08 17:08:58 +01:00
Matt Mackall
b066b57e3c backout 17bc9a6bb165 (issue3077) (issue3071)
Using util.realpath turns out to create complex issues on both Mac and
Windows. Back this change out for the release.
2011-10-29 11:02:23 -05:00
Thomas Arendsen Hein
51c498ead0 consistency: use util.realpath instead of os.path.realpath where useful
exceptions:
  hg: os.path.realpath used before util can be imported
  tests/run-tests.py: may not import mercurial modules
2011-10-24 13:51:24 +02:00
Thomas Arendsen Hein
846f225a93 convert: add missing import of util, needed for svn < 1.6 2011-10-22 23:42:48 +02:00
Eli Carter
bad1c40c51 convert: fix typo 2011-10-18 10:32:12 -05:00
Matt Mackall
e82c2e671f merge with stable 2011-12-05 17:48:40 -06:00
Patrick Mezard
08f16028b0 convert: simplify getargmax() with propertycache 2011-12-02 18:36:32 +01:00
Patrick Mezard
17dd79d671 convert/svn: update svn working copy only when necessary
I have not tried to produce the bug but here is idea: b2b0622d9e96 stopped
passing the modified files list to commit. This makes commit more fragile since
we better not touch unrelated files by mistake. But putcommit() still applies
file changes before exiting upon ignored revisions. So in theory, we could
apply changes from a skipped branch then commit them as part of another
revision.

This patch makes the sink apply the changes after possibly skipping the
revision. The real fix would be to use svn commit --targets option to pass the
file names in an argument file. Unfortunately, it seems to be bugged in svn
1.7.1:

  http://svn.haxx.se/dev/archive-2011-11/0211.shtml
2011-12-02 17:38:07 +01:00
Matt Mackall
9e27ec8fc4 merge with stable 2011-12-01 15:57:10 -06:00
Matt Mackall
bd2719486e merge with stable 2011-11-23 16:35:17 -06:00
Matt Mackall
8f2b7260c4 merge with stable 2011-11-10 11:00:27 -06:00
Matt Mackall
d0885370c9 check-code: enable camelcase check, fix up problems 2011-11-09 16:36:54 -06:00
jakob krainz
5eecc04f49 convert: detect false cset boundaries in cvsps descriptions 2011-10-05 10:28:39 +02:00
Matt Mackall
5b7a7b3462 convert: fix crazy rollback call, broken by recent rollback safety checks
This was causing test-convert-cvs.t to fail.
2011-10-07 15:36:35 -05:00
Martin Geisler
91ea943857 convert: rename local variable 2011-09-19 14:19:26 +02:00