Skip to content

Bug 1428000 - Migrate: only annotate affected files #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 4, 2018

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Jan 4, 2018

Copy link
Contributor

@Pike Pike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a tad unsure on the abspath vs path change. Can you add more detail on that in the commit message? I think I know why it's OK in blame (cwd=root vs not), but not in blame -> migration.

The other question I have is whether we should first collect all the migration contexts, then gather all files, and run blame once?

# Annotate legacy localization files used as sources by this migration
# to preserve attribution of translations.
files = ctx.localization_resources.keys()
blame = Blame(localization_dir).main(files)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should pass the hglib client to Blame directly. That way, we only have one hg process open instead of ... n + 1 minus whatever gets garbage-collected?

Either in this patch or in a follow-up, I think.

@@ -1,8 +1,10 @@
import argparse
import json
from os.path import join
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: I prefer to have os.path.join explicit rather than importing join into the global namespace. Just import os is good enough. At least that's what more pythonic people have told me to do ;-)

@stasm
Copy link
Contributor Author

stasm commented Jan 4, 2018

Thanks for the review!

I'm a tad unsure on the abspath vs path change. Can you add more detail on that in the commit message? I think I know why it's OK in blame (cwd=root vs not), but not in blame -> migration.

In blame data, path is the path relative to CWD and abspath is the path relative to the root of the repo. With CWD==root, they're the same and I removed abspath to reduce the number of different paths used in the code.

The other question I have is whether we should first collect all the migration contexts, then gather all files, and run blame once?

Annotating now takes under a second which I think is good enough. The code is cleaner now when annotating happens for each migration context separately. Also, batching blames would only help us in the scenario when we run multiple migrations touching the same files... and it would likely shave off a fraction of a second per locale or so. Let's keep this simple for now and revisit as a potential perf optimization if we hit another bottleneck.

In `hg annotate` data, `path` is the path relative to CWD and `abspath` is the path
relative to the root of the repo. With CWD==root, they're the same and we can
remove `abspath` to reduce the number of different types of paths used in the
code.
Copy link
Contributor

@Pike Pike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, now I get it.

Also OK to only refactor the loop for a single blame if we get to need it. I also wondered that there might be situations where it's slower, aka, you have two distinct migrations with different blame authors, then you check empty changesets in one from the other. We'll see, likely hardly noticable impact.

@stasm stasm merged commit 44b1203 into projectfluent:master Jan 4, 2018
@stasm stasm deleted the annotate-only-affected branch January 4, 2018 14:37
stasm added a commit that referenced this pull request Jan 31, 2018
  - Implement Fluent Syntax 0.5.

    - Add support for terms.
    - Add support for `#`, `##` and `###` comments.
    - Remove support for tags.
    - Add support for `=` after the identifier in message and term
      defintions.
    - Forbid newlines in string expressions.
    - Allow trailing comma in call expression argument lists.

    In fluent 0.6.x the new Syntax 0.5 is supported alongside the old
    Syntax 0.4. This should make migrations easier.

    `FluentParser` will correctly parse Syntax 0.4 comments (prefixed with
    `//`), sections and message definitions without the `=` after the
    identifier. The one exception are tags which are no longer supported.
    Please use attributed defined on terms instead.

    `FluentSerializer` always serializes using the new Syntax 0.5.

  - Expose `FluentSerializer.serialize_expression`.

  - Fix Bug 1428000 - Migrate: only annotate affected files (#34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants