D5940: uncommit: don't allow dirty working copy with PATH (issue5977)

navaneeth.suresh (Navaneeth Suresh) phabricator at mercurial-scm.org
Wed Mar 6 08:39:26 EST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGbf22e370ae9a: uncommit: don't allow dirty working copy with PATH (issue5977) (authored by navaneeth.suresh, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5940?vs=14371&id=14374#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5940?vs=14371&id=14374

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

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
@@ -156,9 +156,12 @@
   M files
   $ hg uncommit
   abort: uncommitted changes
+  (requires experimental.uncommitondirtywdir to uncommit)
   [255]
   $ hg uncommit files
-  note: keeping empty commit
+  abort: uncommitted changes
+  (requires experimental.uncommitondirtywdir to uncommit)
+  [255]
   $ cat files
   abcde
   foo
@@ -169,6 +172,7 @@
   $ echo "bar" >> files
   $ hg uncommit
   abort: uncommitted changes
+  (requires experimental.uncommitondirtywdir to uncommit)
   [255]
   $ hg uncommit --config experimental.uncommitondirtywdir=True
   $ hg commit -m "files abcde + foo"
@@ -192,16 +196,16 @@
   +abc
   
   $ hg bookmark
-     foo                       10:48e5bd7cd583
+     foo                       9:48e5bd7cd583
   $ hg uncommit
   3 new orphan changesets
   $ hg status
   M files
   A file-abc
   $ hg heads -T '{rev}:{node} {desc}'
-  10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol)
+  9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol)
   $ hg bookmark
-     foo                       10:48e5bd7cd583
+     foo                       9:48e5bd7cd583
   $ hg commit -m 'new abc'
   created new head
 
@@ -223,38 +227,36 @@
   +ab
   
   $ hg bookmark
-     foo                       10:48e5bd7cd583
+     foo                       9:48e5bd7cd583
   $ hg uncommit file-ab
   1 new orphan changesets
   $ hg status
   A file-ab
 
   $ hg heads -T '{rev}:{node} {desc}\n'
-  12:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab
-  11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
-  10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
+  11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab
+  10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
+  9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
 
   $ hg bookmark
-     foo                       10:48e5bd7cd583
+     foo                       9:48e5bd7cd583
   $ hg commit -m 'update ab'
   $ hg status
   $ hg heads -T '{rev}:{node} {desc}\n'
-  13:f21039c59242b085491bb58f591afc4ed1c04c09 update ab
-  11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
-  10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
+  12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab
+  10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
+  9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
 
   $ hg log -G -T '{rev}:{node} {desc}' --hidden
-  @  13:f21039c59242b085491bb58f591afc4ed1c04c09 update ab
+  @  12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab
   |
-  o  12:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab
+  o  11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab
   |
-  | *  11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
+  | *  10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
   | |
-  | | *  10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
+  | | *  9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
   | | |
-  | | | x  9:8a6b58c173ca6a2e3745d8bd86698718d664bc6c files abcde + foo
-  | | |/
-  | | | x  8:39ad452c7f684a55d161c574340c5766c4569278 update files for abcde
+  | | | x  8:84beeba0ac30e19521c036e4d2dd3a5fa02586ff files abcde + foo
   | | |/
   | | | x  7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde
   | | |/
@@ -276,23 +278,23 @@
 
   $ hg uncommit
   $ hg phase -r .
-  12: draft
+  11: draft
   $ hg commit -m 'update ab again'
 
 Phase is preserved
 
   $ hg uncommit --keep --config phases.new-commit=secret
   note: keeping empty commit
   $ hg phase -r .
-  15: draft
+  14: draft
   $ hg commit --amend -m 'update ab again'
 
 Uncommit with public parent
 
   $ hg phase -p "::.^"
   $ hg uncommit
   $ hg phase -r .
-  12: public
+  11: public
 
 Partial uncommit with public parent
 
@@ -303,9 +305,9 @@
   $ hg status
   A xyz
   $ hg phase -r .
-  18: draft
+  17: draft
   $ hg phase -r ".^"
-  12: public
+  11: public
 
 Uncommit with --keep or experimental.uncommit.keep leaves an empty changeset
 
@@ -393,6 +395,7 @@
 
   $ hg uncommit
   abort: outstanding uncommitted merge
+  (requires experimental.uncommitondirtywdir to uncommit)
   [255]
 
   $ hg uncommit --config experimental.uncommitondirtywdir=True
@@ -463,3 +466,49 @@
     a
   A c
     a
+  $ cd ..
+
+experimental.uncommitondirtywdir should also work on a dirty PATH
+
+  $ hg init issue5977
+  $ cd issue5977
+  $ echo 'super critical info!' > a
+  $ hg ci -Am 'add a'
+  adding a
+  $ echo 'foo' > b
+  $ hg add b
+  $ hg status
+  A b
+  $ hg unc a
+  note: keeping empty commit
+  $ hg unc b
+  abort: uncommitted changes
+  (requires experimental.uncommitondirtywdir to uncommit)
+  [255]
+  $ cat a
+  super critical info!
+  $ hg log
+  changeset:   1:656ba143d384
+  tag:         tip
+  parent:      -1:000000000000
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add a
+  
+  $ hg ci -Am 'add b'
+  $ echo 'foo bar' > b
+  $ hg unc --config experimental.uncommitondirtywdir=True b
+  $ hg log
+  changeset:   3:30fa958635b2
+  tag:         tip
+  parent:      1:656ba143d384
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add b
+  
+  changeset:   1:656ba143d384
+  parent:      -1:000000000000
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add a
+  
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -158,9 +158,12 @@
 
     with repo.wlock(), repo.lock():
 
-        if not pats and not repo.ui.configbool('experimental',
-                                               'uncommitondirtywdir'):
-            cmdutil.bailifchanged(repo)
+        m, a, r, d = repo.status()[:4]
+        isdirtypath = any(set(m + a + r + d) & set(pats))
+        if (not repo.ui.configbool('experimental', 'uncommitondirtywdir') and
+            (not pats or isdirtypath)):
+            cmdutil.bailifchanged(repo, hint=_('requires '
+                                'experimental.uncommitondirtywdir to uncommit'))
         old = repo['.']
         rewriteutil.precheck(repo, [old.rev()], 'uncommit')
         if len(old.parents()) > 1:



To: navaneeth.suresh, #hg-reviewers, pulkit
Cc: martinvonz, pulkit, mercurial-devel


More information about the Mercurial-devel mailing list