D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-03-07 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @martinvonz cleaned it up .

REPOSITORY
  rHG Mercurial

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

To: taapas1128, #hg-reviewers
Cc: pulkit, martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-03-07 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 14387.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6005?vs=14386=14387

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

AFFECTED FILES
  hgext/uncommit.py
  tests/test-uncommit-interactive.t
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -34,6 +34,7 @@
   
   options ([+] can be repeated):
   
+   -i --interactive  interactive mode to uncommit
   --keep allow an empty commit after uncommiting
   --allow-dirty-working-copy allow uncommit with outstanding changes
-I --include PATTERN [+]  include names matching the given patterns
diff --git a/tests/test-uncommit-interactive.t 
b/tests/test-uncommit-interactive.t
new file mode 100644
--- /dev/null
+++ b/tests/test-uncommit-interactive.t
@@ -0,0 +1,969 @@
+
+||  The test for `hg uncommit --interactive`  ||
+
+
+Repo Setup
+
+
+  $ cat >> $HGRCPATH < [ui]
+  > interactive = true
+  > [experimental]
+  > evolution.createmarkers=True
+  > evolution.allowunstable=True
+  > uncommitondirtywdir = true
+  > [extensions]
+  > uncommit =
+  > amend =
+  > drawdag=$TESTDIR/drawdag.py
+  > EOF
+  $ glog() {
+  >   hg log -G --template '{rev}:{node|short}@{branch}({separate("/", 
obsolete, phase)}) {desc|firstline}\n' "$@"
+  > }
+
+  $ hg init repo
+  $ cd repo
+
+  $ touch a
+  $ cat >> a << EOF
+  > 1
+  > 2
+  > 3
+  > 4
+  > 5
+  > EOF
+
+  $ hg add a
+  $ hg ci -m "The base commit"
+
+Make sure aborting the interactive selection does no magic
+--
+
+  $ hg status
+  $ hg uncommit -i< q
+  > EOF
+  diff --git a/a b/a
+  new file mode 100644
+  examine changes to 'a'? [Ynesfdaq?] q
+  
+  abort: user quit
+  [255]
+  $ hg status
+
+Make a commit with multiple hunks
+-
+
+  $ cat > a << EOF
+  > -2
+  > -1
+  > 0
+  > 1
+  > 2
+  > 3
+  > foo
+  > bar
+  > 4
+  > 5
+  > babar
+  > EOF
+
+  $ hg diff
+  diff -r 7733902a8d94 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,5 +1,11 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  +babar
+
+  $ hg ci -m "another one"
+
+Not selecting anything to uncommit
+==
+
+  $ hg uncommit -i< y
+  > n
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+  abort: nothing selected to uncommit
+  [255]
+  $ hg status
+
+Uncommit a chunk
+
+
+  $ hg uncommit -i< y
+  > y
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+
+  $ hg log -G --hidden
+  @  changeset:   3:678a59e5ff90
+  |  tag: tip
+  |  parent:  0:7733902a8d94
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: another one
+  |
+  | x  changeset:   2:e9635f4beaf1
+  |/   parent:  0:7733902a8d94
+  |user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:pruned using uncommit
+  |summary: temporary commit for uncommiting f70fb463d5bf
+  |
+  | x  changeset:   1:f70fb463d5bf
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:rewritten using uncommit as 3:678a59e5ff90
+  |summary: another one
+  |
+  o  changeset:   0:7733902a8d94
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: The base commit
+  
+The unselected part should be in the diff
+-
+
+  $ hg diff
+  diff -r 678a59e5ff90 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+
+The commit should contain the rest of part
+--
+
+  $ hg exp
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #  Thu Jan 01 00:00:00 1970 +
+  # Node ID 678a59e5ff90754d5e94719bd82ad169be773c21
+  # Parent  7733902a8d94c789ca81d866bea1893d79442db6
+  

D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-03-07 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 14386.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6005?vs=14385=14386

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

AFFECTED FILES
  hgext/uncommit.py
  tests/test-uncommit-interactive.t
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -34,6 +34,7 @@
   
   options ([+] can be repeated):
   
+   -i --interactive  interactive mode to uncommit
   --keep allow an empty commit after uncommiting
   --allow-dirty-working-copy allow uncommit with outstanding changes
-I --include PATTERN [+]  include names matching the given patterns
diff --git a/tests/test-uncommit-interactive.t 
b/tests/test-uncommit-interactive.t
new file mode 100644
--- /dev/null
+++ b/tests/test-uncommit-interactive.t
@@ -0,0 +1,969 @@
+
+||  The test for `hg uncommit --interactive`  ||
+
+
+Repo Setup
+
+
+  $ cat >> $HGRCPATH < [ui]
+  > interactive = true
+  > [experimental]
+  > evolution.createmarkers=True
+  > evolution.allowunstable=True
+  > uncommitondirtywdir = true
+  > [extensions]
+  > uncommit =
+  > amend =
+  > drawdag=$TESTDIR/drawdag.py
+  > EOF
+  $ glog() {
+  >   hg log -G --template '{rev}:{node|short}@{branch}({separate("/", 
obsolete, phase)}) {desc|firstline}\n' "$@"
+  > }
+
+  $ hg init repo
+  $ cd repo
+
+  $ touch a
+  $ cat >> a << EOF
+  > 1
+  > 2
+  > 3
+  > 4
+  > 5
+  > EOF
+
+  $ hg add a
+  $ hg ci -m "The base commit"
+
+Make sure aborting the interactive selection does no magic
+--
+
+  $ hg status
+  $ hg uncommit -i< q
+  > EOF
+  diff --git a/a b/a
+  new file mode 100644
+  examine changes to 'a'? [Ynesfdaq?] q
+  
+  abort: user quit
+  [255]
+  $ hg status
+
+Make a commit with multiple hunks
+-
+
+  $ cat > a << EOF
+  > -2
+  > -1
+  > 0
+  > 1
+  > 2
+  > 3
+  > foo
+  > bar
+  > 4
+  > 5
+  > babar
+  > EOF
+
+  $ hg diff
+  diff -r 7733902a8d94 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,5 +1,11 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  +babar
+
+  $ hg ci -m "another one"
+
+Not selecting anything to uncommit
+==
+
+  $ hg uncommit -i< y
+  > n
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+  abort: nothing selected to uncommit
+  [255]
+  $ hg status
+
+Uncommit a chunk
+
+
+  $ hg uncommit -i< y
+  > y
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+
+  $ hg log -G --hidden
+  @  changeset:   3:678a59e5ff90
+  |  tag: tip
+  |  parent:  0:7733902a8d94
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: another one
+  |
+  | x  changeset:   2:e9635f4beaf1
+  |/   parent:  0:7733902a8d94
+  |user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:pruned using uncommit
+  |summary: temporary commit for uncommiting f70fb463d5bf
+  |
+  | x  changeset:   1:f70fb463d5bf
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:rewritten using uncommit as 3:678a59e5ff90
+  |summary: another one
+  |
+  o  changeset:   0:7733902a8d94
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: The base commit
+  
+The unselected part should be in the diff
+-
+
+  $ hg diff
+  diff -r 678a59e5ff90 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+
+The commit should contain the rest of part
+--
+
+  $ hg exp
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #  Thu Jan 01 00:00:00 1970 +
+  # Node ID 678a59e5ff90754d5e94719bd82ad169be773c21
+  # Parent  7733902a8d94c789ca81d866bea1893d79442db6
+  

D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-03-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  As I said a while ago on IRC, it feels like `_fixdirstate()` should not need 
an `interactive` flag, and it should not even need to be specifically for 
uncommit. It feels like it should work the same for any case where we move to a 
different commit without changing the working copy, such as uncommit, unamend, 
amend, fix (though we may want optimized code paths for some of them). So I 
took this patch and tried the most naive attempt at unifying the interactive 
version with the non-interactive version, namely to just drop the code for the 
interactive path (see patch below). Surprisingly, all tests pass :) So maybe 
you can just apply the below patch and clean it up (drop the `if True`), or 
maybe you need to add tests.
  
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -109,59 +109,10 @@ def _fixdirstate(repo, oldctx, newctx, m
 oldctx to a copy of oldctx not containing changed files matched by
 match.
 """
-ctx = repo['.']
 ds = repo.dirstate
 ds.setparents(newctx.node(), node.nullid)
 copies = dict(ds.copies())
-if interactive:
-# In interactive cases, we will find the status between oldctx and 
ctx
-# and considering only the files which are changed between oldctx 
and
-# ctx, and the status of what changed between oldctx and ctx will 
help
-# us in defining the exact behavior
-s = oldctx.status(ctx, match=match)
-for f in s.modified:
-# These are files which are modified between oldctx and ctx 
which
-# contains two cases: 1) Were modified in oldctx and some
-# modifications are uncommitted
-# 2) Were added in oldctx but some part is uncommitted (this 
cannot
-# contain the case when added files are uncommitted completely 
as
-# that will result in status as removed not modified.)
-# Also any modifications to a removed file will result the 
status as
-# added, so we have only two cases. So in either of the cases, 
the
-# resulting status can be modified or clean.
-if ds[f] == 'r':
-# But the file is removed in the working directory, 
leaving that
-# as removed
-continue
-ds.normallookup(f)
-
-for f in s.added:
-# These are the files which are added between oldctx and 
ctx(new
-# one), which means the files which were removed in oldctx
-# but uncommitted completely while making the ctx
-# This file should be marked as removed if the working 
directory
-# does not adds it back. If it's adds it back, we do a 
normallookup.
-# The file can't be removed in working directory, because it 
was
-# removed in oldctx
-if ds[f] == 'a':
-ds.normallookup(f)
-continue
-ds.remove(f)
-
-for f in s.removed:
-# These are files which are removed between oldctx and ctx, 
which
-# means the files which were added in oldctx and were 
completely
-# uncommitted in ctx. If a added file is partially 
uncommitted, that
-# would have resulted in modified status, not removed.
-# So a file added in a commit, and uncommitting that addition 
must
-# result in file being stated as unknown.
-if ds[f] == 'r':
-# The working directory say it's removed, so lets make the 
file
-# unknown
-ds.drop(f)
-continue
-ds.add(f)
-else:
+if True:
 s = newctx.status(oldctx, match=match)
 for f in s.modified:
 if ds[f] == 'r':

REPOSITORY
  rHG Mercurial

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

To: taapas1128, #hg-reviewers
Cc: pulkit, martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-03-07 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 14385.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6005?vs=14278=14385

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

AFFECTED FILES
  hgext/uncommit.py
  tests/test-uncommit-interactive.t
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -34,6 +34,7 @@
   
   options ([+] can be repeated):
   
+   -i --interactive  interactive mode to uncommit
   --keep allow an empty commit after uncommiting
   --allow-dirty-working-copy allow uncommit with outstanding changes
-I --include PATTERN [+]  include names matching the given patterns
diff --git a/tests/test-uncommit-interactive.t 
b/tests/test-uncommit-interactive.t
new file mode 100644
--- /dev/null
+++ b/tests/test-uncommit-interactive.t
@@ -0,0 +1,969 @@
+
+||  The test for `hg uncommit --interactive`  ||
+
+
+Repo Setup
+
+
+  $ cat >> $HGRCPATH < [ui]
+  > interactive = true
+  > [experimental]
+  > evolution.createmarkers=True
+  > evolution.allowunstable=True
+  > uncommitondirtywdir = true
+  > [extensions]
+  > uncommit =
+  > amend =
+  > drawdag=$TESTDIR/drawdag.py
+  > EOF
+  $ glog() {
+  >   hg log -G --template '{rev}:{node|short}@{branch}({separate("/", 
obsolete, phase)}) {desc|firstline}\n' "$@"
+  > }
+
+  $ hg init repo
+  $ cd repo
+
+  $ touch a
+  $ cat >> a << EOF
+  > 1
+  > 2
+  > 3
+  > 4
+  > 5
+  > EOF
+
+  $ hg add a
+  $ hg ci -m "The base commit"
+
+Make sure aborting the interactive selection does no magic
+--
+
+  $ hg status
+  $ hg uncommit -i< q
+  > EOF
+  diff --git a/a b/a
+  new file mode 100644
+  examine changes to 'a'? [Ynesfdaq?] q
+  
+  abort: user quit
+  [255]
+  $ hg status
+
+Make a commit with multiple hunks
+-
+
+  $ cat > a << EOF
+  > -2
+  > -1
+  > 0
+  > 1
+  > 2
+  > 3
+  > foo
+  > bar
+  > 4
+  > 5
+  > babar
+  > EOF
+
+  $ hg diff
+  diff -r 7733902a8d94 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,5 +1,11 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  +babar
+
+  $ hg ci -m "another one"
+
+Not selecting anything to uncommit
+==
+
+  $ hg uncommit -i< y
+  > n
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+  abort: nothing selected to uncommit
+  [255]
+  $ hg status
+
+Uncommit a chunk
+
+
+  $ hg uncommit -i< y
+  > y
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+
+  $ hg log -G --hidden
+  @  changeset:   3:678a59e5ff90
+  |  tag: tip
+  |  parent:  0:7733902a8d94
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: another one
+  |
+  | x  changeset:   2:e9635f4beaf1
+  |/   parent:  0:7733902a8d94
+  |user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:pruned using uncommit
+  |summary: temporary commit for uncommiting f70fb463d5bf
+  |
+  | x  changeset:   1:f70fb463d5bf
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:rewritten using uncommit as 3:678a59e5ff90
+  |summary: another one
+  |
+  o  changeset:   0:7733902a8d94
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: The base commit
+  
+The unselected part should be in the diff
+-
+
+  $ hg diff
+  diff -r 678a59e5ff90 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+
+The commit should contain the rest of part
+--
+
+  $ hg exp
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #  Thu Jan 01 00:00:00 1970 +
+  # Node ID 678a59e5ff90754d5e94719bd82ad169be773c21
+  # Parent  7733902a8d94c789ca81d866bea1893d79442db6
+  

D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-02-28 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked an inline comment as done.
taapas1128 added a comment.


  @pulkit Thanks for pointing that out . That was extremely silly of me . I 
have corrected that . Is there anything else to be changed ?

REPOSITORY
  rHG Mercurial

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

To: taapas1128, #hg-reviewers
Cc: pulkit, martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-02-28 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 14278.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6005?vs=14193=14278

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

AFFECTED FILES
  hgext/uncommit.py
  tests/test-uncommit-interactive.t
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -34,6 +34,7 @@
   
   options ([+] can be repeated):
   
+   -i --interactive interactive mode to uncommit
   --keepallow an empty commit after uncommiting
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
diff --git a/tests/test-uncommit-interactive.t 
b/tests/test-uncommit-interactive.t
new file mode 100644
--- /dev/null
+++ b/tests/test-uncommit-interactive.t
@@ -0,0 +1,969 @@
+
+||  The test for `hg uncommit --interactive`  ||
+
+
+Repo Setup
+
+
+  $ cat >> $HGRCPATH < [ui]
+  > interactive = true
+  > [experimental]
+  > evolution.createmarkers=True
+  > evolution.allowunstable=True
+  > uncommitondirtywdir = true
+  > [extensions]
+  > uncommit =
+  > amend =
+  > drawdag=$TESTDIR/drawdag.py
+  > EOF
+  $ glog() {
+  >   hg log -G --template '{rev}:{node|short}@{branch}({separate("/", 
obsolete, phase)}) {desc|firstline}\n' "$@"
+  > }
+
+  $ hg init repo
+  $ cd repo
+
+  $ touch a
+  $ cat >> a << EOF
+  > 1
+  > 2
+  > 3
+  > 4
+  > 5
+  > EOF
+
+  $ hg add a
+  $ hg ci -m "The base commit"
+
+Make sure aborting the interactive selection does no magic
+--
+
+  $ hg status
+  $ hg uncommit -i< q
+  > EOF
+  diff --git a/a b/a
+  new file mode 100644
+  examine changes to 'a'? [Ynesfdaq?] q
+  
+  abort: user quit
+  [255]
+  $ hg status
+
+Make a commit with multiple hunks
+-
+
+  $ cat > a << EOF
+  > -2
+  > -1
+  > 0
+  > 1
+  > 2
+  > 3
+  > foo
+  > bar
+  > 4
+  > 5
+  > babar
+  > EOF
+
+  $ hg diff
+  diff -r 7733902a8d94 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,5 +1,11 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  +babar
+
+  $ hg ci -m "another one"
+
+Not selecting anything to uncommit
+==
+
+  $ hg uncommit -i< y
+  > n
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+  abort: nothing selected to uncommit
+  [255]
+  $ hg status
+
+Uncommit a chunk
+
+
+  $ hg uncommit -i< y
+  > y
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+
+  $ hg log -G --hidden
+  @  changeset:   3:678a59e5ff90
+  |  tag: tip
+  |  parent:  0:7733902a8d94
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: another one
+  |
+  | x  changeset:   2:e9635f4beaf1
+  |/   parent:  0:7733902a8d94
+  |user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:pruned using uncommit
+  |summary: temporary commit for uncommiting f70fb463d5bf
+  |
+  | x  changeset:   1:f70fb463d5bf
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:rewritten using uncommit as 3:678a59e5ff90
+  |summary: another one
+  |
+  o  changeset:   0:7733902a8d94
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: The base commit
+  
+The unselected part should be in the diff
+-
+
+  $ hg diff
+  diff -r 678a59e5ff90 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+
+The commit should contain the rest of part
+--
+
+  $ hg exp
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #  Thu Jan 01 00:00:00 1970 +
+  # Node ID 678a59e5ff90754d5e94719bd82ad169be773c21
+  # Parent  7733902a8d94c789ca81d866bea1893d79442db6
+  another one
+  
+  

D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-02-28 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> uncommit.py:101
>  ds = repo.dirstate
> -ds.setparents(newctx.node(), node.nullid)
>  copies = dict(ds.copies())

I just skimmed through changes and looks like this is missing in the changed 
version.

REPOSITORY
  rHG Mercurial

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

To: taapas1128, #hg-reviewers
Cc: pulkit, martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-02-28 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a subscriber: pulkit.
taapas1128 added a comment.


  @pulkit I am unable to figure out why the output for `test-unamend.t` is 
changing . Any hint on that ?

REPOSITORY
  rHG Mercurial

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

To: taapas1128, #hg-reviewers
Cc: pulkit, martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-02-22 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked 4 inline comments as done.
taapas1128 added a comment.


  @martinvonz I made the changes you asked . However I am not sure why 
`test-unamend.t` is changing because when `interactive` is false so it should 
behave exactly like the previous `_fixdirstate()` functioned . Can you provide 
some help with this ? I will work further based on your review.

REPOSITORY
  rHG Mercurial

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

To: taapas1128, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6005: uncommit: added interactive mode and modified fixdirstate(issue6062)

2019-02-22 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 14193.
taapas1128 retitled this revision from "uncommit: added interactive mode and 
removed _fixdirstate(issue6062)" to "uncommit: added interactive mode and 
modified fixdirstate(issue6062)".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6005?vs=14192=14193

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

AFFECTED FILES
  hgext/uncommit.py
  tests/test-unamend.t
  tests/test-uncommit-interactive.t
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -34,6 +34,7 @@
   
   options ([+] can be repeated):
   
+   -i --interactive interactive mode to uncommit
   --keepallow an empty commit after uncommiting
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
diff --git a/tests/test-uncommit-interactive.t 
b/tests/test-uncommit-interactive.t
new file mode 100644
--- /dev/null
+++ b/tests/test-uncommit-interactive.t
@@ -0,0 +1,969 @@
+
+||  The test for `hg uncommit --interactive`  ||
+
+
+Repo Setup
+
+
+  $ cat >> $HGRCPATH < [ui]
+  > interactive = true
+  > [experimental]
+  > evolution.createmarkers=True
+  > evolution.allowunstable=True
+  > uncommitondirtywdir = true
+  > [extensions]
+  > uncommit =
+  > amend =
+  > drawdag=$TESTDIR/drawdag.py
+  > EOF
+  $ glog() {
+  >   hg log -G --template '{rev}:{node|short}@{branch}({separate("/", 
obsolete, phase)}) {desc|firstline}\n' "$@"
+  > }
+
+  $ hg init repo
+  $ cd repo
+
+  $ touch a
+  $ cat >> a << EOF
+  > 1
+  > 2
+  > 3
+  > 4
+  > 5
+  > EOF
+
+  $ hg add a
+  $ hg ci -m "The base commit"
+
+Make sure aborting the interactive selection does no magic
+--
+
+  $ hg status
+  $ hg uncommit -i< q
+  > EOF
+  diff --git a/a b/a
+  new file mode 100644
+  examine changes to 'a'? [Ynesfdaq?] q
+  
+  abort: user quit
+  [255]
+  $ hg status
+
+Make a commit with multiple hunks
+-
+
+  $ cat > a << EOF
+  > -2
+  > -1
+  > 0
+  > 1
+  > 2
+  > 3
+  > foo
+  > bar
+  > 4
+  > 5
+  > babar
+  > EOF
+
+  $ hg diff
+  diff -r 7733902a8d94 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,5 +1,11 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  +babar
+
+  $ hg ci -m "another one"
+
+Not selecting anything to uncommit
+==
+
+  $ hg uncommit -i< y
+  > n
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+  abort: nothing selected to uncommit
+  [255]
+  $ hg status
+
+Uncommit a chunk
+
+
+  $ hg uncommit -i< y
+  > y
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+
+  $ hg log -G --hidden
+  @  changeset:   3:678a59e5ff90
+  |  tag: tip
+  |  parent:  0:7733902a8d94
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: another one
+  |
+  | x  changeset:   2:e9635f4beaf1
+  |/   parent:  0:7733902a8d94
+  |user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:pruned using uncommit
+  |summary: temporary commit for uncommiting f70fb463d5bf
+  |
+  | x  changeset:   1:f70fb463d5bf
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:rewritten using uncommit as 3:678a59e5ff90
+  |summary: another one
+  |
+  o  changeset:   0:7733902a8d94
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: The base commit
+  
+The unselected part should be in the diff
+-
+
+  $ hg diff
+  diff -r 678a59e5ff90 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+
+The commit should contain the rest of part
+--
+
+  $ hg exp
+  # HG changeset