This is an archive of the discontinued Mercurial Phabricator instance.

copy: add option to unmark file as copied
ClosedPublic

Authored by martinvonz on Jan 28 2020, 6:51 PM.

Details

Summary

To unmark a file as copied, the user currently has to do this:

hg forget <dest>
hg add <dest>

The new command simplifies that to:

hg copy --forget <dest>

That's not a very big improvement, but I'm planning to also teach `hg
copy [--forget] a --at-rev` argument for marking/unmarking copies
after commit (usually with --at-rev .).

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

martinvonz created this revision.Jan 28 2020, 6:51 PM
martinvonz updated this revision to Diff 19669.Jan 28 2020, 6:55 PM

Coudl we use a flag for to hg copy for that ? something like hg copy --forget

Coudl we use a flag for to hg copy for that ? something like hg copy --forget

Why would you prefer that? Discoverability?

An argument against it is that the commands take different flags and arguments (for example, hg uncopy takes only the destination, no source).

Coudl we use a flag for to hg copy for that ? something like hg copy --forget

Why would you prefer that? Discoverability?
An argument against it is that the commands take different flags and arguments (for example, hg uncopy takes only the destination, no source).

I'm convinced enough that hg uncopy is enough clearer to justify being its own thing.

durin42 accepted this revision.Jan 29 2020, 5:44 PM
This revision is now accepted and ready to land.Jan 29 2020, 5:44 PM
martinvonz updated this revision to Diff 19692.Jan 29 2020, 6:37 PM
pulkit added a subscriber: pulkit.Jan 30 2020, 9:19 AM
pulkit added inline comments.
mercurial/cmdutil.py
1722

generally we refer to repo[None] as wctx right?

mercurial/commands.py
7511

We should add descriptive function documentation which will be visible to user when they do hg uncopy -h.

martinvonz added inline comments.Jan 30 2020, 9:40 AM
mercurial/cmdutil.py
1722

I didn't do that because I had planned the next patch, where the same code is used for working copy and not, so ctx isn't necessarily the working copy.

mercurial/commands.py
7511

Oops, I just forgot about that, I think. I'll send a follow-up (I assume you know that many of the patches you're reviewing now are already queued).

martinvonz added inline comments.Jan 30 2020, 12:08 PM
mercurial/commands.py
7511

Sorry, I forgot that this series was just accepted but not queued :) I've added documentation now.

marmoute requested changes to this revision.Feb 7 2020, 3:29 PM

I am still not convinced by the command name.

Coudl we use a flag for to hg copy for that ? something like hg copy --forget

Why would you prefer that? Discoverability?

Discoverability, avoiding command creep, interface clarify, avoiding interface of similar command drifting appart from each other. The two command really deal with the same data in the same way. Having them one would

An argument against it is that the commands take different flags and arguments (for example, hg uncopy takes only the destination, no source).

I don't think it is a big deal hg copy source dest, hg copy --forget dest seems clear enough to me.

One of the thing that bother me is that hg uncopy is not reverse of hg copy, it is the reverse hg copy --after I expect it can be a source of confusion. using --after better map the behavior of the function, that is closer to hg forget as you point out in your changeset description.

This revision now requires changes to proceed.Feb 7 2020, 3:29 PM

I am still not convinced by the command name.

Coudl we use a flag for to hg copy for that ? something like hg copy --forget

Why would you prefer that? Discoverability?

Discoverability, avoiding command creep, interface clarify, avoiding interface of similar command drifting appart from each other. The two command really deal with the same data in the same way. Having them one would

An argument against it is that the commands take different flags and arguments (for example, hg uncopy takes only the destination, no source).

I don't think it is a big deal hg copy source dest, hg copy --forget dest seems clear enough to me.
One of the thing that bother me is that hg uncopy is not reverse of hg copy, it is the reverse hg copy --after I expect it can be a source of confusion. using --after better map the behavior of the function, that is closer to hg forget as you point out in your changeset description.

You're saying you want the user to say hg copy --forget --after dest to unmark it as copied?

martinvonz retitled this revision from uncopy: add new `hg uncopy` command to copy: add option to unmark file as copied.Feb 10 2020, 5:42 PM
martinvonz edited the summary of this revision. (Show Details)
martinvonz updated this revision to Diff 20068.

I am still not convinced by the command name.

Coudl we use a flag for to hg copy for that ? something like hg copy --forget

Why would you prefer that? Discoverability?

Discoverability, avoiding command creep, interface clarify, avoiding interface of similar command drifting appart from each other. The two command really deal with the same data in the same way. Having them one would

An argument against it is that the commands take different flags and arguments (for example, hg uncopy takes only the destination, no source).

I don't think it is a big deal hg copy source dest, hg copy --forget dest seems clear enough to me.
One of the thing that bother me is that hg uncopy is not reverse of hg copy, it is the reverse hg copy --after I expect it can be a source of confusion. using --after better map the behavior of the function, that is closer to hg forget as you point out in your changeset description.

You're saying you want the user to say hg copy --forget --after dest to unmark it as copied?

Since both you and @durin42 wanted hg copy --forget, I've updated the series to do it that way. I decided not to require hg --after since --forget could be interpreted to mean both "forget the copy" and "forget the file" (i.e. untrack but don't remove) at the same time. That's convenient :)

Note that the synopsis of the command is now not quite correct because hg copy --forget doesn't have SOURCE... DEST but DEST.... timeless suggested adding multiple synopsis lines à la man cp, but our help system decided not to respect my newline. So I just gave up on it. I described it in the help text instead.

martinvonz updated this revision to Diff 20081.Feb 10 2020, 6:30 PM
durin42 accepted this revision.Feb 12 2020, 2:41 PM

LGTM, would like @marmoute to chime in.

martinvonz updated this revision to Diff 20174.Feb 12 2020, 5:23 PM

The commit message has a mention of uncopy which needs to be removed.

martinvonz edited the summary of this revision. (Show Details)Feb 13 2020, 2:09 PM

The commit message has a mention of uncopy which needs to be removed.

Good catch. Done.

martinvonz updated this revision to Diff 20199.Feb 13 2020, 4:37 PM
marmoute requested changes to this revision.Feb 13 2020, 5:57 PM

The UI seems good, but it seems like we should have --dry-run supports and I find the help text confusing (I made improvement suggestion).

mercurial/cmdutil.py
1413

Why are these two incompatible ? I can imagine running --forget with --dryrun

1421

Thanks for updating the UI to forget ☺

mercurial/commands.py
2339

I find this text a bit confusing. Do you mean the the synopsys is hg copy --forget FILE ?

If so, what about something like:

To undo marking a file as copied, use --forget. In that case, any copy informations attached to the command argument will be forgotten: `hg copy --forget FILE+`. The target file(s) will be left in place (still tracked).
tests/test-copy.t
304

This block will be a great place to add a --dry-run test ;-).

This revision now requires changes to proceed.Feb 13 2020, 5:57 PM
martinvonz added inline comments.Feb 13 2020, 6:07 PM
mercurial/cmdutil.py
1413

Just not implemented yet. Are you asking just out of curiosity or do you think it needs to be clarified to the user?

mercurial/commands.py
2339

If you first do hg cp a b, you can't then do hg cp --forget a, it needs to be the destination. The "SOURCE" and "DEST" names refer to the names in the synopsis. I was trying to clarify that that they're treated the same, but maybe there will be no confusion and I should not mention it?

tests/test-copy.t
304

I'll leave that for a follow-up. I don't think it should be a requirement.

marmoute added inline comments.Feb 13 2020, 6:14 PM
mercurial/commands.py
2339

doing hg cp a b does not add copies information to a, so I don't think there would be confusion from the users.

What I find the most confusing part is the piece refering to SOURCE and DEST for an operation that as no such pair. I would refer to an explicite TARGET argument and include some kind of synopsys (at that location in the documentation)

tests/test-copy.t
304

Okay that seems fair. Do you think you could impletement that before 5.4 ?

martinvonz added inline comments.Feb 13 2020, 6:20 PM
mercurial/commands.py
2339

What I find the most confusing part is the piece refering to SOURCE and DEST for an
operation that as no such pair. I would refer to an explicite TARGET argument and
include some kind of synopsys (at that location in the documentation)

I tried to add a separate synopsis line for --forget, as I said in https://phab.mercurial-scm.org/D8029#120191.

I'll still update the comment here to not refer to SOURCE and DEST since it's clearly confusing you, but I don't want to refer to TARGET or FILE either since that's not defined anywhere.

martinvonz updated this revision to Diff 20204.Feb 13 2020, 6:22 PM
marmoute added inline comments.Feb 13 2020, 6:49 PM
mercurial/commands.py
2339

What i mean is to put the equivalent of a synopsys line inside the documentation text at tle location where --forget is defined.

martinvonz added inline comments.Feb 13 2020, 6:51 PM
mercurial/commands.py
2339

Hmm, do we do that elsewhere? It would seem out of place to me, but if there's precedent for doing it, I can do it here too.

marmoute added inline comments.Feb 13 2020, 6:59 PM
mercurial/commands.py
2339

The other command with variable number of arguments I can think of usually mark them as optional in their synopsis (eg: hg bookmarks), but I feel like the situation in a bit different.

The new doc is clearer, but still not very clear. Can you try adding the synopsis to see how it looks like?

An alternative is to augment the help test to support multiple synopsys, "it can't be that hard".

martinvonz added inline comments.Feb 13 2020, 7:03 PM
mercurial/commands.py
2339

I'll let other reviewers decide if it's worth blocking the patch or series for that. I think it's quite clear already.

martinvonz edited the summary of this revision. (Show Details)Feb 14 2020, 6:19 PM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.