Commit Graph

75 Commits

Author SHA1 Message Date
Pulkit Goyal
9251b69fc4 py3: replace os.environ with encoding.environ (part 5 of 5) 2016-12-18 02:08:59 +05:30
Pulkit Goyal
97f340e354 py3: use pycompat.getcwd() instead of os.getcwd()
We have pycompat.getcwd() which returns bytes path on Python 3. This patch
changes most of the occurences of the os.getcwd() with pycompat one.
2016-11-23 00:03:11 +05:30
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
f77cdcd3b1 pycompat: switch to util.stringio for py3 compat 2016-04-10 20:55:37 +00:00
timeless
798be7b824 convert: cvs use absolute_import 2016-03-02 16:41:35 +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
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
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
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
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +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
Martin Geisler
af8a35e078 check-code: flag 0/1 used as constant Boolean expression 2011-06-01 12:38:46 +02:00
Brodie Rao
0f9d940cb9 cleanup: remove unused variables 2010-08-27 13:32:40 -04: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
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
Mads Kiilerich
378848d5c1 convert.cvs: Initialize state variable and abort on cvs error
Fix as proposed by Frank Kingswood.

Avoids
UnboundLocalError: local variable 'mode' referenced before assignment
when cvs fails.

This alsa partially fixes issue1592.
2010-03-30 02:42:21 +02: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
Patrick Mezard
0133f8d115 convert/cvs: stop supporting external cvsps 2009-10-05 22:57:15 +02:00
Greg Ward
2a117f0e09 convert/cvs: improve error message on unexpected server output. 2009-07-08 22:08:45 -04:00
Alejandro Santos
77d606ac51 compat: use open() instead of file() everywhere 2009-07-05 11:01:30 +02:00
Patrick Mezard
82ffe82eb9 convert: deprecate external cvsps, to be removed in 1.4 2009-05-24 16:27:56 +02:00
Martin Geisler
e8bc5f4f01 util: remove ignored mode argument in popen[23] 2009-05-09 17:32:57 +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
Patrick Mezard
71875461a3 convert/cvs: add an option to disable remote log caching
Useful for debugging or testing when using --tmpdir.
2009-04-26 16:30:37 +02:00
Patrick Mezard
d34099656d convert/cvs: delay CVS log parsing after initialization (issue1581/2)
Source and destination constructors should be fast so configurations issues are
hit quickly, including authentication and filemap/authormap/splicemap issues.
Delaying might be a problem if the remove side disconnects idle connections
while the log is being read. It did not happen when converting openafs
repository, where log retrieval took at least 10mn.
2009-04-11 21:17:11 +02:00
Peter Arrenbrecht
a2d3e23eef cleanup: drop variables for unused return values
They are unnecessary. I did leave them in localrepo.py where there is
something like:

  _junk = foo()
  _junk = None

to free memory early. I don't know if just `foo()` will free the return
value as early.
2009-03-23 13:13:02 +01:00
Patrick Mezard
1620a3ec34 Merge with crew-stable 2008-12-14 18:13:41 +01:00
Frank Kingswood
e9b2b07250 convert-cvs: correctly handle Removed replies, fixes bug 1427 2008-12-11 13:33:35 +00:00
Benoit Boissinot
193deb723b convert/cvs: do not compare None with int 2008-12-06 15:40:04 +01:00
Thomas Arendsen Hein
efbb4bc0d2 Improvement to 14ce129cfcd: Use try/except and pass filename on errors
Without the second part, the error message would be
  abort: Is a directory
instead of
  abort: Is a directory: /home/user/.cvspass
2008-11-28 11:38:41 +01:00
Edouard Gomez
88835d384f convert: check existence of ~/.cvspass before reading it 2008-11-27 10:13:20 +01:00
Mads Kiilerich
b9c26e8467 convert cvs: Fix branch name parsing
cvsps version 2.2b1 as found in Fedora 10 outputs the following format:
---------------------
PatchSet 1
Date: 2008/11/26 00:59:46
Author: mk
Branch: HEAD
Tag: (none)
Branches: INITIAL
Log:
Initial revision

Members:
	a:INITIAL->1.1
	b/c:INITIAL->1.1

---------------------

The parser overwrote the Branch value with noise from the misparsed Branches
value.
2008-11-27 22:04:51 +01:00
Dirkjan Ochtman
67bd09df5b python2.6: use subprocess if available 2008-10-05 21:35:26 +02:00
Patrick Mezard
71877ea8d9 convert: make built-in cvsps the default
Reviewed by Frank Kingswood <frank@kingswood-consulting.co.uk>
2008-10-15 20:14:28 +02:00
Martin Geisler
a791bcac31 i18n: mark strings for translation in convert extension 2008-08-31 16:12:02 +02:00
Patrick Mezard
49cd301d4b Merge with crew-stable 2008-07-20 21:51:13 +02:00
Martin OConnor
8a6ec085df Bug:1201 hg convert on CVS working copy produces Traceback
Fix identified by frank@kingswood-consulting.co.uk

Changed usage fron os.environ["HOME"] to expanduser("~/.cvspass") as
this is the
 only usage of this construct in mercurial sources.
2008-06-25 19:41:43 +01:00
Matt Mackall
a65ef7bc5d util: add sort helper 2008-06-27 18:28:45 -05:00
Frank Kingswood
6c0cfe8797 convert: cvs.py - Allow user to use built-in CVS changeset code.
tests: add two testcases for CVS conversion with builtin CVS
including a testcase for issue 1148.
2008-06-15 16:05:46 +01:00
Eric Hopper
40e06fccb8 convert: Add convert.cvsps option to set up an alternate cvsps command line. 2008-03-17 12:41:14 -07:00
Matt Mackall
11a373ad95 convert: try to be smarter about CVS branching
Better handles this case:

The output from cvsps -A -u --cvs-direct -q:
---------------------
PatchSet 1
Date: 2008/02/08 20:33:28
Author: fk
Branch: HEAD
Tag: (none)
Log:
initial

Members:
         file_one:INITIAL->1.1

---------------------
PatchSet 2
Date: 2008/02/08 20:33:32
Author: fk
Branch: branch_name
Ancestor branch: HEAD
Tag: (none)
Log:
new file on branch

Members:
         file_two:1.1->1.1.2.1
2008-02-11 16:16:05 -06:00
Thomas Arendsen Hein
ddce807d45 merge with crew-stable 2008-01-22 00:55:01 +01:00