Page MenuHomePhabricator

copy: add option to unmark file as copied
ClosedPublic

Authored by martinvonz on Tue, Jan 28, 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
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

martinvonz created this revision.Tue, Jan 28, 6:51 PM
martinvonz updated this revision to Diff 19669.Tue, Jan 28, 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.Wed, Jan 29, 5:44 PM
This revision is now accepted and ready to land.Wed, Jan 29, 5:44 PM
martinvonz updated this revision to Diff 19692.Wed, Jan 29, 6:37 PM
pulkit added a subscriber: pulkit.Thu, Jan 30, 9:19 AM
pulkit added inline comments.
mercurial/cmdutil.py
1712

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

mercurial/commands.py
7506

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

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

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
7506

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.Thu, Jan 30, 12:08 PM
mercurial/commands.py
7506

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

marmoute requested changes to this revision.Fri, Feb 7, 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.Fri, Feb 7, 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.Mon, Feb 10, 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.Mon, Feb 10, 6:30 PM
durin42 accepted this revision.Wed, Feb 12, 2:41 PM

LGTM, would like @marmoute to chime in.

martinvonz updated this revision to Diff 20174.Wed, Feb 12, 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)Thu, Feb 13, 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.Thu, Feb 13, 4:37 PM
marmoute requested changes to this revision.Thu, Feb 13, 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
1406

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

1414

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.Thu, Feb 13, 5:57 PM
martinvonz added inline comments.Thu, Feb 13, 6:07 PM
mercurial/cmdutil.py
1406

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.Thu, Feb 13, 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.Thu, Feb 13, 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.Thu, Feb 13, 6:22 PM
marmoute added inline comments.Thu, Feb 13, 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.Thu, Feb 13, 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.Thu, Feb 13, 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.Thu, Feb 13, 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)Fri, Feb 14, 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.