D821: unamend: move fb extension unamend to core
yuja added a comment. Can you send a follow-up to fix these issues? INLINE COMMENTS > uncommit.py:259 > +# identify the commit from which to unamend > +curctx = repo['.'] > + Probably better to query `curctx` after locks are taken. > uncommit.py:280 > +extras = predctx.extra() > +extras['unamend_source'] = curctx.node() > + This should be `curctx.hex()`. It's highly discouraged to store blob in extras. > uncommit.py:311 > +diff = cm.diff(wm) > +changedfiles.extend(diff.iterkeys()) > + Mostly unused variables? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: yuja, quark, durin42, ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
This revision was automatically updated to reflect the committed changes. Closed by commit rHG867990238dc6: unamend: move fb extension unamend to core (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D821?vs=3671=4054 REVISION DETAIL https://phab.mercurial-scm.org/D821 AFFECTED FILES hgext/uncommit.py tests/test-unamend.t CHANGE DETAILS diff --git a/tests/test-unamend.t b/tests/test-unamend.t new file mode 100644 --- /dev/null +++ b/tests/test-unamend.t @@ -0,0 +1,366 @@ +Test for command `hg unamend` which lives in uncommit extension +=== + + $ cat >> $HGRCPATH << EOF + > [alias] + > glog = log -G -T '{rev}:{node|short} {desc}' + > [experimental] + > evolution = createmarkers, allowunstable + > [extensions] + > rebase = + > amend = + > uncommit = + > EOF + +Repo Setup + + $ hg init repo + $ cd repo + $ for ch in {a..h}; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done + + $ hg glog + @ 7:ec2426147f0e Added h + | + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + +Trying to unamend when there was no amend done + + $ hg unamend + abort: changeset must have one predecessor, found 0 predecessors + [255] + +Unamend on clean wdir and tip + + $ echo "bar" >> h + $ hg amend + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID c9fa1a715c1b7661c0fafb362a9f30bd75878d7d + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r c9fa1a715c1b h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + + $ hg glog --hidden + @ 8:c9fa1a715c1b Added h + | + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg unamend + $ hg glog --hidden + @ 9:8da14a1fd653 Added h + | + | x 8:c9fa1a715c1b Added h + |/ + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg diff + diff -r 8da14a1fd653 h + --- a/h Thu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID 8da14a1fd653c3f07fdad5760511c9e12652a306 + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r 8da14a1fd653 h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,1 @@ + +foo + + $ hg status + M h + + $ hg log -r . -T '{extras % "{extra}\n"}' --config alias.log=log + branch=default + unamend_source=\xc9\xfa\x1aq\\\x1bva\xc0\xfa\xfb6*\x9f0\xbdu\x87\x8d} + +Using unamend to undo an unamed (intentional) + + $ hg unamend + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID 1c09887216571a9755fc9d2e7f0e41c2b49e341b + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r 1c0988721657 h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + $ hg diff + +Unamend on a dirty working directory + + $ echo "bar" >> a + $ hg amend + $ echo "foobar" >> a + $ echo "bar" >> b + $ hg status + M a + M b + + $ hg unamend + + $ hg status + M a + M b + + $ hg diff + diff -r 956548224719 a + --- a/a Thu Jan 01 00:00:00 1970 + + +++ b/a Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,3 @@ + foo + +bar + +foobar + diff -r 956548224719 b + --- a/b Thu Jan 01 00:00:00 1970 + + +++ b/b Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + +Unamending an added file + + $ hg ci -m "Added things to a and b" + $ echo foo > bar + $ hg add bar + $ hg amend + + $ hg unamend + $ hg status + A bar + + $ hg revert --all + forgetting bar + +Unamending a removed file + + $ hg remove a + $ hg amend + + $ hg unamend + $ hg status + R a + ? bar + + $ hg revert --all + undeleting a + +Unamending an added file with dirty wdir status + + $ hg add bar + $ hg amend + $ echo bar >> bar + $ hg status + M bar + + $ hg unamend + $ hg
D821: unamend: move fb extension unamend to core
pulkit added a comment. Any updates on this? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: quark, durin42, ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
pulkit updated this revision to Diff 3671. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D821?vs=3421=3671 REVISION DETAIL https://phab.mercurial-scm.org/D821 AFFECTED FILES hgext/uncommit.py tests/test-unamend.t CHANGE DETAILS diff --git a/tests/test-unamend.t b/tests/test-unamend.t new file mode 100644 --- /dev/null +++ b/tests/test-unamend.t @@ -0,0 +1,366 @@ +Test for command `hg unamend` which lives in uncommit extension +=== + + $ cat >> $HGRCPATH << EOF + > [alias] + > glog = log -G -T '{rev}:{node|short} {desc}' + > [experimental] + > evolution = createmarkers, allowunstable + > [extensions] + > rebase = + > amend = + > uncommit = + > EOF + +Repo Setup + + $ hg init repo + $ cd repo + $ for ch in {a..h}; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done + + $ hg glog + @ 7:ec2426147f0e Added h + | + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + +Trying to unamend when there was no amend done + + $ hg unamend + abort: changeset must have one predecessor, found 0 predecessors + [255] + +Unamend on clean wdir and tip + + $ echo "bar" >> h + $ hg amend + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID c9fa1a715c1b7661c0fafb362a9f30bd75878d7d + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r c9fa1a715c1b h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + + $ hg glog --hidden + @ 8:c9fa1a715c1b Added h + | + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg unamend + $ hg glog --hidden + @ 9:8da14a1fd653 Added h + | + | x 8:c9fa1a715c1b Added h + |/ + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg diff + diff -r 8da14a1fd653 h + --- a/h Thu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID 8da14a1fd653c3f07fdad5760511c9e12652a306 + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r 8da14a1fd653 h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,1 @@ + +foo + + $ hg status + M h + + $ hg log -r . -T '{extras % "{extra}\n"}' --config alias.log=log + branch=default + unamend_source=\xc9\xfa\x1aq\\\x1bva\xc0\xfa\xfb6*\x9f0\xbdu\x87\x8d} + +Using unamend to undo an unamed (intentional) + + $ hg unamend + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID 1c09887216571a9755fc9d2e7f0e41c2b49e341b + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r 1c0988721657 h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + $ hg diff + +Unamend on a dirty working directory + + $ echo "bar" >> a + $ hg amend + $ echo "foobar" >> a + $ echo "bar" >> b + $ hg status + M a + M b + + $ hg unamend + + $ hg status + M a + M b + + $ hg diff + diff -r 956548224719 a + --- a/a Thu Jan 01 00:00:00 1970 + + +++ b/a Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,3 @@ + foo + +bar + +foobar + diff -r 956548224719 b + --- a/b Thu Jan 01 00:00:00 1970 + + +++ b/b Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + +Unamending an added file + + $ hg ci -m "Added things to a and b" + $ echo foo > bar + $ hg add bar + $ hg amend + + $ hg unamend + $ hg status + A bar + + $ hg revert --all + forgetting bar + +Unamending a removed file + + $ hg remove a + $ hg amend + + $ hg unamend + $ hg status + R a + ? bar + + $ hg revert --all + undeleting a + +Unamending an added file with dirty wdir status + + $ hg add bar + $ hg amend + $ echo bar >> bar + $ hg status + M bar + + $ hg unamend + $ hg status + A bar + $ hg diff + diff -r ff917aa01c86 bar + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/barThu Jan 01 00:00:00
D821: unamend: move fb extension unamend to core
durin42 added inline comments. INLINE COMMENTS > durham wrote in uncommit.py:265 > I'd just let unamend undo an unamend. Letting unamend toggle back and forth > between the two states seems like it might grant the user more confidence in > the command, even. Works for me. Add some documentation/testing of this so we know it's intentional in the future? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: quark, durin42, ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
durham added inline comments. INLINE COMMENTS > pulkit wrote in uncommit.py:265 > Okay while trying to add this condition, I found we cannot refuse to unamend > a changeset on the basis of unamend_source, for e.g > `a -amend-> b -unamend-> a' -amend-> c -unamend-> a''` > > But if we refuse on basis on unamend_source, unamend `c` will refuse. We need > to be more smart here but when I think the other way around, I think it's > okay to unamend an unamend. I am open to suggestion and will go with what you > guys prefer is good. I'd just let unamend undo an unamend. Letting unamend toggle back and forth between the two states seems like it might grant the user more confidence in the command, even. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: quark, durin42, ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
pulkit added inline comments. INLINE COMMENTS > durin42 wrote in uncommit.py:265 > Should we also look for unamend_source in the extra, and potentially refuse > to unamend an unamend? Or not? Okay while trying to add this condition, I found we cannot refuse to unamend a changeset on the basis of unamend_source, for e.g `a -amend-> b -unamend-> a' -amend-> c -unamend-> a''` But if we refuse on basis on unamend_source, unamend `c` will refuse. We need to be more smart here but when I think the other way around, I think it's okay to unamend an unamend. I am open to suggestion and will go with what you guys prefer is good. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: quark, durin42, ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
pulkit added a subscriber: quark. pulkit added inline comments. INLINE COMMENTS > durin42 wrote in uncommit.py:247 > undo the _most recent_ amend? or can I run this iteratively and undo many > amends in sequence? Nice catch, it should be undo the _most recent_ amend. Thanks! > durin42 wrote in uncommit.py:265 > Should we also look for unamend_source in the extra, and potentially refuse > to unamend an unamend? Or not? I don't think users will run unamend(1) and then will try to run unamend(2) again to unamend the first unamend. It's not intuitive in my opinion. @durham @quark what do you guys think here? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: quark, durin42, ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
durin42 added inline comments. INLINE COMMENTS > uncommit.py:247 > +def unamend(ui, repo, **opts): > +"""undo the amend operation on a current changeset > + undo the _most recent_ amend? or can I run this iteratively and undo many amends in sequence? > uncommit.py:265 > +markers = list(predecessormarkers(curctx)) > +if len(markers) != 1: > +e = _("changeset must have one predecessor, found %i > predecessors") Should we also look for unamend_source in the extra, and potentially refuse to unamend an unamend? Or not? > uncommit.py:273 > +if curctx.children(): > +raise error.Abort(_("cannot unamend in the middle of a stack")) > + cannot unamend a changeset with children REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: durin42, ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
pulkit updated this revision to Diff 3421. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D821?vs=2493=3421 REVISION DETAIL https://phab.mercurial-scm.org/D821 AFFECTED FILES hgext/uncommit.py tests/test-unamend.t CHANGE DETAILS diff --git a/tests/test-unamend.t b/tests/test-unamend.t new file mode 100644 --- /dev/null +++ b/tests/test-unamend.t @@ -0,0 +1,362 @@ +Test for command `hg unamend` which lives in uncommit extension +=== + + $ cat >> $HGRCPATH << EOF + > [alias] + > glog = log -G -T '{rev}:{node|short} {desc}' + > [experimental] + > evolution = createmarkers, allowunstable + > [extensions] + > rebase = + > amend = + > uncommit = + > EOF + +Repo Setup +- + + $ hg init repo + $ cd repo + $ for ch in {a..h}; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done + + $ hg glog + @ 7:ec2426147f0e Added h + | + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + +Trying to unamend when there was no amend done +-- + + $ hg unamend + abort: changeset must have one predecessor, found 0 predecessors + [255] + +Unamend on clean wdir and tip +-- + + $ echo "bar" >> h + $ hg amend + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID c9fa1a715c1b7661c0fafb362a9f30bd75878d7d + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r c9fa1a715c1b h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + + $ hg glog --hidden + @ 8:c9fa1a715c1b Added h + | + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg unamend + $ hg glog --hidden + @ 9:8da14a1fd653 Added h + | + | x 8:c9fa1a715c1b Added h + |/ + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg diff + diff -r 8da14a1fd653 h + --- a/h Thu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID 8da14a1fd653c3f07fdad5760511c9e12652a306 + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r 8da14a1fd653 h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,1 @@ + +foo + + $ hg status + M h + + $ hg log -r . -T '{extras % "{extra}\n"}' --config alias.log=log + branch=default + unamend_source=\xc9\xfa\x1aq\\\x1bva\xc0\xfa\xfb6*\x9f0\xbdu\x87\x8d} + +Unamend on a dirty working directory + + + $ hg ci -m "Added bar to h" + $ echo "bar" >> a + $ hg amend + $ echo "foobar" >> a + $ echo "bar" >> b + $ hg status + M a + M b + + $ hg unamend + + $ hg status + M a + M b + + $ hg diff + diff -r 49f03646f7a0 a + --- a/a Thu Jan 01 00:00:00 1970 + + +++ b/a Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,3 @@ + foo + +bar + +foobar + diff -r 49f03646f7a0 b + --- a/b Thu Jan 01 00:00:00 1970 + + +++ b/b Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + +Unamending an added file + + + $ hg ci -m "Added things to a and b" + $ echo foo > bar + $ hg add bar + $ hg amend + + $ hg unamend + $ hg status + A bar + + $ hg revert --all + forgetting bar + +Unamending a removed file +- + + $ hg remove a + $ hg amend + + $ hg unamend + $ hg status + R a + ? bar + + $ hg revert --all + undeleting a + +Unamending an added file with dirty wdir status +--- + + $ hg add bar + $ hg amend + $ echo bar >> bar + $ hg status + M bar + + $ hg unamend + $ hg status + A bar + $ hg diff + diff -r 738d71740456 bar + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/barThu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + + $ hg revert --all + forgetting bar + +Unamending in middle of a stack +--- + + $ hg glog + @ 19:738d71740456 Added things to a and b + | + o
D821: unamend: move fb extension unamend to core
durham accepted this revision. durham added a comment. Overall looks good to me. My one comment is probably not enough to block this going in. INLINE COMMENTS > uncommit.py:260 > +prednode = markers[0].prednode() > +predctx = unfi[prednode] > + Might be worth doing the predecessor check in the lock as well, since the result of this verification could technically change between now and when the lock is taken. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
pulkit added a comment. This is lying here from a long time. It will be good some feedback is given. :) REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
ryanmce added inline comments. INLINE COMMENTS > ryanmce wrote in uncommit.py:260 > Test test Tested nested comments, sorry for the spam. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
pulkit updated this revision to Diff 2493. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D821?vs=2128=2493 REVISION DETAIL https://phab.mercurial-scm.org/D821 AFFECTED FILES hgext/uncommit.py tests/test-unamend.t CHANGE DETAILS diff --git a/tests/test-unamend.t b/tests/test-unamend.t new file mode 100644 --- /dev/null +++ b/tests/test-unamend.t @@ -0,0 +1,362 @@ +Test for command `hg unamend` which lives in uncommit extension +=== + + $ cat >> $HGRCPATH << EOF + > [alias] + > glog = log -G -T '{rev}:{node|short} {desc}' + > [experimental] + > evolution = createmarkers, allowunstable + > [extensions] + > rebase = + > amend = + > uncommit = + > EOF + +Repo Setup +- + + $ hg init repo + $ cd repo + $ for ch in {a..h}; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done + + $ hg glog + @ 7:ec2426147f0e Added h + | + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + +Trying to unamend when there was no amend done +-- + + $ hg unamend + abort: changeset must have one predecessor, found 0 predecessors + [255] + +Unamend on clean wdir and tip +-- + + $ echo "bar" >> h + $ hg amend + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID c9fa1a715c1b7661c0fafb362a9f30bd75878d7d + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r c9fa1a715c1b h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + + $ hg glog --hidden + @ 8:c9fa1a715c1b Added h + | + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg unamend + $ hg glog --hidden + @ 9:8da14a1fd653 Added h + | + | x 8:c9fa1a715c1b Added h + |/ + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg diff + diff -r 8da14a1fd653 h + --- a/h Thu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID 8da14a1fd653c3f07fdad5760511c9e12652a306 + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r 8da14a1fd653 h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,1 @@ + +foo + + $ hg status + M h + + $ hg log -r . -T '{extras % "{extra}\n"}' --config alias.log=log + branch=default + unamend_source=\xc9\xfa\x1aq\\\x1bva\xc0\xfa\xfb6*\x9f0\xbdu\x87\x8d} + +Unamend on a dirty working directory + + + $ hg ci -m "Added bar to h" + $ echo "bar" >> a + $ hg amend + $ echo "foobar" >> a + $ echo "bar" >> b + $ hg status + M a + M b + + $ hg unamend + + $ hg status + M a + M b + + $ hg diff + diff -r 49f03646f7a0 a + --- a/a Thu Jan 01 00:00:00 1970 + + +++ b/a Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,3 @@ + foo + +bar + +foobar + diff -r 49f03646f7a0 b + --- a/b Thu Jan 01 00:00:00 1970 + + +++ b/b Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + +Unamending an added file + + + $ hg ci -m "Added things to a and b" + $ echo foo > bar + $ hg add bar + $ hg amend + + $ hg unamend + $ hg status + A bar + + $ hg revert --all + forgetting bar + +Unamending a removed file +- + + $ hg remove a + $ hg amend + + $ hg unamend + $ hg status + R a + ? bar + + $ hg revert --all + undeleting a + +Unamending an added file with dirty wdir status +--- + + $ hg add bar + $ hg amend + $ echo bar >> bar + $ hg status + M bar + + $ hg unamend + $ hg status + A bar + $ hg diff + diff -r 738d71740456 bar + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/barThu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + + $ hg revert --all + forgetting bar + +Unamending in middle of a stack +--- + + $ hg glog + @ 19:738d71740456 Added things to a and b + | + o
D821: unamend: move fb extension unamend to core
ryanmce added inline comments. INLINE COMMENTS > durham wrote in uncommit.py:260 > This should be in a with statement probably? Can we just have it be as part > of the top level lock with statement? Test test REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: ryanmce, singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
pulkit planned changes to this revision. pulkit added a comment. In https://phab.mercurial-scm.org/D821#14116, @singhsrb wrote: > I just wanted to mention that unamend command does not track copytrace information properly. That's a pretty good catch. Thanks a lot. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
singhsrb added a comment. I just wanted to mention that unamend command does not track copytrace information properly. For example, if we do: touch dummy hg commit -Aqm 'dummy' hg cp dummy dummy2 hg commit -Aqm 'dummy2' hg cp dummy2 dummy3 hg amend hg log -f dummy3 hg unamend hg amend hg log -f dummy3 Notice the difference in output on step 10 and 7. While 7 correctly records the copy information indicating that dummy3 was copied from dummy, 10 considers dummy3 a new file. We may want to fix this before taking unamend to core because the corresponding amend command does handle copytracing properly. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: singhsrb, durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
pulkit updated this revision to Diff 2128. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D821?vs=2092=2128 REVISION DETAIL https://phab.mercurial-scm.org/D821 AFFECTED FILES hgext/uncommit.py tests/test-unamend.t CHANGE DETAILS diff --git a/tests/test-unamend.t b/tests/test-unamend.t new file mode 100644 --- /dev/null +++ b/tests/test-unamend.t @@ -0,0 +1,289 @@ +Test for command `hg unamend` which lives in uncommit extension +=== + + $ cat >> $HGRCPATH << EOF + > [alias] + > glog = log -G -T '{rev}:{node|short} {desc}' + > [experimental] + > evolution = createmarkers, allowunstable + > [extensions] + > rebase = + > amend = + > uncommit = + > EOF + +Repo Setup +- + + $ hg init repo + $ cd repo + $ for ch in {a..h}; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done + + $ hg glog + @ 7:ec2426147f0e Added h + | + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + +Trying to unamend when there was no amend done +-- + + $ hg unamend + abort: changeset must have one predecessor, found 0 predecessors + [255] + +Unamend on clean wdir and tip +-- + + $ echo "bar" >> h + $ hg amend + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID c9fa1a715c1b7661c0fafb362a9f30bd75878d7d + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r c9fa1a715c1b h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + + $ hg glog --hidden + @ 8:c9fa1a715c1b Added h + | + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg unamend + $ hg glog --hidden + @ 9:8da14a1fd653 Added h + | + | x 8:c9fa1a715c1b Added h + |/ + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg diff + diff -r 8da14a1fd653 h + --- a/h Thu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID 8da14a1fd653c3f07fdad5760511c9e12652a306 + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r 8da14a1fd653 h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,1 @@ + +foo + + $ hg status + M h + + $ hg log -r . -T '{extras % "{extra}\n"}' --config alias.log=log + branch=default + unamend_source=\xc9\xfa\x1aq\\\x1bva\xc0\xfa\xfb6*\x9f0\xbdu\x87\x8d} + +Unamend on a dirty working directory + + + $ hg ci -m "Added bar to h" + $ echo "bar" >> a + $ hg amend + $ echo "foobar" >> a + $ echo "bar" >> b + $ hg status + M a + M b + + $ hg unamend + + $ hg status + M a + M b + + $ hg diff + diff -r 49f03646f7a0 a + --- a/a Thu Jan 01 00:00:00 1970 + + +++ b/a Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,3 @@ + foo + +bar + +foobar + diff -r 49f03646f7a0 b + --- a/b Thu Jan 01 00:00:00 1970 + + +++ b/b Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + +Unamending an added file + + + $ hg ci -m "Added things to a and b" + $ echo foo > bar + $ hg add bar + $ hg amend + + $ hg unamend + $ hg status + A bar + + $ hg revert --all + forgetting bar + +Unamending a removed file +- + + $ hg remove a + $ hg amend + + $ hg unamend + $ hg status + R a + ? bar + + $ hg revert --all + undeleting a + +Unamending an added file with dirty wdir status +--- + + $ hg add bar + $ hg amend + $ echo bar >> bar + $ hg status + M bar + + $ hg unamend + $ hg status + A bar + $ hg diff + diff -r 738d71740456 bar + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/barThu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + + $ hg revert --all + forgetting bar + +Unamending in middle of a stack +--- + + $ hg glog + @ 19:738d71740456 Added things to a and b + | + o
D821: unamend: move fb extension unamend to core
durham requested changes to this revision. durham added a comment. This revision now requires changes to proceed. Generally looks good. Just need to fix the transaction thing. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers, durham Cc: durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
durham added inline comments. INLINE COMMENTS > uncommit.py:260 > + > +tr = repo.transaction('unamend') > +with dirstate.parentchange(): This should be in a with statement probably? Can we just have it be as part of the top level lock with statement? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 To: pulkit, #hg-reviewers Cc: durham, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D821: unamend: move fb extension unamend to core
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY unamend extension adds an unamend command which undoes the effect of the amend command. This patch moves the unamend command from that extension to uncommit extension and this one does not completely undoes the effect of amend command as it creates a new commit, rather than reviving the old one back. This also adds tests for the same. .. feature:: A new unamend command in uncommit extension which undoes the effect of the amend command by creating a new changeset which was there before amend and moving the changes that were amended to the working directory. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D821 AFFECTED FILES hgext/uncommit.py tests/test-unamend.t CHANGE DETAILS diff --git a/tests/test-unamend.t b/tests/test-unamend.t new file mode 100644 --- /dev/null +++ b/tests/test-unamend.t @@ -0,0 +1,289 @@ +Test for command `hg unamend` which lives in uncommit extension +=== + + $ cat >> $HGRCPATH << EOF + > [alias] + > glog = log -G -T '{rev}:{node|short} {desc}' + > [experimental] + > evolution = createmarkers, allowunstable + > [extensions] + > rebase = + > amend = + > uncommit = + > EOF + +Repo Setup +- + + $ hg init repo + $ cd repo + $ for ch in {a..h}; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done + + $ hg glog + @ 7:ec2426147f0e Added h + | + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + +Trying to unamend when there was no amend done +-- + + $ hg unamend + abort: changeset must have one predecessor, found 0 predecessors + [255] + +Unamend on clean wdir and tip +-- + + $ echo "bar" >> h + $ hg amend + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID c9fa1a715c1b7661c0fafb362a9f30bd75878d7d + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r c9fa1a715c1b h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,2 @@ + +foo + +bar + + $ hg glog --hidden + @ 8:c9fa1a715c1b Added h + | + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg unamend + $ hg glog --hidden + @ 9:8da14a1fd653 Added h + | + | x 8:c9fa1a715c1b Added h + |/ + | x 7:ec2426147f0e Added h + |/ + o 6:87d6d6676308 Added g + | + o 5:825660c69f0c Added f + | + o 4:aa98ab95a928 Added e + | + o 3:62615734edd5 Added d + | + o 2:28ad74487de9 Added c + | + o 1:29becc82797a Added b + | + o 0:18d04c59bb5d Added a + + $ hg diff + diff -r 8da14a1fd653 h + --- a/h Thu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + + $ hg exp + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 + + # Node ID 8da14a1fd653c3f07fdad5760511c9e12652a306 + # Parent 87d6d66763085b629e6d7ed56778c79827273022 + Added h + + diff -r 87d6d6676308 -r 8da14a1fd653 h + --- /dev/nullThu Jan 01 00:00:00 1970 + + +++ b/h Thu Jan 01 00:00:00 1970 + + @@ -0,0 +1,1 @@ + +foo + + $ hg status + M h + + $ hg log -r . -T '{extras % "{extra}\n"}' --config alias.log=log + branch=default + unamend_source=\xc9\xfa\x1aq\\\x1bva\xc0\xfa\xfb6*\x9f0\xbdu\x87\x8d} + +Unamend on a dirty working directory + + + $ hg ci -m "Added bar to h" + $ echo "bar" >> a + $ hg amend + $ echo "foobar" >> a + $ echo "bar" >> b + $ hg status + M a + M b + + $ hg unamend + + $ hg status + M a + M b + + $ hg diff + diff -r 49f03646f7a0 a + --- a/a Thu Jan 01 00:00:00 1970 + + +++ b/a Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,3 @@ + foo + +bar + +foobar + diff -r 49f03646f7a0 b + --- a/b Thu Jan 01 00:00:00 1970 + + +++ b/b Thu Jan 01 00:00:00 1970 + + @@ -1,1 +1,2 @@ + foo + +bar + +Unamending an added file + + + $ hg ci -m "Added things to a and b" + $ echo foo > bar + $ hg add bar + $ hg amend + + $ hg unamend + $ hg status + A bar + + $ hg revert --all + forgetting bar + +Unamending a removed file +- + + $ hg remove a + $ hg amend + + $ hg unamend + $ hg status + R a + ? bar + + $ hg