Commit Graph

770 Commits

Author SHA1 Message Date
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