martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.02k stars 261 forks source link

FR: manually track moves and copies #3386

Open Zoybean opened 4 months ago

Zoybean commented 4 months ago

Is your feature request related to a problem? Please describe. I would like to be able to manually track a file move or copy, and have changes to the history of the source file affect the state of the destination file(s), regardless of any similarity or lack of similarity between the source and destination files.

Describe the solution you'd like firstly, I'm writing these as subcommands of a jj file command, where the current jj files could sit as a new jj file ls. I don't care too much about what it is called in the end, but I think it would be useful to separate the file-oriented commands from the repo-oriented commands, hence jj file.

Describe alternatives you've considered An alternative is not to track copies or moves at all. I understand that move tracking is a desired feature, but I do not know if copy tracking is possible (in jj), or if so, if it is practical, to implement in jj.

Additional context Similar to #2012, however it is specific to conflict resolution, whereas this is more general. Related to #47, however this is independent of any file-similarity heuristics. This is informed by me learning about hg mv and hg cp, only just today, however I am otherwise unfamiliar with hg, so I may have misunderstood these hg commands.

joyously commented 4 months ago

If you look at the Wikipedia VCS page, you'll see that most VCS have a command for move/mv and some have a command for copy/cp. (Breezy is the fork of Bazaar but it's not on there, and it has both.)

arxanas commented 4 months ago

It's somewhat tangential, but I like the idea of a jj file command. Also —

martinvonz commented 4 months ago

Sorry I forgot to reply earlier. The plan, IMO, is to let the commit backend decide whether renames are tracked like in Mercurial or detected like in Git. We might have a function like get_copies(source: &Commit, target: &Commit) and it would be up to the backend to decide where to get the information from and whether to calculate it on the fly. We would have commands for marking a file as copied/renamed and it would be up to the backend to decide whether to record that information or to just discard it. The Git backend would discard it.

torquestomp commented 4 months ago

I've started work on a hypothetical API [change] to power this feature, draft PR here: https://github.com/martinvonz/jj/pull/3510. RFC on direction before I go any further

I'm hopeful we can do this in a way that: