hg mv old new equivalent to mv old new hg addremove

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

hg mv old new equivalent to mv old new hg addremove

Uwe Brauer

Hi

This seems trivial but I want to be 100 % sure:

Is

hg mv old new
equivalent to
mv old new
hg addremove


Regards

Uwe Brauer

_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: hg mv old new equivalent to mv old new hg addremove

Dr Rainer Woitok
Uwe,

On Saturday, 2020-07-25 19:26:36 +0200, you wrote:

> ...
> Is
>
> hg mv old new
> equivalent to
> mv old new
> hg addremove

Superficially yes.  But if you look closer, the information is lost that
file "new" is not really new but rather just received a new name.

Sincerely,
  Rainer
_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: hg mv old new equivalent to mv old new hg addremove

Uwe Brauer
>>> "RW" == Rainer Woitok <[hidden email]> writes:

   > Uwe,
   > On Saturday, 2020-07-25 19:26:36 +0200, you wrote:

   >> ...
   >> Is
   >>
   >> hg mv old new
   >> equivalent to
   >> mv old new
   >> hg addremove

   > Superficially yes.  But if you look closer, the information is lost that
   > file "new" is not really new but rather just received a new name.

I presume hg mv is «safer» in that sense. But what information does it
preserve?
I can't use annotate in none of these two cases, which as I understand
would be in general impossible, if I merge two files into a single one,
still I found the following email from Matt some years ago:
https://www.mercurial-scm.org/pipermail/mercurial/2012-March/042407.html 

 hg annotate -r 2519^ "set:follow(somefile)"

But this was never implemented as far as I can see

_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: hg mv old new equivalent to mv old new hg addremove

Dr Rainer Woitok
Uwe,

On Sunday, 2020-07-26 19:14:53 +0200, you wrote:

> ...
> I presume hg mv is «safer» in that sense. But what information does it
> preserve?

The information that one file  is just a rename of the other,  which is,
for instance, utilized by "hg log -f".   If you just move a file outside
of Mercurial,  the old file  will just  cease to exist  and the new file
will just spring into existence  without noting that the old file is the
predecessor of the new one.

Sincerely,
  Rainer
_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: hg mv old new equivalent to mv old new hg addremove

Uwe Brauer
>>> "RW" == Rainer Woitok <[hidden email]> writes:

Rainer,


   > Uwe,
   > On Sunday, 2020-07-26 19:14:53 +0200, you wrote:

   >> ...
   >> I presume hg mv is «safer» in that sense. But what information does it
   >> preserve?

   > The information that one file  is just a rename of the other,  which is,
   > for instance, utilized by "hg log -f".   If you just move a file outside
   > of Mercurial,  the old file  will just  cease to exist  and the new file
   > will just spring into existence  without noting that the old file is the
   > predecessor of the new one.

Sorry to nag, but the following scripts seem to produce an identical
result:
,----
| hg init
| echo "First" > test.org
| hg add test.org
| hg commit  -m "First"
| echo "Second" >> test.org
| hg commit  -m "Second"
| echo "Third" >> test.org
| hg commit  -m "Third"
| echo "Forth" >> test.org
| hg commit  -m "Forth"
| hg mv test.org testnew.org
| hg commit  -m "Renamed file test.org to testnew.org"
| hg log -f testnew.org
`----


,----
| hg init
| echo "First" > test.org
| hg add test.org
| hg commit  -m "First"
| echo "Second" >> test.org
| hg commit  -m "Second"
| echo "Third" >> test.org
| hg commit  -m "Third"
| echo "Forth" >> test.org
| hg commit  -m "Forth"
| mv test.org testnew.org
| hg addremove
| hg commit  -m "Renamed file test.org to testnew.org"
| hg log -f testnew.org
`----


Uwe

_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: hg mv old new equivalent to mv old new hg addremove

Marcus Harnisch-2
In reply to this post by Uwe Brauer
On 25/07/2020 19.26, Uwe Brauer wrote:
> This seems trivial but I want to be 100 % sure:
>
> Is
>
> hg mv old new
> equivalent to
> mv old new
> hg addremove

Yes. ‘hg addremove’ synthesizes the meta-information about moved files
(perhaps also copied?) based on the similarity of files (default: 100%,
i.e. files must be identical). ‘hg help addremove --verbose’ has the
details.

I've used this sucessfully for importing from another VCS that doesn't
support this kind of functionality.

Cheers,
Marcus

_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: hg mv old new equivalent to mv old new hg addremove

Dr Rainer Woitok
In reply to this post by Uwe Brauer
Uwe,

On Monday, 2020-07-27 17:01:57 +0200, you wrote:

> ...
> Sorry to nag, but the following scripts seem to produce an identical
> result:

You are right.   If I remember correctly,  earlier versions of Mercurial
did not provide this  "recording removal of test.org  as rename to test-
new.org  (100% similar)" feature.   Now problems might only arise if you
do both, renaming and modifying in the same changeset.  Then I would he-
sitate to rely on  this similarity test  and would prefer  "hg mv"  over
just "mv"  (and if I forgot to use "hg mv" instead of "mv" but remember-
ed before committing, there's "hg mv --after" to correct the situation).

Sincerely,
  Rainer
_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: hg mv old new equivalent to mv old new hg addremove

Uwe Brauer
>>> "RW" == Rainer Woitok <[hidden email]> writes:

   > Uwe,
   > On Monday, 2020-07-27 17:01:57 +0200, you wrote:

   >> ...
   >> Sorry to nag, but the following scripts seem to produce an identical
   >> result:

   > You are right.   If I remember correctly,  earlier versions of Mercurial
   > did not provide this  "recording removal of test.org  as rename to test-
   > new.org  (100% similar)" feature.   Now problems might only arise if you
   > do both, renaming and modifying in the same changeset.  Then I would he-
   > sitate to rely on  this similarity test  and would prefer  "hg mv"  over
   > just "mv"  (and if I forgot to use "hg mv" instead of "mv" but remember-
   > ed before committing, there's "hg mv --after" to correct the situation).

Hm, I use emacs, or to be more precise the dired mode of emacs for
renaming, copying, deleting  and moving, so
hg addremove comes in very handy

_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: hg mv old new equivalent to mv old new hg addremove

Pierre-Yves David-2
In reply to this post by Uwe Brauer
In you simple example they will be "the same" because the content of
old/new did not change betwen the `mv` and the `hg addremove`. So the
addremove will successfully detect the rename and record the copy
information. However if you know that you are doing a move for `hg move`
will be safer because it avoid the risk of `hg addremove` failing to
pick up the rename (eg: because of content change) or have unintended
side effect (because other file are in the repository)

On 7/25/20 7:26 PM, Uwe Brauer wrote:

>
> Hi
>
> This seems trivial but I want to be 100 % sure:
>
> Is
>
> hg mv old new
> equivalent to
> mv old new
> hg addremove
>
>
> Regards
>
> Uwe Brauer
>
> _______________________________________________
> Mercurial mailing list
> [hidden email]
> https://www.mercurial-scm.org/mailman/listinfo/mercurial
>

--
Pierre-Yves David
_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial