Commit Graph

57 Commits

Author SHA1 Message Date
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
81c64e649e convert: gnuarch use absolute_import 2016-03-02 08:58:01 +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
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
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
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
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
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
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
Adrian Buehlmann
4163cf2e6f rename util.find_exe to findexe 2011-05-08 20:35:46 +02:00
Patrick Mezard
979ccf4590 Use lexists() instead of exists() where appropriate 2010-09-20 21:46:56 +02:00
Brodie Rao
5c97a02c1e convert: use encoding.encoding instead of locale.getpreferredencoding()
The latter may not return useful results in certain OS X environments.
2010-08-18 10:53:52 -04:00
Brodie Rao
e752297abf convert: properly set encoding for gnuarch converter 2010-08-18 10:53:50 -04:00
Patrick Mezard
20f6d4cdf1 convert: merge sources getmode() into getfile() 2010-05-09 21:52:34 +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
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
Martin Geisler
9f1896c083 do not attempt to translate ui.debug output 2009-09-19 01:15:38 +02:00
Nicolas Dumazet
fb2cbab1fb use 'x in dict' instead of 'dict.has_key(x)'
"in" is faster, and has_key will be removed in py3k
2009-08-24 21:00:34 +02:00
Benoit Boissinot
125a85ec87 use new style classes 2009-06-10 15:10:21 +02:00
Martin Geisler
c624e91552 fixed typos found in translatable strings
This is from a spell-check of hg.pot.
2009-05-31 14:55:51 +02:00
Martin Geisler
1d423b04e4 convert/gnuarch: wrap long line, format kwargs without spaces 2009-05-31 01:29:30 +02:00
Martin Geisler
393fa0bd51 convert: add copyright and license headers to back-ends 2009-04-26 01:47:44 +02:00
Matt Mackall
2f9b02c62d replace util.sort with sorted built-in
This is marginally faster for small and moderately-sized lists
2009-04-26 16:50:44 -05:00
Martin Geisler
44aa7e92d1 util: use built-in set instead of util.unique 2009-04-22 00:56:06 +02:00
Peter Arrenbrecht
19591b6a8c cleanup: drop unused assignments 2009-03-23 13:13:06 +01:00
Patrick Mezard
cdcf39e446 Merge with crew-stable 2009-01-05 14:37:46 +01:00
Patrick Mezard
cfa7c44e4c convert/gnuarch: fix switched copy source and destination
Reported by Edouard Gomez <ed.gomez@free.fr>
2009-01-05 14:34:20 +01:00
Edouard Gomez
ab724af676 convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly 2009-01-04 18:44:39 +01:00
Edouard Gomez
d7aad5cf36 convert/gnuarch: add cat-log payload to commit description 2009-01-04 18:44:30 +01:00
Dirkjan Ochtman
0d446da451 convert/gnuarch: correct indentation 2009-01-04 19:12:42 +01:00
Edouard Gomez
778729ff46 convert/gnuarch: follow continuation-of revisions
Built on top of previous patches:
 - continuation-of parsing
 - registered archives retrieval
 - use of fully qualified revisions

This allows the converter scanning for more source revisions
following the tree versions 'leaked' through the continuation-of
informations. Coupled with the registered archives retrieval, this
makes possible to decide to follow such a hint or stop scanning for
more revisions.

This also implies some changes in the retrieval of some base-0
revisions when they're continuation-of other revisions, in that
case a 'replay' will work where a simple 'get' fails because the
dir exists already. I found the code dealing with 'replay' quite
good as it has already a fallback to 'get' in the error path.
2009-01-04 02:36:48 +01:00
Edouard Gomez
4ea7ad0c50 convert/gnuarch: retrieve known archive names list
This will make possible in a followup patch to prevent
following history that is not reachable because an archive
is unknown to the user.
2009-01-04 02:36:48 +01:00
Edouard Gomez
dd0c6f737a convert/gnuarch: parse continuation-of revisions in gnuarch source
In GNU Arch, continuation-of was often used for:
 - tagging revisions
 - continue working on a project in a new archive, because arch
   was scaling poorly in revision numbers (cat-logs were slow
   to be parsed and scanned through)
 - very similar to the previous point, fork his own branch of
   a project.

Parsing this header information will allow to 'follow' new history
because it often hints at older/forked/personal revision trees.

This patch however just implements the parsing of the
continuation-of header. A followup patch will implement the proper
use of this new information.
2009-01-04 02:36:48 +01:00
Edouard Gomez
0c747d809d convert/gnuarch: use fully qualified revisions
There is no need loosing information in the conversion process. This could
lead to wrong shamap mappings if different archives used the same 'version'
naming.
2009-01-04 02:36:48 +01:00
Edouard Gomez
44d6dc97e7 convert/gnuarch: keep track of original revision in extra headers
It seems to be standard to populate the .rev attribute of a commit
to keep track of original SCM revision names.

Just do it(tm).
2009-01-04 02:36:48 +01:00
Edouard Gomez
d2bfa6d72f convert/gnuarch: robustify cat-log retrieval
GNU Arch used to scale very poorly when revision number was
increasing. This was mostly caused by the huge amount of
cat-log it has to scan/read through to keep track of all
patches that were merged in a given revision.

In order to improve things, cat-log prunning was a common
admin task that would accelerate cat-log parsing at the expense
of unreachabe locally stored cat-logs.

However, these missing cat-logs are still available in the archive.
So try to get them from the archive as a fallback solution.
2009-01-04 02:36:48 +01:00
Edouard Gomez
65ccb5e0de convert/gnuarch: set prefered locale for str conversions
Seems necessary, as a test on my archives goes further with this.
2009-01-04 02:36:48 +01:00
Edouard Gomez
1e555765a3 convert/gnuarch: fix cat-log parsing
cat-log parsing was very wrong. It assumed the Summary header
was comming last, which is wrong. Plus the code was buggy because
it was concatenating all headers in the summary.

As parsing GNU Arch isn't trivial, and python email code does it
so well... just use that ;-)
2009-01-04 02:36:48 +01:00
Edouard Gomez
d5da3e53f1 convert/gnuarch: remove unused code
Debug stuff ? Wipe it.
2009-01-04 02:36:48 +01:00
Martin Geisler
8c1d48c66f move % out of translatable strings
The translators need to see the raw format string, not the result of
using the format string.
2008-08-16 14:46:56 +02:00
Matt Mackall
a65ef7bc5d util: add sort helper 2008-06-27 18:28:45 -05:00
Joel Rosdahl
4f8012378a Remove unused imports 2008-03-06 22:23:41 +01:00
Patrick Mezard
6b7a646271 convert: detect baz before tla
The former seems to handle repositories built by the latter, the opposite is not true.
2008-02-12 23:35:35 +01:00