D5792: uncommit: added interactive mode(issue6062)

2019-02-21 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D5792#87534, @taapas1128 wrote:
  
  > @martinvonz Sure I will try to unify `_fixdirstate()` and 
`_uncommitdirstate()`. I will follow on the advancements you made. Should I 
send the new patch as a follow up or and altogether new patch making the amends 
in this?
  
  
  A new patch please (I've dropped this version). Just pull from the 
hg-commited repo and make sure it applies there. Note that you'll probably get 
an obsmarker when you pull, so you may need to `hg touch` some version of this 
commit in your repo to revive it.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-21 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @martinvonz Sure I will try to unify `_fixdirstate()` and 
`_uncommitdirstate()`. I will follow on the advancements you made. Should I 
send the new patch as a follow up or and altogether new patch making the amends 
in this?

INLINE COMMENTS

> martinvonz wrote in uncommit.py:273
> Unnecessary (done on line 269)

Will look into it.

> martinvonz wrote in uncommit.py:288
> Why did this moved here? I just moved it down in 
> https://phab.mercurial-scm.org/D5660. I really should have written a better 
> commit message explaining what the problem was. But it's also unclear why it 
> should be moved back.

Oh that was a mistake made due to rebasing on top . I will shift that back.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-21 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  I'll drop this patch from the queue because I think there's a lot that can be 
cleaned up. I tried to re-unify `_fixdirstate()` and `_uncommitdirstate()` 
myself. This is my first step:
  
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -138,7 +138,7 @@ def _fixdirstate(repo, oldctx, newctx, m
 ds.copy(src, dst)
 
 
-def _uncommitdirstate(repo, oldctx, match, interactive):
+def _uncommitdirstate(repo, oldctx, newctx, match, interactive):
 """Fix the dirstate after switching the working directory from
 oldctx to a copy of oldctx not containing changed files matched by
 match.
@@ -217,21 +217,13 @@ def _uncommitdirstate(repo, oldctx, matc
 ds.remove(f)
 
 # Merge old parent and old working dir copies
-oldcopies = {}
-if interactive:
-# Interactive had different meaning of the variables so restoring 
the
-# original meaning to use them
-m, a, r = repo.status(oldctx.p1(), oldctx, match=match)[:3]
-for f in (m + a):
-src = oldctx[f].renamed()
-if src:
-oldcopies[f] = src[0]
+oldcopies = copiesmod.pathcopies(newctx, oldctx, match)
 oldcopies.update(copies)
 copies = dict((dst, oldcopies.get(src, src))
   for dst, src in oldcopies.iteritems())
 # Adjust the dirstate copies
 for dst, src in copies.iteritems():
-if (src not in ctx or dst in ctx or ds[dst] != 'a'):
+if (src not in newctx or dst in newctx or ds[dst] != 'a'):
 src = None
 ds.copy(src, dst)
 
@@ -285,11 +277,11 @@ def uncommit(ui, repo, *pats, **opts):
 # Fully removed the old commit
 mapping[old.node()] = ()
 
-scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True)
-
 with repo.dirstate.parentchange():
 repo.dirstate.setparents(newid, node.nullid)
-_uncommitdirstate(repo, old, match, interactive)
+_uncommitdirstate(repo, old, repo[newid], match, 
interactive)
+
+scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True)
 
 def _interactiveuncommit(ui, repo, old, match):
 """ The function which contains all the logic for interactively 
uncommiting
  
  Is there a reason that's broken? Tests seem to pass (test-uncommit.t passes). 
If not, could you try to continue in the direction of unifying the two method 
again?

INLINE COMMENTS

> uncommit.py:141
> +
> +def _uncommitdirstate(repo, oldctx, match, interactive):
> +"""Fix the dirstate after switching the working directory from

Much of this duplicates `_fixdirstate()`. We must be able to share some of this 
code.

> uncommit.py:273
> +if interactive:
> +match = scmutil.match(old, pats, opts)
> +newid = _interactiveuncommit(ui, repo, old, match)

Unnecessary (done on line 269)

> uncommit.py:288
>  
> +scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True)
> +

Why did this moved here? I just moved it down in 
https://phab.mercurial-scm.org/D5660. I really should have written a better 
commit message explaining what the problem was. But it's also unclear why it 
should be moved back.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-20 Thread taapas1128 (Taapas Agrawal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGedd5c8dc812e: uncommit: added interactive mode(issue6062) 
(authored by taapas1128, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5792?vs=14139=14144

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

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 

D5792: uncommit: added interactive mode(issue6062)

2019-02-19 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @durin42 please review this whenever you are free.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  Thank you for the help @pulkit . I have rebased it to the top.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 14139.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5792?vs=14132=14139

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

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
+  
+  

D5792: uncommit: added interactive mode(issue6062)

2019-02-18 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  In https://phab.mercurial-scm.org/D5792#87320, @taapas1128 wrote:
  
  > @durin42 I have sent the patch for `hg-stable` repo 
(https://www.mercurial-scm.org/repo/hg-stable) . Maybe it is this the reason 
you are unable to apply the patch. Should I send a patch for `hg` repo ?
  
  
  Yes, you should rebase your patch on default branch of `hg` repo. You don't 
need to clone again, you can pull from  https://mercurial-scm.org/hg and then 
rebase.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-17 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @durin42 I have sent the patch from `hg-stable` 
(https://www.mercurial-scm.org/repo/hg-stable) . Maybe it is this reason you 
are unable to apply the patch. Should I send a patch for `hg` repo ?

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-17 Thread durin42 (Augie Fackler)
durin42 added a comment.


  Anything recent. @ on https://mercurial-scm.org/hg is fine.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-17 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @durin42 to which rev should I rebase it to ?

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

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


  @durin42 I have made the change. Please review.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-15 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 14132.
taapas1128 edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5792?vs=13915=14132

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

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  

D5792: uncommit: added interactive mode(issue6062)

2019-02-15 Thread durin42 (Augie Fackler)
durin42 requested changes to this revision.
durin42 added a comment.
This revision now requires changes to proceed.


  I'd fix this one style nit in flight (this actually looks good), but it no 
longer applies - could you rebase it for me?

INLINE COMMENTS

> uncommit.py:321
> +return newnode
> +def _createtempcommit(ui, repo, old, match):
> +""" Creates a temporary commit for `uncommit --interative` which contains

Need an extra blank line here.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-15 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  In https://phab.mercurial-scm.org/D5792#87115, @taapas1128 wrote:
  
  > @pulkit I have updated the description .
  
  
  Great thanks! As mentioned before I will let someone else review this :)

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-15 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @pulkit I have updated the description .

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-14 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  The import looks fine to me. I will let someone else review the code because 
I authored this code in first place in evolve extension. Also it will be nice 
if you specify that the code is imported from evolve extension and also specify 
the commit hash from which you imported.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-12 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @pulkit Can you please review this . I did not send a patch regarding `-n` 
flag because tests could be completed without it and also it would mean i would 
have to import large chunks of code.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @pulkit Apparently it seems removing `-n` flag altogether will not interfere 
with the tests and they can be completed without that flag too . I have added 
inline comments please review.

INLINE COMMENTS

> test-uncommit-interactive.t:134
> +
> +
> +  $ hg uncommit -i< test-uncommit-interactive.t:253
> +   3
> +
> +  $ hg uncommit -i

D5792: uncommit: added interactive mode(issue6062)

2019-02-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 13915.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5792?vs=13738=13915

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

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
+  
+  

D5792: uncommit: added interactive mode(issue6062)

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


  @pulkit I have added some inline comments . So what do you suggest one way 
can be merging this and I will send a follow up for integrating `-n` to `hg 
uncommit`and then amending the tests. The other way is I should send a request 
for `-n` flag and then make all these changes again as a follow up pr for that 
request.

INLINE COMMENTS

> test-uncommit-interactive.t:135
> +
> +  $ hg amend --extract -n "note on amend --extract" -i< +  > y

`hg amend --extract` uses `-n` flag here so it cant be completed with `hg 
uncommit` alone `-n` integration will be necessary. Also `hg obslog` is the 
same test so without this it can also not be replaced.

> test-uncommit-interactive.t:208
> +
> +  $ hg uncommit -n "testing uncommit on dirty wdir" -i< +  > y

Same problem here.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-07 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  In https://phab.mercurial-scm.org/D5792#85236, @taapas1128 wrote:
  
  > @pulkit I was able to import the tests and make them compatible with 
`hg-stable` . Some tests which include commands like `hg obslog` , `hg amend 
--extract` , and `hg uncommit -n` which are not part of `hg-stable` but 
`evolve` are not running else all tests are now running smoothly .
  
  
  `hg amend --extract` is just another name for `hg uncommit`.
  You can move `--note` flag to core uncommit as a part of different patch.
  Related to obslog, you can do `hg log -r . -r precursor(.)` or `hg diff -r . 
-r precursor(.)` but I don't think that will be sufficient.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-04 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @pulkit I was able to import the tests and make them compatible with 
`hg-stable` . Some tests which include commands like `hg obslog` , `hg amend 
--extract` , and `hg uncommit -n` which are not part of `hg-stable` but 
`evolve` are not running else all tests are now running smoothly .

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-04 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 13738.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5792?vs=13737=13738

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

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,873 @@
+
+||  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 amend --extract -n "note on amend --extract" -i< y
+  > y
+  > n
+  > n
+  > EOF
+  hg amend: option --extract not recognized
+  hg amend [OPTION]... [FILE]...
+  
+  amend the working copy parent with all or specified outstanding changes
+  
+  (use 'hg help -e amend' to show help for the amend extension)
+  
+  options ([+] can be repeated):
+  
+   -A --addremove   mark new/missing files as added/removed before
+committing
+   -e --editinvoke editor on commit messages
+   -i --interactive use interactive mode
+   -n --note VALUE  store a note on the amend
+   -I --include PATTERN [+] include names matching the given patterns
+   -X --exclude PATTERN [+] exclude names matching the given patterns
+   -m --message TEXTuse text as commit message
+   -l --logfile FILEread commit message from file
+   -d --date DATE   record the specified date as commit date
+   -u --user USER   record the specified user as committer
+  
+  (use 'hg amend -h' to show more help)
+  [255]
+
+  $ hg obslog
+  hg: unknown command 'obslog'
+  (did you mean log?)
+  [255]
+The unselected part should be in the diff
+-
+
+  $ hg diff
+
+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 f70fb463d5bf9f0ffd38f105521d96e9f2591bc1
+  # Parent  7733902a8d94c789ca81d866bea1893d79442db6
+  another one
+  
+  diff -r 7733902a8d94 -r f70fb463d5bf 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
+
+Uncommiting on dirty working directory
+==
+
+  $ 

D5792: uncommit: added interactive mode(issue6062)

2019-02-04 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 13737.
taapas1128 edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5792?vs=13701=13737

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

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
@@ -1,6 +1,8 @@
 Test uncommit - set up the config
 
   $ cat >> $HGRCPATH < [ui]
+  > interactive = true
   > [experimental]
   > evolution.createmarkers=True
   > evolution.allowunstable=True
@@ -34,6 +36,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
@@ -398,3 +401,15 @@
   |/
   o  0:ea4e33293d4d274a2ba73150733c2612231f398c a 1
   
+Test for interactive mode
+  $ hg init repo3
+  $ touch x
+  $ hg add x
+  $ hg commit -m "added x"
+  $ hg uncommit -i< y
+  > EOF
+  diff --git a/x b/x
+  new file mode 100644
+  examine changes to 'x'? [Ynesfdaq?] y
+  
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,873 @@
+
+||  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 amend --extract -n "note on amend --extract" -i< y
+  > y
+  > n
+  > n
+  > EOF
+  hg amend: option --extract not recognized
+  hg amend [OPTION]... [FILE]...
+  
+  amend the working copy parent with all or specified outstanding changes
+  
+  (use 'hg help -e amend' to show help for the amend extension)
+  
+  options ([+] can be repeated):
+  
+   -A --addremove   mark new/missing files as added/removed before
+committing
+   -e --editinvoke editor on commit messages
+   -i --interactive use interactive mode
+   -n --note VALUE  store a note on the amend
+   -I --include PATTERN [+] include names matching the given patterns
+   -X --exclude PATTERN [+] exclude names matching the given patterns
+   -m --message TEXTuse text as commit message
+   -l --logfile FILEread commit message from file
+   -d --date DATE   record the specified date as commit date
+   -u --user USER   record the specified user as committer
+  
+  (use 'hg amend -h' to show more help)
+  [255]
+
+  $ hg obslog
+  hg: unknown command 'obslog'
+  (did you mean log?)
+  [255]
+The unselected part should be in the diff
+-
+
+  $ hg diff
+
+The commit should contain the rest of part
+--
+
+  $ 

D5792: uncommit: added interactive mode(issue6062)

2019-02-03 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  In https://phab.mercurial-scm.org/D5792#85088, @taapas1128 wrote:
  
  > @pulkit I have made an attempt to import the code please review. 
@lothiraldan  can you please review and help me if I have missed out any 
portion of interactive from `evolve`
  
  
  @taapas1128 haven't looked at the code in detail yet, but there are tests in 
evolve which should also be moved.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

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


  @pulkit I have made an attempt to import the code please review. @lothiraldan 
 can you please review and help me if I have missed out any portion of 
interactive from `evolve`

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5792?vs=13669=13701

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

AFFECTED FILES
  hgext/uncommit.py
  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
@@ -1,6 +1,8 @@
 Test uncommit - set up the config
 
   $ cat >> $HGRCPATH < [ui]
+  > interactive = true
   > [experimental]
   > evolution.createmarkers=True
   > evolution.allowunstable=True
@@ -34,6 +36,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
@@ -398,3 +401,15 @@
   |/
   o  0:ea4e33293d4d274a2ba73150733c2612231f398c a 1
   
+Test for interactive mode
+  $ hg init repo3
+  $ touch x
+  $ hg add x
+  $ hg commit -m "added x"
+  $ hg uncommit -i< y
+  > EOF
+  diff --git a/x b/x
+  new file mode 100644
+  examine changes to 'x'? [Ynesfdaq?] y
+  
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -28,11 +28,14 @@
 copies,
 error,
 node,
+obsolete,
 obsutil,
+patch,
 pycompat,
 registrar,
 rewriteutil,
 scmutil,
+util,
 )
 
 cmdtable = {}
@@ -45,6 +48,8 @@
 default=False,
 )
 
+stringio = util.stringio
+
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' 
for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
@@ -135,8 +140,107 @@
 src = None
 ds.copy(src, dst)
 
+
+def _uncommitdirstate(repo, oldctx, match, interactive):
+"""Fix the dirstate after switching the working directory from
+oldctx to a copy of oldctx not containing changed files matched by
+match.
+"""
+ctx = repo['.']
+ds = repo.dirstate
+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
+m, a, r = repo.status(oldctx, ctx, match=match)[:3]
+for f in m:
+# 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 a:
+# 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 r:
+# 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:
+m, a, r = repo.status(oldctx.p1(), oldctx, match=match)[:3]
+for f in m:
+if ds[f] == 'r':
+# modified + removed -> removed
+continue
+ds.normallookup(f)
+
+for f in a:
+   

D5792: uncommit: added interactive mode(issue6062)

2019-02-01 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  In https://phab.mercurial-scm.org/D5792#84959, @taapas1128 wrote:
  
  > Thanks for the review @pulkit . By importing do you suggest importing the 
code for interactive or someway is there is someway to link `evolve` to 
`hg-stable` ?
  
  
  I mean importing the code.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-01 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  Thanks for the review @pulkit . By importing do you suggest importing the 
code for interactive or someway is there is someway to link `evolve` to 
`hg-stable` ?

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-02-01 Thread pulkit (Pulkit Goyal)
pulkit added subscribers: lothiraldan, pulkit.
pulkit added a comment.


  Hi, thanks for the patch. Your patch is a good start at implementing 
`uncommit -i`. It misses multiple things like dirstate handling.
  
  The good news is that you don't need to implement all that.  There is an 
evolve extension which has already implemented that: 
https://www.mercurial-scm.org/repo/evolve/file/8494015ec24b/hgext3rd/evolve/cmdrewrite.py#l460.
 You can import that from there.
  
  If you plan to import that from there, I suggest notifying @lothiraldan about 
that too so that they can manage things in evolve.

REPOSITORY
  rHG Mercurial

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

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


D5792: uncommit: added interactive mode(issue6062)

2019-01-31 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 13669.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5792?vs=13668=13669

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

AFFECTED FILES
  hgext/uncommit.py
  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
@@ -1,6 +1,8 @@
 Test uncommit - set up the config
 
   $ cat >> $HGRCPATH < [ui]
+  > interactive = true
   > [experimental]
   > evolution.createmarkers=True
   > evolution.allowunstable=True
@@ -34,6 +36,7 @@
   
   options ([+] can be repeated):
   
+   -i --interactive use interactive mode
   --keepallow an empty commit after uncommiting
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
@@ -398,3 +401,17 @@
   |/
   o  0:ea4e33293d4d274a2ba73150733c2612231f398c a 1
   
+Test for interactive mode
+  $ hg init repo3
+  $ touch x
+  $ hg add x
+  $ hg commit -m "added x"
+  $ hg uncommit -i< y
+  > EOF
+  diff --git a/x b/x
+  new file mode 100644
+  examine changes to 'x'? [Ynesfdaq?] y
+  
+  abort: empty commit message
+  [255]
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -136,7 +136,8 @@
 ds.copy(src, dst)
 
 @command('uncommit',
-[('', 'keep', False, _('allow an empty commit after uncommiting')),
+[('i', 'interactive', None, _('use interactive mode')),
+('', 'keep', False, _('allow an empty commit after uncommiting')),
 ] + commands.walkopts,
 _('[OPTION]... [FILE]...'),
 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
@@ -186,6 +187,11 @@
 s = old.p1().status(old, match=match)
 _fixdirstate(repo, old, repo[newid], s)
 
+if opts.get(r'interactive'):
+opts.pop(r'interactive')
+ret = cmdutil.dorecord(ui, repo, commands.commit, None, False,
+   cmdutil.recordfilter, *pats,
+   **opts)
 def predecessormarkers(ctx):
 """yields the obsolete markers marking the given changeset as a 
successor"""
 for data in ctx.repo().obsstore.predecessors.get(ctx.node(), ()):



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


D5792: uncommit: added interactive mode(issue6062)

2019-01-31 Thread taapas1128 (Taapas Agrawal)
taapas1128 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/uncommit.py
  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
@@ -1,6 +1,8 @@
 Test uncommit - set up the config
 
   $ cat >> $HGRCPATH < [ui]
+  > interactive = true
   > [experimental]
   > evolution.createmarkers=True
   > evolution.allowunstable=True
@@ -34,6 +36,7 @@
   
   options ([+] can be repeated):
   
+   -i --interactive use interactive mode
   --keepallow an empty commit after uncommiting
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
@@ -398,3 +401,17 @@
   |/
   o  0:ea4e33293d4d274a2ba73150733c2612231f398c a 1
   
+Test for interactive mode
+  $ hg init repo3
+  $ touch x
+  $ hg add x
+  $ hg commit -m "added x"
+  $ hg uncommit -i< y
+  > EOF
+  diff --git a/x b/x
+  new file mode 100644
+  examine changes to 'x'? [Ynesfdaq?] y
+  
+  abort: empty commit message
+  [255]
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -136,7 +136,8 @@
 ds.copy(src, dst)
 
 @command('uncommit',
-[('', 'keep', False, _('allow an empty commit after uncommiting')),
+[('i', 'interactive', None, _('use interactive mode')),
+('', 'keep', False, _('allow an empty commit after uncommiting')),
 ] + commands.walkopts,
 _('[OPTION]... [FILE]...'),
 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
@@ -151,6 +152,7 @@
 If no files are specified, the commit will be pruned, unless --keep is
 given.
 """
+
 opts = pycompat.byteskwargs(opts)
 
 with repo.wlock(), repo.lock():
@@ -186,6 +188,11 @@
 s = old.p1().status(old, match=match)
 _fixdirstate(repo, old, repo[newid], s)
 
+if opts.get(r'interactive'):
+opts.pop(r'interactive')
+ret = cmdutil.dorecord(ui, repo, commands.commit, None, False,
+   cmdutil.recordfilter, *pats,
+   **opts)
 def predecessormarkers(ctx):
 """yields the obsolete markers marking the given changeset as a 
successor"""
 for data in ctx.repo().obsstore.predecessors.get(ctx.node(), ()):



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