D6178: crecord: new keys g & G to navigate to the top and bottom hunks respectively

2019-04-01 Thread arun (Arun Chandrasekaran)
arun created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch introduces two new keys 'g' and 'G' that helps to navigate to the
  top and bottom of the hunks respectively. This is inline with the shortcuts
  used in man, less, more and such tools that makes it convenient to navigate
  swiftly.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/crecord.py

CHANGE DETAILS

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -1467,6 +1467,8 @@
 pgup/pgdn [K/J] : go to previous/next item of same type
  right/left-arrow [l/h] : go to child item / parent item
  shift-left-arrow   [H] : go to parent header / fold selected header
+  g : go to the first hunk line
+  G : go to the last hunk line
   f : fold / unfold item, hiding/revealing its children
   F : fold / unfold parent item and all of its ancestors
  ctrl-l : scroll the selected line to the top of the screen
@@ -1505,6 +1507,39 @@
 self.stdscr.refresh()
 self.stdscr.keypad(1) # allow arrow-keys to continue to function
 
+def handlefirstlineevent(self):
+"""
+Handle 'g' to navigate to the top most hunk.
+"""
+self.currentselecteditem = self.headerlist[0]
+currentitem = self.currentselecteditem
+# select the parent item recursively until we're at a header
+while True:
+nextitem = currentitem.parentitem()
+if nextitem is None:
+break
+else:
+currentitem = nextitem
+
+self.currentselecteditem = currentitem
+
+def handlelastlineevent(self):
+"""
+Handle 'G' to navigate to the bottom most hunk.
+"""
+currentitem = self.currentselecteditem
+nextitem = currentitem.nextitem()
+# select the child item recursively until we're at a footer
+while nextitem is not None:
+nextitem = currentitem.nextitem()
+if nextitem is None:
+break
+else:
+currentitem = nextitem
+
+self.currentselecteditem = currentitem
+self.recenterdisplayedarea()
+
 def confirmationwindow(self, windowtext):
 "display an informational window, then wait for and return a keypress."
 
@@ -1725,6 +1760,10 @@
 self.togglefolded(foldparent=True)
 elif keypressed in ["m"]:
 self.commitMessageWindow()
+elif keypressed in ["g"]:
+self.handlefirstlineevent()
+elif keypressed in ["G"]:
+self.handlelastlineevent()
 elif keypressed in ["?"]:
 self.helpwindow()
 self.stdscr.clear()



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


[PATCH V4] uncommit: abort if an explicitly given file cannot be uncommitted

2019-04-01 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1553910795 14400
#  Fri Mar 29 21:53:15 2019 -0400
# Node ID 8ced6cadf535d8f7502f61db01ddcb8b2629a17a
# Parent  eec20025ada33889233e553c5825aac36b708f6c
uncommit: abort if an explicitly given file cannot be uncommitted

I've gotten burned several times by this in the last few days.  The former tests
look simple enough, but if a good file and a bad file are given, the bad files
are silently ignored.  Some commands like `forget` will warn about bogus files,
but that would likely get lost in the noise of an interactive uncommit.  The
commit command aborts if a bad file is given, so this seems more consistent for
commands that alter the repository.

diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -33,6 +33,7 @@ from mercurial import (
 registrar,
 rewriteutil,
 scmutil,
+util,
 )
 
 cmdtable = {}
@@ -133,8 +134,34 @@ def uncommit(ui, repo, *pats, **opts):
 if len(old.parents()) > 1:
 raise error.Abort(_("cannot uncommit merge changeset"))
 
+match = scmutil.match(old, pats, opts)
+
+# Check all explicitly given files; abort if there's a problem.
+if match.files():
+s = old.status(old.p1(), match, listclean=True)
+eligible = set(s.added) | set(s.modified) | set(s.removed)
+
+badfiles = set(match.files()) - eligible
+
+# Naming a parent directory of an eligible file is OK, even
+# if not everything tracked in that directory can be
+# uncommitted.
+if badfiles:
+badfiles -= set([f for f in util.dirs(eligible)])
+
+for f in sorted(badfiles):
+if f in s.clean:
+hint = _(b"file was not changed in working directory "
+ b"parent")
+elif repo.wvfs.exists(f):
+hint = _(b"file was untracked in working directory parent")
+else:
+hint = _(b"file does not exist")
+
+raise error.Abort(_(b'cannot uncommit "%s"')
+  % scmutil.getuipathfn(repo)(f), hint=hint)
+
 with repo.transaction('uncommit'):
-match = scmutil.match(old, pats, opts)
 keepcommit = pats
 if not keepcommit:
 if opts.get('keep') is not None:
diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -102,14 +102,16 @@ Recommit
   $ hg heads -T '{rev}:{node} {desc}'
   5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde (no-eol)
 
-Uncommit of non-existent and unchanged files has no effect
+Uncommit of non-existent and unchanged files aborts
   $ hg uncommit nothinghere
-  nothing to uncommit
-  [1]
+  abort: cannot uncommit "nothinghere"
+  (file does not exist)
+  [255]
   $ hg status
   $ hg uncommit file-abc
-  nothing to uncommit
-  [1]
+  abort: cannot uncommit "file-abc"
+  (file was not changed in working directory parent)
+  [255]
   $ hg status
 
 Try partial uncommit, also moves bookmark
@@ -513,3 +515,56 @@ Copy a->b1 and a->b2, then rename b1->c 
   date:Thu Jan 01 00:00:00 1970 +
   summary: add a
   
+Removes can be uncommitted
+
+  $ hg ci -m 'modified b'
+  $ hg rm b
+  $ hg ci -m 'remove b'
+  $ hg uncommit b
+  note: keeping empty commit
+  $ hg status
+  R b
+
+Uncommitting a directory won't run afoul of the checks that an explicit file
+can be uncommitted.
+
+  $ mkdir dir
+  $ echo 1 > dir/file.txt
+  $ hg ci -Aqm 'add file in directory'
+  $ hg uncommit dir
+  $ hg status
+  A dir/file.txt
+
+`uncommit ` and `cd  && uncommit .` behave the same...
+
+  $ hg rollback -q --config ui.rollback=True
+  $ echo 2 > dir/file2.txt
+  $ hg ci -Aqm 'add file2 in directory'
+  $ hg uncommit dir
+  note: keeping empty commit
+  $ hg status
+  A dir/file2.txt
+
+  $ hg rollback -q --config ui.rollback=True
+  $ cd dir
+  $ hg uncommit .
+  note: keeping empty commit
+  $ hg status
+  A dir/file2.txt
+  $ cd ..
+
+... and errors out the same way when nothing can be uncommitted
+
+  $ hg rollback -q --config ui.rollback=True
+  $ mkdir emptydir
+  $ hg uncommit emptydir
+  abort: cannot uncommit "emptydir"
+  (file was untracked in working directory parent)
+  [255]
+
+  $ cd emptydir
+  $ hg uncommit .
+  abort: cannot uncommit "emptydir"
+  (file was untracked in working directory parent)
+  [255]
+  $ hg status
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH V3] uncommit: abort if an explicitly given file cannot be uncommitted

2019-04-01 Thread Matt Harbison

On Mon, 01 Apr 2019 18:59:10 -0400, Yuya Nishihara  wrote:


On Sun, 31 Mar 2019 22:46:25 -0400, Matt Harbison wrote:

# HG changeset patch
# User Matt Harbison 
# Date 1553910795 14400
#  Fri Mar 29 21:53:15 2019 -0400
# Node ID 9802203e693d83f4092512be6d3e397926b36f8e
# Parent  eec20025ada33889233e553c5825aac36b708f6c
uncommit: abort if an explicitly given file cannot be uncommitted

I've gotten burned several times by this in the last few days.  The  
former tests
look simple enough, but if a good file and a bad file are given, the  
bad files
are silently ignored.  Some commands like `forget` will warn about  
bogus files,
but that would likely get lost in the noise of an interactive  
uncommit.  The
commit command aborts if a bad file is given, so this seems more  
consistent for

commands that alter the repository.

diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -133,8 +133,36 @@ def uncommit(ui, repo, *pats, **opts):
 if len(old.parents()) > 1:
 raise error.Abort(_("cannot uncommit merge changeset"))

+match = scmutil.match(old, pats, opts)
+
+# Check all explicitly given files; abort if there's a problem.
+if match.files():
+s = old.status(old.p1(), match, listclean=True)
+eligible = set(s.added) | set(s.modified) | set(s.removed)
+
+for f in match.files():
+if f not in eligible:
+# Naming a parent directory of an eligible file is  
OK, even
+# if not everything tracked in that directory can  
be

+# uncommitted.
+for e in eligible:
+if e.startswith(f + '/'):
+break


Perhaps, the eligible set can be extended to include util.dirs(eligible)
to get around possible quadratic computation.


Oh, I forgot about that, thanks.

That said, do we really want to error out if  doesn't match any  
modified
files? If I do "hg  ", I don't care if  is empty or  
not.

I expect it'll be basically the same as "cd  && hg  .".


I think if it's a command that's making changes to the repo history and we  
can't do exactly what the user requested, we do want to abort.  That's how  
commit seems to work.  Warnings for things that just modify dirstate seem  
fine, as those mistakes can easily be fixed up without cluttering the  
hidden view.  But really the problem is not recognizing that it is  
currently partially ignoring the request.


I'll submit a V4 with some extra tests (including your example IIUC), and  
the only difference with and without this code is the stderr message and  
the exit code (1 vs 255).  So we are failing in some of those cases  
already, just not consistently when given multiple files.


The slight edge case here is if you have a commit of 'dir/foo', and then a  
child commit with 'dir/bar' and 'dir/baz'.  On the child, `hg uncommit  
dir` will only uncommit bar and baz.  But that seems OK for a user that  
understands what uncommit does.  It's also what `cd dir && hg uncommit .`  
currently does.  This change just tries to catch typos.  FTR, I hit this  
being lazy and not wanting to type out full file names.  So I did:


cd deep/nested/dir && hg uncommit file1 file2 ../otherdir/file3

The last path was missing another '../', and there was absolutely no  
indication from the command that it didn't work.  I only noticed later.


The other thing to keep in mind here is it isn't just modified files.   
Removed files can be uncommitted, so you can name things not in the  
filesystem, unlike a lot of commands.

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6177: histedit: narrow the scope of discarded ui output

2019-04-01 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 14614.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6177?vs=14613=14614

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

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t
  tests/test-histedit-edit.t
  tests/test-histedit-fold-non-commute.t
  tests/test-histedit-fold.t
  tests/test-histedit-merge-tools.t
  tests/test-histedit-non-commute.t
  tests/test-histedit-obsolete.t
  tests/test-qrecord.t

CHANGE DETAILS

diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
--- a/tests/test-qrecord.t
+++ b/tests/test-qrecord.t
@@ -446,7 +446,6 @@
   > edit ea55e2ae468f foo bar
   > EOF
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  adding a
   Editing (ea55e2ae468f), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -216,7 +216,6 @@
   > edit b346ab9a313d 6 c
   > EOF
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  adding c
   Editing (b346ab9a313d), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
@@ -351,7 +350,6 @@
   > pick ee118ab9fa44 16 k
   > EOF
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
-  adding f
   Editing (b449568bf7fc), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
@@ -394,7 +392,6 @@
   > pick ee118ab9fa44 16 k
   > EOF
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
-  adding f
   Editing (b449568bf7fc), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
diff --git a/tests/test-histedit-non-commute.t 
b/tests/test-histedit-non-commute.t
--- a/tests/test-histedit-non-commute.t
+++ b/tests/test-histedit-non-commute.t
@@ -87,7 +87,6 @@
 
 edit the history
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (pick 39522b764e3d)
@@ -145,7 +144,6 @@
 
 edit the history
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (pick 39522b764e3d)
@@ -241,7 +239,6 @@
 
 edit the history, this time with a fold action
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (mess 39522b764e3d)
diff --git a/tests/test-histedit-merge-tools.t 
b/tests/test-histedit-merge-tools.t
new file mode 100644
--- /dev/null
+++ b/tests/test-histedit-merge-tools.t
@@ -0,0 +1,57 @@
+Test histedit extension: Merge tools
+
+
+Initialization
+---
+
+  $ . "$TESTDIR/histedit-helpers.sh"
+
+  $ cat >> $HGRCPATH < [alias]
+  > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
+  > [extensions]
+  > histedit=
+  > mockmakedate = $TESTDIR/mockmakedate.py
+  > [ui]
+  > pre-merge-tool-output-template='pre-merge message for {node}\n'
+  > EOF
+
+Merge conflict
+--
+
+  $ hg init r
+  $ cd r
+  $ echo foo > file
+  $ hg add file
+  $ hg ci -m "First" -d "1 0"
+  $ echo bar > file
+  $ hg ci -m "Second" -d "2 0"
+
+  $ hg logt --graph
+  @  1:2aa920f62fb9 Second
+  |
+  o  0:7181f42b8fca First
+  
+
+Invert the order of the commits, but fail the merge.
+  $ hg histedit --config ui.merge=false --commands - 2>&1 < pick 2aa920f62fb9 Second
+  > pick 7181f42b8fca First
+  > EOF
+  merging file
+  pre-merge message for b90fa2e91a6d11013945a5f684be45b84a8ca6ec
+  merging file failed!
+  Fix up the change (pick 7181f42b8fca)
+  (hg histedit --continue to resume)
+
+  $ hg histedit --abort | fixbundle
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Invert the order of the commits, and pretend the merge succeeded.
+  $ hg histedit --config ui.merge=true --commands - 2>&1 < pick 2aa920f62fb9 Second
+  > pick 7181f42b8fca First
+  > EOF
+  merging file
+  pre-merge message for b90fa2e91a6d11013945a5f684be45b84a8ca6ec
+  7181f42b8fca: skipping changeset (no changes)
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -287,7 +287,6 @@
   > drop 888f9082bf99 2 +5
   > fold 251d831eeec5 3 +6
   > EOF
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging file
   warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
   Fix up the change (fold 251d831eeec5)
@@ -361,7 +360,6 @@
   

D6177: histedit: narrow the scope of discarded ui output

2019-04-01 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  In 
https://phab.mercurial-scm.org/rHG34165875fa5df813bec3a0cd348932b304d44efb, a 
lot of the output from
  histedit was excluded. This slightly adjusts the scope of that exclusion,
  to both discard more uninsteresting messages, and ensure that pre-merge-tool
  output gets shown before the external merge tool is executed.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t
  tests/test-histedit-edit.t
  tests/test-histedit-fold-non-commute.t
  tests/test-histedit-fold.t
  tests/test-histedit-merge-tools.t
  tests/test-histedit-non-commute.t
  tests/test-histedit-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -216,7 +216,6 @@
   > edit b346ab9a313d 6 c
   > EOF
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  adding c
   Editing (b346ab9a313d), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
@@ -351,7 +350,6 @@
   > pick ee118ab9fa44 16 k
   > EOF
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
-  adding f
   Editing (b449568bf7fc), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
@@ -394,7 +392,6 @@
   > pick ee118ab9fa44 16 k
   > EOF
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
-  adding f
   Editing (b449568bf7fc), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
diff --git a/tests/test-histedit-non-commute.t 
b/tests/test-histedit-non-commute.t
--- a/tests/test-histedit-non-commute.t
+++ b/tests/test-histedit-non-commute.t
@@ -87,7 +87,6 @@
 
 edit the history
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (pick 39522b764e3d)
@@ -145,7 +144,6 @@
 
 edit the history
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (pick 39522b764e3d)
@@ -241,7 +239,6 @@
 
 edit the history, this time with a fold action
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (mess 39522b764e3d)
diff --git a/tests/test-histedit-merge-tools.t 
b/tests/test-histedit-merge-tools.t
new file mode 100644
--- /dev/null
+++ b/tests/test-histedit-merge-tools.t
@@ -0,0 +1,57 @@
+Test histedit extension: Merge tools
+
+
+Initialization
+---
+
+  $ . "$TESTDIR/histedit-helpers.sh"
+
+  $ cat >> $HGRCPATH < [alias]
+  > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
+  > [extensions]
+  > histedit=
+  > mockmakedate = $TESTDIR/mockmakedate.py
+  > [ui]
+  > pre-merge-tool-output-template='pre-merge message for {node}\n'
+  > EOF
+
+Merge conflict
+--
+
+  $ hg init r
+  $ cd r
+  $ echo foo > file
+  $ hg add file
+  $ hg ci -m "First" -d "1 0"
+  $ echo bar > file
+  $ hg ci -m "Second" -d "2 0"
+
+  $ hg logt --graph
+  @  1:2aa920f62fb9 Second
+  |
+  o  0:7181f42b8fca First
+  
+
+Invert the order of the commits, but fail the merge.
+  $ hg histedit --config ui.merge=/bin/false --commands - 2>&1 < pick 2aa920f62fb9 Second
+  > pick 7181f42b8fca First
+  > EOF
+  merging file
+  pre-merge message for b90fa2e91a6d11013945a5f684be45b84a8ca6ec
+  merging file failed!
+  Fix up the change (pick 7181f42b8fca)
+  (hg histedit --continue to resume)
+
+  $ hg histedit --abort | fixbundle
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Invert the order of the commits, and pretend the merge succeeded.
+  $ hg histedit --config ui.merge=/bin/true --commands - 2>&1 < pick 2aa920f62fb9 Second
+  > pick 7181f42b8fca First
+  > EOF
+  merging file
+  pre-merge message for b90fa2e91a6d11013945a5f684be45b84a8ca6ec
+  7181f42b8fca: skipping changeset (no changes)
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -287,7 +287,6 @@
   > drop 888f9082bf99 2 +5
   > fold 251d831eeec5 3 +6
   > EOF
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging file
   warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
   Fix up the change (fold 251d831eeec5)
@@ -361,7 +360,6 @@
   > drop 

D6169: unshelve: disable unshelve during merge (issue5123)

2019-04-01 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   I saw some patches[0][1][2] trying to fix this issue. It seems like it's 
difficult to preserve the second parent.
  >   
  >   [0]: 
http://mercurial.808500.n3.nabble.com/PATCH-shelve-adds-restoring-original-parents-after-unshelve-issue5123-tc4035657.html#none
  >   [1]: 
http://mercurial.808500.n3.nabble.com/PATCH-V2-shelve-restore-parents-after-unshelve-issue5123-tc4036093.html#a4037370
  >   [2]: 
http://mercurial.808500.n3.nabble.com/PATCH-V3-shelve-restore-parents-after-unshelve-issue5123-tt4036858.html#a4037408
  
  Okay, let's disable unshelve then. Can you update the commit message to
  include why we can't simply allow it?

REPOSITORY
  rHG Mercurial

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

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


Re: D6169: unshelve: disable unshelve during merge (issue5123)

2019-04-01 Thread Yuya Nishihara
>   I saw some patches[0][1][2] trying to fix this issue. It seems like it's 
> difficult to preserve the second parent.
>   
>   [0]: 
> http://mercurial.808500.n3.nabble.com/PATCH-shelve-adds-restoring-original-parents-after-unshelve-issue5123-tc4035657.html#none
>   [1]: 
> http://mercurial.808500.n3.nabble.com/PATCH-V2-shelve-restore-parents-after-unshelve-issue5123-tc4036093.html#a4037370
>   [2]: 
> http://mercurial.808500.n3.nabble.com/PATCH-V3-shelve-restore-parents-after-unshelve-issue5123-tt4036858.html#a4037408

Okay, let's disable unshelve then. Can you update the commit message to
include why we can't simply allow it?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH V3] uncommit: abort if an explicitly given file cannot be uncommitted

2019-04-01 Thread Yuya Nishihara
On Sun, 31 Mar 2019 22:46:25 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison 
> # Date 1553910795 14400
> #  Fri Mar 29 21:53:15 2019 -0400
> # Node ID 9802203e693d83f4092512be6d3e397926b36f8e
> # Parent  eec20025ada33889233e553c5825aac36b708f6c
> uncommit: abort if an explicitly given file cannot be uncommitted
> 
> I've gotten burned several times by this in the last few days.  The former 
> tests
> look simple enough, but if a good file and a bad file are given, the bad files
> are silently ignored.  Some commands like `forget` will warn about bogus 
> files,
> but that would likely get lost in the noise of an interactive uncommit.  The
> commit command aborts if a bad file is given, so this seems more consistent 
> for
> commands that alter the repository.
> 
> diff --git a/hgext/uncommit.py b/hgext/uncommit.py
> --- a/hgext/uncommit.py
> +++ b/hgext/uncommit.py
> @@ -133,8 +133,36 @@ def uncommit(ui, repo, *pats, **opts):
>  if len(old.parents()) > 1:
>  raise error.Abort(_("cannot uncommit merge changeset"))
>  
> +match = scmutil.match(old, pats, opts)
> +
> +# Check all explicitly given files; abort if there's a problem.
> +if match.files():
> +s = old.status(old.p1(), match, listclean=True)
> +eligible = set(s.added) | set(s.modified) | set(s.removed)
> +
> +for f in match.files():
> +if f not in eligible:
> +# Naming a parent directory of an eligible file is OK, 
> even
> +# if not everything tracked in that directory can be
> +# uncommitted.
> +for e in eligible:
> +if e.startswith(f + '/'):
> +break

Perhaps, the eligible set can be extended to include util.dirs(eligible)
to get around possible quadratic computation.

That said, do we really want to error out if  doesn't match any modified
files? If I do "hg  ", I don't care if  is empty or not.
I expect it'll be basically the same as "cd  && hg  .".

> +else:
> +if f in s.clean:
> +hint = _(b"file was not changed in working "
> + b"directory parent")
> +elif repo.wvfs.exists(f):
> +hint = _(b"file was untracked in working 
> directory "
> + b"parent")
> +else:
> +hint = _(b"file does not exist")
> +
> +raise error.Abort(_(b'cannot uncommit "%s"')
> +  % scmutil.getuipathfn(repo)(f),
> +  hint=hint)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6169: unshelve: disable unshelve during merge (issue5123)

2019-04-01 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added a comment.


  I saw some patches[0][1][2] trying to fix this issue. It seems like it's 
difficult to preserve the second parent.
  
  [0]: 
http://mercurial.808500.n3.nabble.com/PATCH-shelve-adds-restoring-original-parents-after-unshelve-issue5123-tc4035657.html#none
  [1]: 
http://mercurial.808500.n3.nabble.com/PATCH-V2-shelve-restore-parents-after-unshelve-issue5123-tc4036093.html#a4037370
  [2]: 
http://mercurial.808500.n3.nabble.com/PATCH-V3-shelve-restore-parents-after-unshelve-issue5123-tt4036858.html#a4037408

REPOSITORY
  rHG Mercurial

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

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