635 Commits

Author SHA1 Message Date
Frej Drejhammar
8e1ba281d4 Merge branch 'frej/gh341'
Closes #341
Closes #342
2025-08-16 15:18:34 +02:00
Günther Nußmüller
d77765a23e Fix UnboundLocalError with plugins and largefiles
When Plugins are used in a repository that contains largefiles,
the following exception is thrown as soon as the first largefile
is converted:

```
Traceback (most recent call last):
  File "fast-export/hg-fast-export.py", line 728, in <module>
    sys.exit(hg2git(options.repourl,m,options.marksfile,options.mappingfile,
  File "fast-export/hg-fast-export.py", line 581, in hg2git
    c=export_commit(ui,repo,rev,old_marks,max,c,authors,branchesmap,
  File "fast-export/hg-fast-export.py", line 366, in export_commit
    export_file_contents(ctx,man,modified,hgtags,fn_encoding,plugins)
  File "fast-export/hg-fast-export.py", line 222, in export_file_contents
    file_data = {'filename':filename,'file_ctx':file_ctx,'data':d}
UnboundLocalError: local variable 'file_ctx' referenced before assignment
```

This commit fixes the error by:

 * initializing the file_ctx before the largefile handling takes place
 * Providing a new `is_largefile` value for plugins so they can detect
    if largefile handling was applied (and therefore the file_ctx
    object may no longer be in sync with the git version of the file)
2025-08-11 08:30:17 +02:00
Frej Drejhammar
95459e5599 Merge branch 'gh/340'
Closes #340
2025-07-17 19:45:42 +02:00
Günther Nußmüller
de5c8d9d97 Remove redundant type check in set_default_branch
The passed `name` parameter is always of type `str` in Python 3
hence the type check is redundant and no longer needed.
2025-07-16 14:44:43 +02:00
Günther Nußmüller
ad96531587 Fix TypeError when using the --origin option
Encode the `name` parameter to bytes (using the utf8 codec).

This fixes the `TypeError` in subsequent concatenations in `get_branch`:

```
Traceback (most recent call last):
  # stack omitted for brevity
  File "C:\Dev\git-migration\fast-export\hg2git.py", line 73, in get_branch
    return origin_name + b'/' + name
TypeError: can only concatenate str (not "bytes") to str
```

The conversion is done unconditionally since the passed
parameter is currently always of type `str`.
2025-07-16 14:41:45 +02:00
Frej Drejhammar
4af9a33bd6 Merge branch 'frej/gh338' 2025-06-05 16:53:33 +02:00
Frej Drejhammar
f71385ec14 Fix "Warn if one of the marks, mapping, or heads files are empty"
The commit "Warn if one of the marks, mapping, or heads files are
empty" (7224e420a7) mixed up the state and heads caches and reported
that the heads cache was empty if the state case was. Error found by
Shun-ichi Goto.

Closes #338
2025-06-05 16:50:56 +02:00
Frej Drejhammar
ae21cbf1a2 CI: Bump Ubuntu version used for the CI
Switch to the oldest supported version.
2025-06-05 16:50:37 +02:00
Frej Drejhammar
8762fee403 Merge branch 'gh/337' v250330 2025-03-30 13:47:22 +02:00
Frank Zingsheim
bd707b5d6e Fix: Largefiles ignored #141
Import mercurial large files as ordinary files into git

The basic idea to this fix is based on
https://github.com/planestraveler/fast-export/tree/add-lfs-support-v2
from PR #65

Closes #141
2025-03-29 18:39:27 +01:00
Frej Drejhammar
0afd336d6f Merge branch 'gh/333' 2024-07-13 19:37:00 +02:00
Thalia Archibald
dd1c8f219b Disable core.ignoreCase in tests
When core.ignoreCase is set in the global config, hg-fast-export.sh
warns the user and exits. Override this for tests.
2024-07-06 02:46:07 -07:00
Thalia Archibald
f947189dcc Consistently terminate commit messages with LF
When the length logic for fast-import 'data' commands was updated in
4c10270 (Fix data handling, 2023-03-02), one branch was missed, so
commit messages now do not have a final LF appended in most cases. This
changed the longtime behavior, which had been consistent since the first
commit of hg2git, 9832035 (Initial import, 2007-03-06), and is expected
by some applications which compare against old conversions from
Mercurial.
2024-07-05 05:20:35 -07:00
Frej Drejhammar
2a3806576c Merge branch 'gh/328' 2024-04-07 15:30:23 +02:00
Frej Drejhammar
08e2297853 CI: Add tests to avoid a repeat of #328
Extend tests to cover the file content filter example plugins in order
to avoid a repeat of #328.
2024-04-07 15:25:04 +02:00
Frej Drejhammar
893d6302b7 Fix errors resulting from #318
When commit ddfc3a8300 ("Run file_data_filter on deleted files")
started calling the file_data_filter plugin method, in order to make
deletion of plugin-renamed files work, the example plugins were not
updated. This commit updates the example plugins to not crash when the
file context is None.

Thanks to @hetas discovering this.

Closes 328
2024-04-07 15:23:08 +02:00
Frej Drejhammar
3de7bcfc18 CI: Remove run-tests script
The script should have been removed in 90c6ad5f87 ("test: use make
to run the tests").
2024-03-02 20:25:29 +01:00
Frej Drejhammar
d72e96b202 Drop manual CodeQL actions
Use default configuration as configured in the web interface instead
of hand-configured ci-actions which gives warnings.
2024-02-23 18:11:10 +01:00
Frej Drejhammar
fb225c4700 Merge branch 'gh/321' 2024-02-23 17:07:02 +01:00
Frej Drejhammar
997e8e1a8c Merge branch 'gh/320'
Fixes warnings appearing with Python 3.12.

hg-fast-export.py:231: SyntaxWarning: invalid escape sequence '\.'
2024-02-23 17:04:28 +01:00
Stephan Hohe
ddb574004f Add tests for plugins setting file content to None 2024-02-23 13:43:28 +01:00
Stephan Hohe
e63feee1b9 Don't add file if plugin sets content to None 2024-02-20 17:07:23 +01:00
Stephan Hohe
7b4bb7ff1d Fix escape in regular expression 2024-02-19 23:40:05 +01:00
Frej Drejhammar
53bbe05278 Merge branch 'frej/gh318'
Closes #318
2024-02-16 17:56:17 +01:00
Frej Drejhammar
ddfc3a8300 Run file_data_filter on deleted files
The `file_data_filter` method should be called when files are deleted.
In this case the `data` and `file_ctx` keys map to None. This is so
that a filter which modifies file names can apply the same name
transformations before files are deleted.
2024-02-16 17:12:49 +01:00
Frej Drejhammar
21ab3f347b Make plugin loader look in directories relative to cwd
Make the plugin loader also look for plugins using a path relative to
the current working directory.
2024-02-16 17:06:51 +01:00
Frej Drejhammar
878ba44f48 Merge branch 'frej/run-tests-with-different-python-versions' 2023-12-28 13:48:02 +01:00
Frej Drejhammar
2476d08517 Run tests with multiple Python versions
Run the CI tests with both the earliest supported Python version and
the latest stable release.

The intent is to quickly notice when new features require adjusting
the oldest supported Python version and also detect when the latest
stable version breaks old code (as when 3.12 removed `imp` and we
witched to `importlib` in #311).
2023-12-28 13:40:48 +01:00
Frej Drejhammar
d4298a0906 Check for a supported Python version on startup
Check that hg-fast-export is running on a supported version of Python
on startup. This is an attempt to avoid problems like #314 in the
future.
2023-12-28 13:40:48 +01:00
Frej Drejhammar
efe934e16b Update required version of Python to 3.7
Due to problems with handling of Unicode input in Python < 3.7, bump
the required version of Python to 3.7.
2023-12-28 13:40:48 +01:00
Frej Drejhammar
59675eca22 Add command line flag to dump found versions
Add `--debug` command line flag which dumps the detected versions of
Mercurial and Python. This will probably help future debugging when
unexpected versions are used.
2023-12-28 13:40:48 +01:00
Frej Drejhammar
3c694243c4 Merge branch 'frej/fix-314' 2023-12-28 13:39:42 +01:00
Frej Drejhammar
1bbf7028b4 Don't look for a Python 2 interpreter
Don't look for a Python 2 interpreter as Python is no longer
supported. If there is a Python 2 available and it had the Mercurial
modules available, hg-fast-export would use it and fail to import
`importlib.machinery`. This is probably the cause of #314.

Closes #314.
2023-12-27 13:18:56 +01:00
Frej Drejhammar
c8fa290adf Merge branch 'PR/312' 2023-11-18 20:39:44 +01:00
Ekin Dursun
c49dd0cf60 Remove Python 2 compatibility code
Python 2 support was removed recently, so we don't need the
compatibility code anymore.
2023-11-18 20:22:18 +03:00
Frej Drejhammar
4f94d61d84 Merge branch 'PR/311'
Closes #311
2023-11-18 14:54:53 +01:00
Ekin Dursun
a3d0562737 Make pluginloader use importlib instead imp
Python 3.12 has removed imp and it's recommended to use importlib
instead. Python 2.7 doesn't have importlib, so Python 2.7 support is
ceased (not a big deal since it's been more than 3 years since it was
EOLed) as a part of this change.
2023-11-12 20:41:43 +03:00
Frej Drejhammar
0d0e90d328 Merge branch 'PR/305' into frej/felipec-pr-spree
Closes #305
v231118
2023-03-27 20:35:36 +02:00
Frej Drejhammar
64ee34dfb0 Merge branch 'PR/303' into frej/felipec-pr-spree
Closes #303
Closes #304
2023-03-27 20:34:17 +02:00
Frej Drejhammar
71834a584c Merge branch 'PR/302' into frej/felipec-pr-spree
Closes #302
2023-03-27 20:33:59 +02:00
Frej Drejhammar
4310e47760 Merge branch 'PR/301' into frej/felipec-pr-spree
Closes #301
2023-03-27 20:33:36 +02:00
Felipe Contreras
278cc9966c github: rename the main action to ci
As in: Continuous Integration.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-03-27 01:54:00 -06:00
Felipe Contreras
cf66c36a32 github: move CodeQL steps into the main action
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-03-27 01:53:49 -06:00
Felipe Contreras
269c23c5bb github: cleanup codeql action
Based on the latest walk-through: https://github.com/github/codeql-action.

Gets rid of the warning:

Warning: 1 issue was detected with this workflow: git checkout HEAD^2 is no longer necessary. Please remove this step as Code Scanning recommends analyzing the merge commit for best results.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-03-27 01:49:29 -06:00
Felipe Contreras
90c6ad5f87 test: use make to run the tests
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-03-26 20:05:03 -06:00
Felipe Contreras
51db3b4236 test: update default location of sharness
It's included as a module for a reason.

Also, use "$0" so the tests can be run like `./t/main.t` (or any other
directory).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-03-26 20:04:38 -06:00
Felipe Contreras
fba03b95fb github: update checkout action
Gets rid of the warning:

Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/checkout@v2. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-03-26 19:46:38 -06:00
Felipe Contreras
2cc7db7556 test: bump sharness to 1.2
It's finally released.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-03-26 19:43:04 -06:00
Frej Drejhammar
a89033b5b1 Merge branch 'PR/299' into frej/sharness-as-submodule-and-smoke-test
Closes #298
Closes #299
2023-03-26 18:40:52 +02:00
Frej Drejhammar
fd5bd48a6c Update codeql to version 2 2023-03-26 16:48:07 +02:00