Patchwork D3968: amend: support "history-editing-backup" config option

login
register
mail settings
Submitter phabricator
Date Aug. 3, 2018, 1:44 p.m.
Message ID <1188f07a2f268cc14be3fbce6ef77079@localhost.localdomain>
Download mbox | patch
Permalink /patch/33146/
State Not Applicable
Headers show

Comments

phabricator - Aug. 3, 2018, 1:44 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG32ece991955c: amend: support &quot;history-editing-backup&quot; config option (authored by khanchi97, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3968?vs=9794&id=9818

REVISION DETAIL
  https://phab.mercurial-scm.org/D3968

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-amend.t

CHANGE DETAILS




To: khanchi97, #hg-reviewers
Cc: yuja, mercurial-devel
sushil khanchi - Aug. 7, 2018, 9:30 p.m.
@yuja Is there any command left which we can consider to add
'history-editing-backup' config option?

On Fri, Aug 3, 2018 at 7:14 PM khanchi97 (Sushil khanchi) <
phabricator@mercurial-scm.org> wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rHG32ece991955c: amend: support
> &quot;history-editing-backup&quot; config option (authored by khanchi97,
> committed by ).
>
> REPOSITORY
>   rHG Mercurial
>
> CHANGES SINCE LAST UPDATE
>   https://phab.mercurial-scm.org/D3968?vs=9794&id=9818
>
> REVISION DETAIL
>   https://phab.mercurial-scm.org/D3968
>
> AFFECTED FILES
>   mercurial/cmdutil.py
>   tests/test-amend.t
>
> CHANGE DETAILS
>
> diff --git a/tests/test-amend.t b/tests/test-amend.t
> --- a/tests/test-amend.t
> +++ b/tests/test-amend.t
> @@ -331,3 +331,37 @@
>    ? missing_content2_content2-untracked
>    ? missing_content2_content3-untracked
>    ? missing_missing_content3-untracked
> +
> +==========================================
> +Test history-editing-backup config option|
> +==========================================
> +  $ hg init $TESTTMP/repo4
> +  $ cd $TESTTMP/repo4
> +  $ echo a>a
> +  $ hg ci -Aqma
> +  $ echo oops>b
> +  $ hg ci -Aqm "b"
> +  $ echo partiallyfixed > b
> +
> +#if obsstore-off
> +  $ hg amend
> +  saved backup bundle to
> $TESTTMP/repo4/.hg/strip-backup/95e899acf2ce-f11cb050-amend.hg
> +When history-editing-backup config option is set:
> +  $ cat << EOF >> $HGRCPATH
> +  > [ui]
> +  > history-editing-backup = False
> +  > EOF
> +  $ echo fixed > b
> +  $ hg amend
> +
> +#else
> +  $ hg amend
> +When history-editing-backup config option is set:
> +  $ cat << EOF >> $HGRCPATH
> +  > [ui]
> +  > history-editing-backup = False
> +  > EOF
> +  $ echo fixed > b
> +  $ hg amend
> +
> +#endif
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2556,8 +2556,10 @@
>          obsmetadata = None
>          if opts.get('note'):
>              obsmetadata = {'note': encoding.fromlocal(opts['note'])}
> +        backup = ui.configbool('ui', 'history-editing-backup')
>          scmutil.cleanupnodes(repo, mapping, 'amend', metadata=obsmetadata,
> -                             fixphase=True, targetphase=commitphase)
> +                             fixphase=True, targetphase=commitphase,
> +                             backup=backup)
>
>          # Fixing the dirstate because localrepo.commitctx does not update
>          # it. This is rather convenient because we did not need to update
>
>
>
> To: khanchi97, #hg-reviewers
> Cc: yuja, mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Yuya Nishihara - Aug. 8, 2018, 11:45 a.m.
> @yuja Is there any command left which we can consider to add
> 'history-editing-backup' config option?

Maybe some of these?

```
% rg scmutil.cleanupnodes hgext mercurial
hgext/rebase.py:1760:    scmutil.cleanupnodes(repo, replacements, 'rebase', moves, backup=backup)
hgext/split.py:172:    scmutil.cleanupnodes(repo, {ctx.node(): [c.node() for c in committed]},
hgext/uncommit.py:181:            scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True)
hgext/uncommit.py:250:        scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True)
hgext/histedit.py:1211:    scmutil.cleanupnodes(repo, mapping, 'histedit')
mercurial/cmdutil.py:798:        scmutil.cleanupnodes(repo, replacements, 'branch-change', fixphase=True)
mercurial/cmdutil.py:2557:        scmutil.cleanupnodes(repo, mapping, 'amend', metadata=obsmetadata,
hgext/fix.py:188:    """Calls scmutil.cleanupnodes() with the given replacements.
hgext/fix.py:201:    scmutil.cleanupnodes(repo, replacements, 'fix', fixphase=True)
```
sushil khanchi - Aug. 9, 2018, 8:35 a.m.
@yuja Thanks.

On Wed, Aug 8, 2018 at 5:34 PM Yuya Nishihara <yuya@tcha.org> wrote:

> > @yuja Is there any command left which we can consider to add
> > 'history-editing-backup' config option?
>
> Maybe some of these?
>
Right. IIUC, For commands like uncommit, unamend we can't add this config
as they require `evolution.allowunstable=True` otherwise they won't work.
So revs won't be stripped when running those commands.
But I think we can add history-editing-backup in split, fix, branch-change?

>
> ```
> % rg scmutil.cleanupnodes hgext mercurial
> hgext/rebase.py:1760:    scmutil.cleanupnodes(repo, replacements,
> 'rebase', moves, backup=backup)
> hgext/split.py:172:    scmutil.cleanupnodes(repo, {ctx.node(): [c.node()
> for c in committed]},
> hgext/uncommit.py:181:            scmutil.cleanupnodes(repo, mapping,
> 'uncommit', fixphase=True)
> hgext/uncommit.py:250:        scmutil.cleanupnodes(repo, mapping,
> 'unamend', fixphase=True)
> hgext/histedit.py:1211:    scmutil.cleanupnodes(repo, mapping, 'histedit')
> mercurial/cmdutil.py:798:        scmutil.cleanupnodes(repo, replacements,
> 'branch-change', fixphase=True)
> mercurial/cmdutil.py:2557:        scmutil.cleanupnodes(repo, mapping,
> 'amend', metadata=obsmetadata,
> hgext/fix.py:188:    """Calls scmutil.cleanupnodes() with the given
> replacements.
> hgext/fix.py:201:    scmutil.cleanupnodes(repo, replacements, 'fix',
> fixphase=True)
> ```
>

Patch

diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -331,3 +331,37 @@ 
   ? missing_content2_content2-untracked
   ? missing_content2_content3-untracked
   ? missing_missing_content3-untracked
+
+==========================================
+Test history-editing-backup config option|
+==========================================
+  $ hg init $TESTTMP/repo4
+  $ cd $TESTTMP/repo4
+  $ echo a>a
+  $ hg ci -Aqma
+  $ echo oops>b
+  $ hg ci -Aqm "b"
+  $ echo partiallyfixed > b
+
+#if obsstore-off
+  $ hg amend
+  saved backup bundle to $TESTTMP/repo4/.hg/strip-backup/95e899acf2ce-f11cb050-amend.hg
+When history-editing-backup config option is set:
+  $ cat << EOF >> $HGRCPATH
+  > [ui]
+  > history-editing-backup = False
+  > EOF
+  $ echo fixed > b
+  $ hg amend
+
+#else
+  $ hg amend
+When history-editing-backup config option is set:
+  $ cat << EOF >> $HGRCPATH
+  > [ui]
+  > history-editing-backup = False
+  > EOF
+  $ echo fixed > b
+  $ hg amend
+
+#endif
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2556,8 +2556,10 @@ 
         obsmetadata = None
         if opts.get('note'):
             obsmetadata = {'note': encoding.fromlocal(opts['note'])}
+        backup = ui.configbool('ui', 'history-editing-backup')
         scmutil.cleanupnodes(repo, mapping, 'amend', metadata=obsmetadata,
-                             fixphase=True, targetphase=commitphase)
+                             fixphase=True, targetphase=commitphase,
+                             backup=backup)
 
         # Fixing the dirstate because localrepo.commitctx does not update
         # it. This is rather convenient because we did not need to update