Commit Graph

45 Commits

Author SHA1 Message Date
Kevin Bullock
99e7f64512 convert: update use of deprecated bzrlib property
The inventory property was deprecated in favor of root_inventory in bzr
2.5.0. Current version is 2.7.0.

I noticed this when testing locally on Python 2.6.9, which has warnings
turned on by default. The failure that occurs without this patch can be
seen on Python 2.7 by running with warnings enabled:

     $ PYTHONWARNINGS=::DeprecationWarning make 'test-convert-bzr*'
2016-07-19 11:00:32 -05:00
Yuya Nishihara
a5c934df3c py3: move up symbol imports to enforce import-checker rules
Since (b) is banned, we should do the same for (a) for consistency.

 a) from mercurial import hg
    from mercurial.i18n import _

 b) from . import hg
    from .i18n import _
2016-05-14 14:03:12 +09:00
timeless
4f987db82a convert: bzr use absolute_import 2016-03-02 16:32:52 +00:00
timeless
4bcfa639ac convert: bzr use absolute_import 2016-03-02 16:32:52 +00:00
timeless@mozdev.org
1b8a3b4ea1 grammar: use does instead of do where appropriate 2015-10-14 02:06:54 -04:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Durham Goode
0f795691b8 convert: add support for specifying multiple revs
Previously convert could only take one '--rev'. This change allows the user to
specify multiple --rev entries. For instance, this could allow converting
multiple branches (but not all branches) at once from git.

In this first patch, we disable support for this for all sources.  Future
patches will enable it for select sources (like git).
2015-07-08 10:27:43 -07: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
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
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
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Brodie Rao
a706d64a2c cleanup: replace naked excepts with except Exception: ... 2012-05-12 16:02:46 +02: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
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
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
Brodie Rao
0f9d940cb9 cleanup: remove unused variables 2010-08-27 13:32:40 -04:00
Patrick Mezard
20f6d4cdf1 convert: merge sources getmode() into getfile() 2010-05-09 21:52:34 +02:00
Martin Geisler
9346f78d09 convert: mark strings for translation 2010-04-18 15:47:49 +02:00
Martin Geisler
540a354601 convert: write "repository" instead of "repo"
We should strive to avoid slang in our messages to the users.
2010-04-18 15:47:49 +02:00
Pierre-Yves David
31bf517562 Add ElementPath to the list of package ignored by demand import
The bzrlib try to import the ElementPath module but had a fallback in
case the import fails. Lazy import of this module leads to later
failure.

The bzrlib is used by the convert extension.
2010-03-01 14:15:55 +01:00
Benoit Boissinot
328394047f fix coding style (reported by pylint) 2010-02-08 15:36:34 +01:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Brendan Cully
a03c60a23d Merge with crew-stable 2009-06-11 12:23:08 -07:00
Brendan Cully
50a940c93e bzr convert: restore paths to source encoding. Closes issue1692. 2009-06-11 12:18:40 -07:00
Patrick Mezard
e391da8024 convert/bzr: warn when source is a lightweight checkout (issue1647) 2009-05-17 14:35:06 +02:00
Patrick Mezard
8a575f0b78 Merge with crew-stable 2009-05-15 16:17:56 +02:00
Patrick Mezard
d3d9100f4a convert/bzr: fix symlinks target (issue1626/2) 2009-05-15 16:12:09 +02:00
Patrick Mezard
ccca7abe8e convert/bzr: make it work with filemaps (issue1631)
The bzr converter maintains a child -> parents mapping and drop entries
whenever a child is read. It does not work with filemaps, getchangedfiles() may
be called more than once when filtered files belong to merge revisions.
getchanges() still works that way but it is not clear whether a similar issue
can arise when interacting with merges.
2009-04-26 11:35:53 +02:00
Patrick Mezard
62eea60737 convert/bzr: fix symlink handling (issue1626) 2009-04-24 10:34:11 +02:00
Patrick Mezard
75233223fe convert/bzr: handle files replaced by directories (issue1623) 2009-04-23 15:07:05 +02:00
Patrick Mezard
2ae17cf19b convert/bzr: fix file rename replaced by a dir case (issue1583)
We were not checking entry types, and getting file content was working with
directories instead of raising IOError.
2009-04-11 20:18:51 +02:00
Xavier ALT
82ecb55fcf convert: remove renamed source files (issue1505) 2009-04-08 22:59:02 +02:00
Greg Ward
ccfd8df373 convert/bzr: handle Bazaar timestamps correctly (issue1652). 2009-05-06 17:48:03 -04:00
Martin Geisler
393fa0bd51 convert: add copyright and license headers to back-ends 2009-04-26 01:47:44 +02:00
Patrick Mezard
eb5b6f47f6 Merge with crew-stable 2009-04-26 11:49:17 +02:00
Patrick Mezard
db8b25f86d Merge with crew-stable 2009-04-24 10:43:12 +02:00
Patrick Mezard
6205446ef7 Merge with crew-stable 2009-04-23 16:52:25 +02:00
Patrick Mezard
ea6ab7b729 Merge with crew-stable 2009-04-11 20:49:47 +02:00
Patrick Mezard
8b64865271 Merge with crew-stable 2009-04-08 23:24:22 +02:00
Matt Mackall
f2b63f05d7 convert: attempt to check repo type before checking for tool 2009-04-04 12:28:13 -05:00
Dirkjan Ochtman
a3c364ffd3 convert: fixed python2.3 incompatibility in bzr source (generator expression) 2008-10-02 15:48:57 +02:00
Marek Kubica
0f790a60a5 convert: add bzr source 2008-09-26 20:33:47 +02:00