Skip to content
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

Add support for kart resolve --renumber #817

Merged
merged 2 commits into from
Apr 12, 2023
Merged

Conversation

olsen232
Copy link
Collaborator

Description

Adds support for any of the following ways of resolving conflicting primary keys occurring due to insert/insert conflicts.

kart resolve --renumber=ours # Renumber all our features that conflict, keep theirs unchanged
kart resolve --renumber=theirs # Renumber all their features that conflict, keep ours unchanged
kart resolve <dataset>:feature --renumber=(ours|theirs) # Renumber only features at a certain dataset
kart resolve <dataset>:feature:<pk> --renumber=(ours|theirs) # Renumber only a certain feature at a certain dataset

The renumbered features will all be given contiguous primary keys from the unused range, beyond any existing primary key values.

Related links:

#814

Checklist:

  • Have you reviewed your own change?
  • Have you included test(s)?
  • Have you updated the changelog?

@olsen232 olsen232 requested a review from craigds April 12, 2023 04:55
Copy link
Member

@craigds craigds left a comment

Choose a reason for hiding this comment

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

What happens if you use it with string PKs? Might need a check/error for that.

Otherwise LGTM.

@EPajares please test if possible to confirm this works for you. (We're aware the Windows build is currently broken though 😢)

a user could easily have an extra ":" on the end by accident.
"""
rstripped = conflict_label.rstrip(":")
if rstripped and len(rstripped) == len(conflict_label) - 1:
Copy link
Member

Choose a reason for hiding this comment

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

mind explaining this? is this in case there are multiple trailing colons?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Basically - I want to handle "<dataset_name>:feature:` but not mess with junk like "::"

kart/resolve.py Outdated Show resolved Hide resolved
@EPajares
Copy link

Thanks! I tested it with my conflicts (PK is an integer), and it worked smoothly on Ubuntu. I guess as suggested for string a check/error might be helpful.

@olsen232 olsen232 merged commit d3e0736 into master Apr 12, 2023
@olsen232 olsen232 deleted the renumber-conflicts branch April 12, 2023 22:53
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.

None yet

3 participants