D6613: commit: improve the files field of changelog for merges (RFC)

2019-07-10 Thread valentin.gatienbaron (Valentin Gatien-Baron)
valentin.gatienbaron added inline comments.

INLINE COMMENTS

> JordiGH wrote in localrepo.py:2658
> Not all merges can be detected by checking for p2 being non-null; p1 being 
> null but p2 being non-null is perfectly acceptable everywhere else, although 
> normally hg won't produce commits like this in most circumstances.

It'd be trivial to change the code to check both parents, but I find what you 
say surprising. Aren't there plenty of places in hg that do checks similar to 
this one:

https://www.mercurial-scm.org/repo/hg-committed/file/3bc400ccbf99/mercurial/context.py#l443
https://www.mercurial-scm.org/repo/hg-committed/file/3bc400ccbf99/mercurial/context.py#l2414
https://www.mercurial-scm.org/repo/hg-committed/file/3bc400ccbf99/mercurial/localrepo.py#l2407

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6613/new/

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

To: valentin.gatienbaron, #hg-reviewers, mharbison72
Cc: JordiGH, yuja, mharbison72, martinvonz, mjpieters, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6613: commit: improve the files field of changelog for merges (RFC)

2019-07-10 Thread valentin.gatienbaron (Valentin Gatien-Baron)
valentin.gatienbaron added a comment.


  In D6613#96908 , @mharbison72 
wrote:
  
  > In D6613#96822 , 
@valentin.gatienbaron wrote:
  >
  >> Ok. Maybe it would be simpler or more robust to do the direct thing: 
optionally treat the files list in the input commit as input and reuse them 
blindly in the resulting commit, when doing a hg->hg conversion without filemap.
  >
  > Maybe.  I've been wondering if it's possible to just pass along the 
manifest and changelog instead of recalculating it.  It seems there have been 
other issues over the years[1].  @yuja fixed something manifest related around 
the time of that thread IIRC.  Even if a filemap is in use, the map may not 
modify early commits.  And when those are changed unexpectedly, it makes me 
wonder what got lost/mangled.  I looked through the repos I converted last year 
without any file mapping, and there were manifest node changes, but also 
differences in `files` and `files+` in the changelog.
  
  Ideally, the whole file list would move out the changelog. Then changing the 
list of modified files wouldn't change hashes anymore, but of course at the 
cost of changing everything once.
  Given that the filelist in the commit is (ignoring changes to mercurial) a 
function of the manifest, it may be reasonable to make convert reuse the 
filelist if the manifestnode gets reused. Or to put it differently, if the 
conversion is the identity so far for a commit, keep behaving as the identity.
  
  >> (btw, a tweak to test-merge-combinations shows the cases where convert is 
not the identity: 12-- and -1--, so cases where a file is absent in p1, that p2 
added or modified, and the merge redeletes the file. Commit shows such files 
are modified (rightly) but convert doesn't)
  >
  > Is that a non-tracked test?  Can you throw a patch up somewhere showing 
this?  One of the things I noticed last year was that I'd get better results if 
`cleanp2`[2] was forced to be empty.  I was unable to come up with a simple 
test case showing a different hash with shipping code and a forcibly emptied 
`cleanp2`, circa 4.6.  What you're describing seems to be the opposite of 
216fa1ba9993 
, 
but something is wrong with that calculation, so maybe it's worth a try.
  
  Saying "the cases where convert misbehaves" is probably optimistic. It shows 
some cases where convert misbehaves. test-merge-combination.t is in the 
previous differential. cleanp2 seems orthogonal, as fiddling with it doesn't 
change what I see. This is the tweak I was talking about (based on this 
differential):
  
diff --git a/tests/test-merge-combination.t b/tests/test-merge-combination.t
--- a/tests/test-merge-combination.t
+++ b/tests/test-merge-combination.t
@@ -58,9 +58,16 @@ revision. "C" indicates that hg merge ha
   >   else expected=a
   >   fi
   >   got=`hg log -r 3 --template '{files}\n' | tr --delete 'e '`
+  >   hg --config extensions.convert= convert . repo-convert -s hg 
-d hg --sourcesort -q
+  >   got2=`hg --cwd repo-convert log -r 3 --template '{files}\n' 
| tr --delete 'e '`
   >   if [ "$got" = "$expected" ]
-  >   then echo "$line$conflicts: agree on \"$got\""
-  >   else echo "$line$conflicts: hg said \"$got\", expected 
\"$expected\""
+  >   then echo -n "$line$conflicts: agree on \"$got\""
+  >   else echo -n "$line$conflicts: hg said \"$got\", expected 
\"$expected\""
+  >   fi
+  >   if [ "$got" = "$got2" ]; then
+  > echo
+  >   else
+  > echo ", commit:\"$got\" vs convert:\"$got2\""
   >   fi
   >   cd ../
   >   rm -rf repo
@@ -115,7 +122,7 @@ All the merges of various file contents.
   12-1 C: agree on "a"
   12-2 C: hg said "", expected "a"
   12-3 C: agree on "a"
-  12-- C: agree on "a"
+  12-- C: agree on "a", commit:"a" vs convert:""
   1-11  : hg said "", expected "a"
   1-12  : agree on "a"
   1-1-  : agree on ""
@@ -135,7 +142,7 @@ All the merges of various file contents.
   -12- C: agree on "a"
   -1-1  : agree on ""
   -1-2  : agree on "a"
-  -1--  : agree on "a"
+  -1--  : agree on "a", commit:"a" vs convert:""
   --11  : agree on ""
   --12  : agree on "a"
   --1-  : agree on "a"

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6613/new/

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

To: valentin.gatienbaron, #hg-reviewers, mharbison72
Cc: JordiGH, yuja, mharbison72, martinvonz, mjpieters, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/m

Re: [PATCH 1 of 2] rust-dirstate: add helper to iterate ancestor paths

2019-07-10 Thread Yuya Nishihara
On Wed, 10 Jul 2019 07:36:26 -0700, Martin von Zweigbergk wrote:
> On Sun, Jun 30, 2019, 04:17 Yuya Nishihara  wrote:
> 
> > # HG changeset patch
> > # User Yuya Nishihara 
> > # Date 1561887163 -32400
> > #  Sun Jun 30 18:32:43 2019 +0900
> > # Node ID 72ab74c704053b2212b874a902574fedadad4252
> > # Parent  904e0da2e195d2a29977ceccdd25480233c34d7a
> > rust-dirstate: add helper to iterate ancestor paths
> >
> > This is modeled after std::path::Path::ancestors().
> >
> > find_dirs(b"") yields b"" because Mercurial's util.finddirs() works in that
> > way, and the test case for DirsMultiset expects such behavior.
> >
> 
> That's also how std::path::Path::ancestors() works, it seems.

finddirs(path) is basically equivalent to

  Ancestors { next: path.parent() }
  // not including the path itself.
  // note that Path::new("/").parent() returns None.

so I feel it's weird that both finddirs("foo") and finddirs("") return [''].
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH V2] rust-dirstate: leverage find_dirs() iterator in DirsMultiset

2019-07-10 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1561887644 -32400
#  Sun Jun 30 18:40:44 2019 +0900
# Node ID 7bf692513e86d829ab4d0a7e37c503767eeeb2f9
# Parent  3bc400ccbf996fac16ef2b608f6c47552eaf6c56
rust-dirstate: leverage find_dirs() iterator in DirsMultiset

diff --git a/rust/hg-core/src/dirstate/dirs_multiset.rs 
b/rust/hg-core/src/dirstate/dirs_multiset.rs
--- a/rust/hg-core/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-core/src/dirstate/dirs_multiset.rs
@@ -8,6 +8,8 @@
 //! A multiset of directory names.
 //!
 //! Used to counts the references to directories in a manifest or dirstate.
+
+use crate::utils::files;
 use std::collections::hash_map::{Entry, Iter};
 use std::collections::HashMap;
 use {DirsIterable, DirstateEntry, DirstateMapError};
@@ -49,40 +51,16 @@ impl DirsMultiset {
 multiset
 }
 
-/// Returns the slice up to the next directory name from right to left,
-/// without trailing slash
-fn find_dir(path: &[u8]) -> &[u8] {
-let mut path = path;
-loop {
-if let Some(new_pos) = path.len().checked_sub(1) {
-if path[new_pos] == b'/' {
-break &path[..new_pos];
-}
-path = &path[..new_pos];
-} else {
-break &[];
-}
-}
-}
-
 /// Increases the count of deepest directory contained in the path.
 ///
 /// If the directory is not yet in the map, adds its parents.
 pub fn add_path(&mut self, path: &[u8]) {
-let mut pos = path.len();
-
-loop {
-let subpath = Self::find_dir(&path[..pos]);
+for subpath in files::find_dirs(path) {
 if let Some(val) = self.inner.get_mut(subpath) {
 *val += 1;
 break;
 }
 self.inner.insert(subpath.to_owned(), 1);
-
-pos = subpath.len();
-if pos == 0 {
-break;
-}
 }
 }
 
@@ -95,10 +73,7 @@ impl DirsMultiset {
 &mut self,
 path: &[u8],
 ) -> Result<(), DirstateMapError> {
-let mut pos = path.len();
-
-loop {
-let subpath = Self::find_dir(&path[..pos]);
+for subpath in files::find_dirs(path) {
 match self.inner.entry(subpath.to_owned()) {
 Entry::Occupied(mut entry) => {
 let val = entry.get().clone();
@@ -113,11 +88,6 @@ impl DirsMultiset {
 path.to_owned(),
 ))
 }
-};
-
-pos = subpath.len();
-if pos == 0 {
-break;
 }
 }
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6613: commit: improve the files field of changelog for merges (RFC)

2019-07-10 Thread Jordi Gutiérrez Hermoso
JordiGH added inline comments.

INLINE COMMENTS

> localrepo.py:2658
>  del m[f]
> +if p2.rev() != nullrev:
> +@util.cachefunc

Not all merges can be detected by checking for p2 being non-null; p1 being null 
but p2 being non-null is perfectly acceptable everywhere else, although 
normally hg won't produce commits like this in most circumstances.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6613/new/

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

To: valentin.gatienbaron, #hg-reviewers, mharbison72
Cc: JordiGH, yuja, mharbison72, martinvonz, mjpieters, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6611: blackbox: disable extremely verbose logging (issue6110)

2019-07-10 Thread valentin.gatienbaron (Valentin Gatien-Baron)
valentin.gatienbaron added inline comments.
valentin.gatienbaron marked an inline comment as done.

INLINE COMMENTS

> durin42 wrote in blackbox.py:97
> Let's make this configurable, and this is the default. Maybe blackbox.ignore, 
> with a default of the things you've specified?

I made the ignore list configurable, although it seems to be of limited 
utility: you can replace the default, but extending seems like the more useful 
thing to do. Extending the list requires repeating the default, and the default 
may not be particularly stable across versions.

I changed the priority of tracked and ignored, so tracked takes predecence. 
This means that `tracked = *, cmdserver` would log cmdserver events, as that 
seems a bit better to me and maybe that's why you wanted the configurability.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6611/new/

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

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


D6611: blackbox: disable extremely verbose logging (issue6110)

2019-07-10 Thread valentin.gatienbaron (Valentin Gatien-Baron)
valentin.gatienbaron updated this revision to Diff 15887.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6611?vs=15787&id=15887

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6611/new/

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

AFFECTED FILES
  hgext/blackbox.py
  tests/test-blackbox.t

CHANGE DETAILS

diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -22,9 +22,6 @@
   > [alias]
   > confuse = log --limit 3
   > so-confusing = confuse --style compact
-  > [blackbox]
-  > track = backupbundle, branchcache, command, commandalias, commandexception,
-  > commandfinish, debug, exthook, incoming, pythonhook, tagscache
   > EOF
 
   $ hg init blackboxtest
diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -9,12 +9,14 @@
 """log repository events to a blackbox for debugging
 
 Logs event information to .hg/blackbox.log to help debug and diagnose problems.
-The events that get logged can be configured via the blackbox.track config key.
+The events that get logged can be configured via the blackbox.track and
+blackbox.ignore config keys.
 
 Examples::
 
   [blackbox]
   track = *
+  ignore = pythonhook
   # dirty is *EXPENSIVE* (slow);
   # each log entry indicates `+` if the repository is dirty, like :hg:`id`.
   dirty = True
@@ -84,6 +86,9 @@
 configitem('blackbox', 'track',
 default=lambda: ['*'],
 )
+configitem('blackbox', 'ignore',
+default=lambda: ['chgserver', 'cmdserver', 'extension'],
+)
 configitem('blackbox', 'date-format',
 default='%Y/%m/%d %H:%M:%S',
 )
@@ -94,12 +99,15 @@
 def __init__(self, ui, repo):
 self._repo = repo
 self._trackedevents = set(ui.configlist('blackbox', 'track'))
+self._ignoredevents = set(ui.configlist('blackbox', 'ignore'))
 self._maxfiles = ui.configint('blackbox', 'maxfiles')
 self._maxsize = ui.configbytes('blackbox', 'maxsize')
 self._inlog = False
 
 def tracked(self, event):
-return b'*' in self._trackedevents or event in self._trackedevents
+return ((b'*' in self._trackedevents
+ and event not in self._ignoredevents)
+or event in self._trackedevents)
 
 def log(self, ui, event, msg, opts):
 # self._log() -> ctx.dirty() may create new subrepo instance, which



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


D6638: abort: removed labels argument from abortmerge()

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

REVISION SUMMARY
  Labels are used to label the code that belongs to `working copy` and `merge 
rev`
  in case of a conflicted state.
  However when merge is aborted there is no unresolved merge in progress and 
hence
  no labels are required.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -957,7 +957,7 @@
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
 if abort:
-return abortmerge(repo.ui, repo, labels=labels)
+return abortmerge(repo.ui, repo)
 
 stats = mergemod.update(repo, node, branchmerge=True, force=force,
 mergeforce=mergeforce, labels=labels)
@@ -969,7 +969,7 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
-def abortmerge(ui, repo, labels=None):
+def abortmerge(ui, repo):
 ms = mergemod.mergestate.read(repo)
 if ms.active():
 # there were conflicts
@@ -980,8 +980,7 @@
 
 repo.ui.status(_("aborting the merge, updating back to"
  " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
+stats = mergemod.update(repo, node, branchmerge=False, force=True)
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 



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


D6588: abort: added support for merge

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG3bc400ccbf99: abort: added support for merge (authored by 
taapas1128).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6588?vs=15880&id=15883#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6588?vs=15880&id=15883

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6588/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  mercurial/state.py
  tests/test-commit-unresolved.t
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -718,11 +718,16 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
+
+#if abortflag
+  $ hg unshelve --abort
+  abort: no unshelve in progress
+  [255]
+#else
   $ hg abort
-  abort: no unshelve in progress (abortflag !)
-  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#endif
   $ cd ..
 
 Unshelve respects --keep even if user intervention is needed
diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t
--- a/tests/test-commit-unresolved.t
+++ b/tests/test-commit-unresolved.t
@@ -1,3 +1,11 @@
+#testcases abortcommand abortflag
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = merge --abort
+  > EOF
+#endif
+
   $ addcommit () {
   > echo $1 > $1
   > hg add $1
@@ -36,9 +44,11 @@
 
 Testing the abort functionality first in case of conflicts
 
-  $ hg merge --abort
-  abort: no merge in progress
+  $ hg abort
+  abort: no merge in progress (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
+
   $ hg merge
   merging A
   warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
@@ -53,7 +63,13 @@
   abort: cannot specify both --rev and --abort
   [255]
 
-  $ hg merge --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  merge in progress, will be aborted
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,7 @@
   abort: cannot specify --preview with --abort
   [255]
 
-  $ hg merge --abort
+  $ hg abort
   aborting the merge, updating back to 68352a18a7c4
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -205,13 +205,6 @@
  'To mark the changeset bad: hg bisect --bad\n'
  'To abort:  hg bisect --reset\n')
 )
-addunfinished(
-'merge', fname=None, clearable=True, allowcommit=True,
-cmdmsg=_('outstanding uncommitted merge'),
-statushint=_('To continue:hg commit\n'
- 'To abort:   hg merge --abort'),
-cmdhint=_("use 'hg commit' or 'hg merge --abort'")
-)
 
 def getrepostate(repo):
 # experimental config: commands.status.skipstates
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -956,31 +956,35 @@
   abort=False):
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
-if not abort:
-stats = mergemod.update(repo, node, branchmerge=True, force=force,
-mergeforce=mergeforce, labels=labels)
-else:
-ms = mergemod.mergestate.read(repo)
-if ms.active():
-# there were conflicts
-node = ms.localctx.hex()
-else:
-# there were no conficts, mergestate was not stored
-node = repo['.'].hex()
+if abort:
+return abortmerge(repo.ui, repo, labels=labels)
 
-repo.ui.status(_("aborting the merge, updating back to"
- " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
-
+stats = mergemod.update(repo, node, branchmerge=True, force=force,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
  "or 'hg merge --abort' to abandon\n"))
-elif remind and not abort:
+elif remind:
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+ms = mergemod.mergestate.read(repo)
+if ms.active():
+# there were conflicts
+node = ms.localctx.hex()
+else:
+

D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG3fb0493812c0: abort: added support for unshelve (authored 
by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6579?vs=15866&id=15882

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.py
  mercurial/state.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -1,4 +1,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
-  $ hg unshelve --abort
+
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  unshelve in progress, will be aborted
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
-  $ hg unshelve --abort
-  abort: no unshelve in progress
+  $ hg abort
+  abort: no unshelve in progress (abortflag !)
+  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,7 @@
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [1]
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 Unshelve without .shelve metadata (can happen when upgrading a repository with 
old shelve)
@@ -843,7 +860,7 @@
   [1]
   $ cat .hg/shelved/default.shelve
   node=82e0cb9893247d12667017593ce1e5655860f1ac
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 #endif
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,10 +194,6 @@
 _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-'unshelve', fname='shelvedstate', continueflag=True,
-cmdmsg=_('unshelve already in progress')
-)
-addunfinished(
 'update', fname='updatestate', clearable=True,
 cmdmsg=_('last update was interrupted'),
 cmdhint=_("use 'hg update' to get a consistent checkout"),
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, opts):
+try:
+state = shelvedstate.load(repo)
+if opts.get('keep') is None:
+opts['keep'] = state.keep
+except IOError as err:
+if err.errno != errno.ENOENT:
+raise
+cmdutil.wrongtooltocontinue(repo, _('unshelve'))
+except error.CorruptedState as err:
+ui.debug(pycompat.bytestr(err) + '\n')
+if opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return state
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui, repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -665,7 +694,6 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-
 def unshelvecontinue(ui, repo, state, opts):
 "

D6636: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG8ddfdcce4bd6: unshelve: changed Corruptedstate error msg 
from ui.warn to error.Abort (authored by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6636?vs=15865&id=15881

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6636/new/

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -696,8 +696,10 @@
 
 Unshelve --abort works with a corrupted shelvedstate
   $ hg unshelve --abort
-  could not read shelved state file, your working copy may be in an unexpected 
state
+  abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
+  
+  [255]
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -880,12 +880,10 @@
  'operation')
 raise error.Abort(msg, hint=hint)
 elif abortf:
-msg = _('could not read shelved state file, your working copy '
-'may be in an unexpected state\nplease update to some '
-'commit\n')
-ui.warn(msg)
 shelvedstate.clear(repo)
-return
+raise error.Abort(_('could not read shelved state file, your '
+ 'working copy may be in an unexpected state\n'
+ 'please update to some commit\n'))
 
 if abortf:
 return unshelveabort(ui, repo, state, opts)



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


D6588: abort: added support for merge

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15880.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6588?vs=15879&id=15880

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6588/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  mercurial/state.py
  tests/test-commit-unresolved.t
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -718,11 +718,16 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
+
+#if abortflag
+  $ hg unshelve --abort
+  abort: no unshelve in progress
+  [255]
+#else
   $ hg abort
-  abort: no unshelve in progress (abortflag !)
-  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#endif
   $ cd ..
 
 Unshelve respects --keep even if user intervention is needed
diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t
--- a/tests/test-commit-unresolved.t
+++ b/tests/test-commit-unresolved.t
@@ -1,3 +1,11 @@
+#testcases abortcommand abortflag
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = merge --abort
+  > EOF
+#endif
+
   $ addcommit () {
   > echo $1 > $1
   > hg add $1
@@ -36,9 +44,11 @@
 
 Testing the abort functionality first in case of conflicts
 
-  $ hg merge --abort
-  abort: no merge in progress
+  $ hg abort
+  abort: no merge in progress (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
+
   $ hg merge
   merging A
   warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
@@ -53,7 +63,13 @@
   abort: cannot specify both --rev and --abort
   [255]
 
-  $ hg merge --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  merge in progress, will be aborted
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,7 @@
   abort: cannot specify --preview with --abort
   [255]
 
-  $ hg merge --abort
+  $ hg abort
   aborting the merge, updating back to 68352a18a7c4
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -205,13 +205,6 @@
  'To mark the changeset bad: hg bisect --bad\n'
  'To abort:  hg bisect --reset\n')
 )
-addunfinished(
-'merge', fname=None, clearable=True, allowcommit=True,
-cmdmsg=_('outstanding uncommitted merge'),
-statushint=_('To continue:hg commit\n'
- 'To abort:   hg merge --abort'),
-cmdhint=_("use 'hg commit' or 'hg merge --abort'")
-)
 
 def getrepostate(repo):
 # experimental config: commands.status.skipstates
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -956,31 +956,35 @@
   abort=False):
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
-if not abort:
-stats = mergemod.update(repo, node, branchmerge=True, force=force,
-mergeforce=mergeforce, labels=labels)
-else:
-ms = mergemod.mergestate.read(repo)
-if ms.active():
-# there were conflicts
-node = ms.localctx.hex()
-else:
-# there were no conficts, mergestate was not stored
-node = repo['.'].hex()
-
-repo.ui.status(_("aborting the merge, updating back to"
- " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
-
+if abort:
+return abortmerge(repo.ui, repo, labels=labels)
+
+stats = mergemod.update(repo, node, branchmerge=True, force=force,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
- "or 'hg merge --abort' to abandon\n"))
-elif remind and not abort:
+ "or 'hg merge --abort' todef abortmerge abandon\n"))
+elif remind:
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+ms = mergemod.mergestate.read(repo)
+if ms.active():
+# there were conflicts
+node = ms.localctx.hex()
+else:
+# there were no conficts, mergestate was not stored
+node = repo['.'].hex()
+
+repo.ui.status(_("aborting the m

D6588: abort: added support for merge

2019-07-10 Thread pulkit (Pulkit Goyal)
This revision is now accepted and ready to land.
pulkit added inline comments.
pulkit accepted this revision.

INLINE COMMENTS

> pulkit wrote in hg.py:987
> Here the user is already running `hg merge --abort`, so we should not show 
> this message.
> 
> Ideally, this `if` condition should not never when aborting a merge.

Turns out I am blind and the previous version already had everything correct. I 
will either apply previous version of fix things in flight.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6588/new/

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

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


D6625: rust-cargo: reorder dependencies

2019-07-10 Thread Raphaël Gomès
Alphare added a comment.
Alphare abandoned this revision.


  In D6625#96944 , @durin42 wrote:
  
  > Why? Before it was sorted, and now it's not.
  
  You're right, that makes no sense. I must have missed something during 
splitting. Sorry for the noise.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6625/new/

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

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


D6588: abort: added support for merge

2019-07-10 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> hg.py:987
> +if stats.unresolvedcount:
> +repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
> + "or 'hg merge --abort' to abandon\n"))

Here the user is already running `hg merge --abort`, so we should not show this 
message.

Ideally, this `if` condition should not never when aborting a merge.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6588/new/

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

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


D6588: abort: added support for merge

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15879.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6588?vs=15867&id=15879

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6588/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  mercurial/state.py
  tests/test-commit-unresolved.t
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -718,11 +718,16 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
+
+#if abortflag
+  $ hg unshelve --abort
+  abort: no unshelve in progress
+  [255]
+#else
   $ hg abort
-  abort: no unshelve in progress (abortflag !)
-  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#endif
   $ cd ..
 
 Unshelve respects --keep even if user intervention is needed
diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t
--- a/tests/test-commit-unresolved.t
+++ b/tests/test-commit-unresolved.t
@@ -1,3 +1,11 @@
+#testcases abortcommand abortflag
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = merge --abort
+  > EOF
+#endif
+
   $ addcommit () {
   > echo $1 > $1
   > hg add $1
@@ -36,9 +44,11 @@
 
 Testing the abort functionality first in case of conflicts
 
-  $ hg merge --abort
-  abort: no merge in progress
+  $ hg abort
+  abort: no merge in progress (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
+
   $ hg merge
   merging A
   warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
@@ -53,7 +63,13 @@
   abort: cannot specify both --rev and --abort
   [255]
 
-  $ hg merge --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  merge in progress, will be aborted
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,7 @@
   abort: cannot specify --preview with --abort
   [255]
 
-  $ hg merge --abort
+  $ hg abort
   aborting the merge, updating back to 68352a18a7c4
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -205,13 +205,6 @@
  'To mark the changeset bad: hg bisect --bad\n'
  'To abort:  hg bisect --reset\n')
 )
-addunfinished(
-'merge', fname=None, clearable=True, allowcommit=True,
-cmdmsg=_('outstanding uncommitted merge'),
-statushint=_('To continue:hg commit\n'
- 'To abort:   hg merge --abort'),
-cmdhint=_("use 'hg commit' or 'hg merge --abort'")
-)
 
 def getrepostate(repo):
 # experimental config: commands.status.skipstates
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -956,31 +956,38 @@
   abort=False):
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
-if not abort:
-stats = mergemod.update(repo, node, branchmerge=True, force=force,
-mergeforce=mergeforce, labels=labels)
-else:
-ms = mergemod.mergestate.read(repo)
-if ms.active():
-# there were conflicts
-node = ms.localctx.hex()
-else:
-# there were no conficts, mergestate was not stored
-node = repo['.'].hex()
-
-repo.ui.status(_("aborting the merge, updating back to"
- " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
-
+if abort:
+return abortmerge(repo.ui, repo, labels=labels)
+
+stats = mergemod.update(repo, node, branchmerge=True, force=force,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
  "or 'hg merge --abort' to abandon\n"))
-elif remind and not abort:
+elif remind:
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+ms = mergemod.mergestate.read(repo)
+if ms.active():
+# there were conflicts
+node = ms.localctx.hex()
+else:
+# there were no conficts, mergestate was not stored
+node = repo['.'].hex()
+
+repo.ui.status(_("aborting the merge, updating back to"
+ " %s\n") % node[:12])
+stats 

D6588: abort: added support for merge

2019-07-10 Thread pulkit (Pulkit Goyal)
This revision now requires changes to proceed.
pulkit added inline comments.
pulkit requested changes to this revision.

INLINE COMMENTS

> pulkit wrote in hg.py:985
> We lost `return stats.unresolvedcount > 0` in this code movement.

This is not yet addressed.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6588/new/

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

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


D6548: mq: fix for merge detection methods

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG51e52a495214: mq: fix for merge detection methods (authored 
by taapas1128).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6548?vs=15643&id=15878

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6548/new/

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

AFFECTED FILES
  hgext/mq.py
  tests/test-mq-qnew.t

CHANGE DETAILS

diff --git a/tests/test-mq-qnew.t b/tests/test-mq-qnew.t
--- a/tests/test-mq-qnew.t
+++ b/tests/test-mq-qnew.t
@@ -164,8 +164,7 @@
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to 
abandon
   (no more unresolved files)
-  abort: outstanding uncommitted merge
-  (use 'hg commit' or 'hg merge --abort')
+  abort: cannot manage merge changesets
   $ rm -r sandbox
 
 hg headers
@@ -244,8 +243,7 @@
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to 
abandon
   (no more unresolved files)
-  abort: outstanding uncommitted merge
-  (use 'hg commit' or 'hg merge --abort')
+  abort: cannot manage merge changesets
   $ rm -r sandbox
 
 Test saving last-message.txt
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1162,18 +1162,17 @@
 _("local changes found, qrefresh first")
 _("local changed subrepos found, qrefresh first")
 
-cmdutil.checkunfinished(repo)
 s = repo.status()
 if not force:
-if len(repo[None].parents()) > 1:
-_("outstanding uncommitted merge") #i18 tool detection
-raise error.Abort(_("outstanding uncommitted merge"+ 
excsuffix))
+cmdutil.checkunfinished(repo)
 if s.modified or s.added or s.removed or s.deleted:
 _("local changes found") # i18n tool detection
 raise error.Abort(_("local changes found" + excsuffix))
 if checksubstate(repo):
 _("local changed subrepos found") # i18n tool detection
 raise error.Abort(_("local changed subrepos found" + 
excsuffix))
+else:
+cmdutil.checkunfinished(repo, skipmerge=True)
 return s
 
 _reserved = ('series', 'status', 'guards', '.', '..')



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


D6636: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

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


  Fixed the message.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6636/new/

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

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


D6572: subrepos: make last line of prompts <40 english chars (issue6158)

2019-07-10 Thread spectral (Kyle Lippincott)
Closed by commit rHGf6540aba8e3e: subrepos: make last line of prompts <40 
english chars (issue6158) (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6572?vs=15655&id=15869

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6572/new/

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

AFFECTED FILES
  mercurial/subrepo.py
  mercurial/subrepoutil.py
  tests/test-largefiles-update.t
  tests/test-mq-subrepo.t
  tests/test-subrepo-git.t
  tests/test-subrepo-svn.t
  tests/test-subrepo.t

CHANGE DETAILS

diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -309,13 +309,14 @@
 subrepo t: both sides changed 
subrepository t diverged (local revision: 20a0db6fbf6c, remote revision: 
7af322bc1198)
   starting 4 threads for background file closing (?)
-  (M)erge, keep (l)ocal [working copy] or keep (r)emote [merge rev]? m
+  you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [merge rev].
+  what do you want to do? m
   merging subrepository "t"
   resolving manifests
branchmerge: True, force: False, partial: False
ancestor: 6747d179aa9a, local: 20a0db6fbf6c+, remote: 7af322bc1198
+  starting 4 threads for background file closing (?)
preserving t for resolve of t
-  starting 4 threads for background file closing (?)
t: versions differ -> m (premerge)
   picked tool ':merge' for t (binary False symlink False changedelete False)
   merging t
@@ -908,7 +909,8 @@
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg merge 4# try to merge default into br again
subrepository s diverged (local revision: f8f13b33206e, remote revision: 
a3f9062a4f88)
-  (M)erge, keep (l)ocal [working copy] or keep (r)emote [merge rev]? m
+  you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [merge rev].
+  what do you want to do? m
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ cd ..
@@ -1199,7 +1201,8 @@
   added 1 changesets with 2 changes to 2 files
   new changesets c82b79fdcc5b
subrepository sub/repo diverged (local revision: f42d5c7504a8, remote 
revision: 46cd4aac504c)
-  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
+  you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
+  what do you want to do? m
   pulling subrepo sub/repo from $TESTTMP/issue1852a/sub/repo
   searching for changes
   adding changesets
@@ -1208,7 +1211,8 @@
   added 1 changesets with 1 changes to 1 files
   new changesets 46cd4aac504c
subrepository sources for sub/repo differ
-  use (l)ocal source (f42d5c7504a8) or (r)emote source (46cd4aac504c)? l
+  you can use (l)ocal source (f42d5c7504a8) or (r)emote source (46cd4aac504c).
+  what do you want to do? l
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cat issue1852d/.hgsubstate
   f42d5c7504a811dda50f5cf3e5e16c3330b87172 sub/repo
@@ -1335,13 +1339,17 @@
   e95bcfa18a35+
   $ hg update tip
subrepository s diverged (local revision: fc627a69481f, remote revision: 
12a213df6fa9)
-  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
+  you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
+  what do you want to do? m
subrepository sources for s differ
-  use (l)ocal source (fc627a69481f) or (r)emote source (12a213df6fa9)? l
+  you can use (l)ocal source (fc627a69481f) or (r)emote source (12a213df6fa9).
+  what do you want to do? l
subrepository t diverged (local revision: e95bcfa18a35, remote revision: 
52c0adc0515a)
-  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
+  you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
+  what do you want to do? m
subrepository sources for t differ
-  use (l)ocal source (e95bcfa18a35) or (r)emote source (52c0adc0515a)? l
+  you can use (l)ocal source (e95bcfa18a35) or (r)emote source (52c0adc0515a).
+  what do you want to do? l
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg id
   925c17564ef8+ tip
@@ -1368,11 +1376,14 @@
   $ cd ..
   $ hg update 10
subrepository s diverged (local revision: 12a213df6fa9, remote revision: 
fc627a69481f)
-  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
+  you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
+  what do you want to do? m
subrepository t diverged (local revision: 52c0adc0515a, remote revision: 
20a0db6fbf6c)
-  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
+  you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
+  what do you want to do? m
subrepository sources for t dif

D6603: copies: filter invalid copies only at end of pathcopies() (issue6163)

2019-07-10 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHGd013099c551b: copies: filter invalid copies only at end of 
pathcopies() (issue6163) (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6603?vs=15747&id=15876

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6603/new/

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

AFFECTED FILES
  mercurial/copies.py
  tests/test-copies-unrelated.t
  tests/test-copies.t

CHANGE DETAILS

diff --git a/tests/test-copies.t b/tests/test-copies.t
--- a/tests/test-copies.t
+++ b/tests/test-copies.t
@@ -354,8 +354,7 @@
   $ hg debugpathcopies 1 3
   x -> z
 
-Copy x to y on one side of merge, create y and rename to z on the other side. 
Pathcopies from the
-first side should not include the y->z rename since y didn't exist in the 
merge base.
+Copy x to y on one side of merge, create y and rename to z on the other side.
   $ newrepo
   $ echo x > x
   $ hg ci -Aqm 'add x'
@@ -385,6 +384,7 @@
   $ hg debugpathcopies 2 3
   y -> z
   $ hg debugpathcopies 1 3
+  y -> z (no-filelog !)
 
 Create x and y, then rename x to z on one side of merge, and rename y to z and
 modify z on the other side. When storing copies in the changeset, we don't
diff --git a/tests/test-copies-unrelated.t b/tests/test-copies-unrelated.t
--- a/tests/test-copies-unrelated.t
+++ b/tests/test-copies-unrelated.t
@@ -299,6 +299,8 @@
   o  0 base
  a
   $ hg debugpathcopies 1 4
+  x -> y (no-filelog !)
+#if filelog
 BROKEN: This should succeed and merge the changes from x into y
   $ hg graft -r 2
   grafting 2:* "modify x" (glob)
@@ -308,6 +310,11 @@
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
   [255]
+#else
+  $ hg graft -r 2
+  grafting 2:* "modify x" (glob)
+  merging y and x to y
+#endif
   $ hg co -qC 2
   $ hg graft -r 4
   grafting 4:* "rename x to y"* (glob)
@@ -345,6 +352,8 @@
   o  0 base
  a
   $ hg debugpathcopies 1 5
+  x -> y (no-filelog !)
+#if filelog
 BROKEN: This should succeed and merge the changes from x into y
   $ hg graft -r 2
   grafting 2:* "modify x" (glob)
@@ -354,6 +363,11 @@
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
   [255]
+#else
+  $ hg graft -r 2
+  grafting 2:* "modify x" (glob)
+  merging y and x to y
+#endif
   $ hg co -qC 2
 BROKEN: This should succeed and merge the changes from x into y
   $ hg graft -r 5
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -285,7 +285,6 @@
 # that side, even if it was also copied on the p2 side.
 copies[dst] = copies2[dst]
 if r == b.rev():
-_filter(a, b, copies)
 return copies
 for i, c in enumerate(children[r]):
 childctx = repo[c]
@@ -321,7 +320,6 @@
 cm = _committedforwardcopies(a, b.p1(), match)
 # combine copies from dirstate if necessary
 copies = _chain(cm, _dirstatecopies(b._repo, match))
-_filter(a, b, copies)
 else:
 copies  = _committedforwardcopies(a, b, match)
 return copies
@@ -373,7 +371,7 @@
 repo.ui.debug('debug.copies: search mode: combined\n')
 copies = _chain(_backwardrenames(x, a, match=match),
 _forwardcopies(a, y, match=match))
-_filter(x, y, copies)
+_filter(x, y, copies)
 return copies
 
 def mergecopies(repo, c1, c2, base):



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


D6623: py3: store _origdoc as str

2019-07-10 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHG83666f011679: py3: store _origdoc as str (authored by 
martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6623?vs=15855&id=15877

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6623/new/

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

AFFECTED FILES
  hgext/show.py
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -64,8 +64,8 @@
 raise error.ProgrammingError(msg)
 
 if func.__doc__ and not util.safehasattr(func, '_origdoc'):
-doc = pycompat.sysbytes(func.__doc__).strip()
-func._origdoc = doc
+func._origdoc = func.__doc__.strip()
+doc = pycompat.sysbytes(func._origdoc)
 func.__doc__ = pycompat.sysstr(self._formatdoc(decl, doc))
 
 self._table[name] = func
diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -460,8 +460,8 @@
 longest = max(map(len, showview._table.keys()))
 entries = []
 for key in sorted(showview._table.keys()):
-entries.append(pycompat.sysstr('%s   %s' % (
-key.ljust(longest), showview._table[key]._origdoc)))
+entries.append(r'%s   %s' % (
+pycompat.sysstr(key.ljust(longest)), 
showview._table[key]._origdoc))
 
 cmdtable['show'][0].__doc__ = pycompat.sysstr('%s\n\n%s\n') % (
 cmdtable['show'][0].__doc__.rstrip(),



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


D6604: copies: follow copies across merge base without source file (issue6163)

2019-07-10 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHG819712deac69: copies: follow copies across merge base 
without source file (issue6163) (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6604?vs=15748&id=15875

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6604/new/

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

AFFECTED FILES
  mercurial/copies.py
  tests/test-copies-unrelated.t

CHANGE DETAILS

diff --git a/tests/test-copies-unrelated.t b/tests/test-copies-unrelated.t
--- a/tests/test-copies-unrelated.t
+++ b/tests/test-copies-unrelated.t
@@ -299,22 +299,10 @@
   o  0 base
  a
   $ hg debugpathcopies 1 4
-  x -> y (no-filelog !)
-#if filelog
-BROKEN: This should succeed and merge the changes from x into y
-  $ hg graft -r 2
-  grafting 2:* "modify x" (glob)
-  file 'x' was deleted in local [local] but was modified in other [graft].
-  What do you want to do?
-  use (c)hanged version, leave (d)eleted, or leave (u)nresolved? u
-  abort: unresolved conflicts, can't continue
-  (use 'hg resolve' and 'hg graft --continue')
-  [255]
-#else
+  x -> y
   $ hg graft -r 2
   grafting 2:* "modify x" (glob)
   merging y and x to y
-#endif
   $ hg co -qC 2
   $ hg graft -r 4
   grafting 4:* "rename x to y"* (glob)
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -150,7 +150,7 @@
 t[k] = v
 return t
 
-def _tracefile(fctx, am, limit):
+def _tracefile(fctx, am, basemf, limit):
 """return file context that is the ancestor of fctx present in ancestor
 manifest am, stopping after the first ancestor lower than limit"""
 
@@ -158,6 +158,8 @@
 path = f.path()
 if am.get(path, None) == f.filenode():
 return path
+if basemf and basemf.get(path, None) == f.filenode():
+return path
 if not f.isintroducedafter(limit):
 return None
 
@@ -183,7 +185,7 @@
 return (repo.ui.config('experimental', 'copies.read-from') in
 ('changeset-only', 'compatibility'))
 
-def _committedforwardcopies(a, b, match):
+def _committedforwardcopies(a, b, base, match):
 """Like _forwardcopies(), but b.rev() cannot be None (working copy)"""
 # files might have to be traced back to the fctx parent of the last
 # one-side-only changeset, but not further back than that
@@ -201,6 +203,7 @@
 if debug:
 dbg('debug.copies:  search limit: %d\n' % limit)
 am = a.manifest()
+basemf = None if base is None else base.manifest()
 
 # find where new files came from
 # we currently don't try to find where old files went, too expensive
@@ -232,7 +235,7 @@
 
 if debug:
 start = util.timer()
-opath = _tracefile(fctx, am, limit)
+opath = _tracefile(fctx, am, basemf, limit)
 if opath:
 if debug:
 dbg('debug.copies:  rename of: %s\n' % opath)
@@ -311,17 +314,19 @@
 heapq.heappush(work, (c, parent, newcopies))
 assert False
 
-def _forwardcopies(a, b, match=None):
+def _forwardcopies(a, b, base=None, match=None):
 """find {dst@b: src@a} copy mapping where a is an ancestor of b"""
 
+if base is None:
+base = a
 match = a.repo().narrowmatch(match)
 # check for working copy
 if b.rev() is None:
-cm = _committedforwardcopies(a, b.p1(), match)
+cm = _committedforwardcopies(a, b.p1(), base, match)
 # combine copies from dirstate if necessary
 copies = _chain(cm, _dirstatecopies(b._repo, match))
 else:
-copies  = _committedforwardcopies(a, b, match)
+copies  = _committedforwardcopies(a, b, base, match)
 return copies
 
 def _backwardrenames(a, b, match):
@@ -369,8 +374,11 @@
 else:
 if debug:
 repo.ui.debug('debug.copies: search mode: combined\n')
+base = None
+if a.rev() != node.nullrev:
+base = x
 copies = _chain(_backwardrenames(x, a, match=match),
-_forwardcopies(a, y, match=match))
+_forwardcopies(a, y, base, match=match))
 _filter(x, y, copies)
 return copies
 



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


D6602: copies: inline _chainandfilter() to prepare for next patch

2019-07-10 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHG11ceb1b8fd74: copies: inline _chainandfilter() to prepare 
for next patch (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6602?vs=15746&id=15874

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6602/new/

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -107,13 +107,13 @@
 # This only occurs when a is a descendent of b or visa-versa.
 return min(limit, a, b)
 
-def _chainandfilter(src, dst, a, b):
-"""chain two sets of copies 'a' and 'b' and filter result"""
+def _filter(src, dst, t):
+"""filters out invalid copies after chaining"""
 
-# When chaining copies in 'a' (from 'src' via some other commit 'mid') with
-# copies in 'b' (from 'mid' to 'dst'), we can get the different cases in 
the
-# following table (not including trivial cases). For example, case 2 is
-# where a file existed in 'src' and remained under that name in 'mid' and
+# When _chain()'ing copies in 'a' (from 'src' via some other commit 'mid')
+# with copies in 'b' (from 'mid' to 'dst'), we can get the different cases
+# in the following table (not including trivial cases). For example, case 2
+# is where a file existed in 'src' and remained under that name in 'mid' 
and
 # then was renamed between 'mid' and 'dst'.
 #
 # case src mid dst result
@@ -129,12 +129,6 @@
 # between 5 and 6, so it includes all cases in its result.
 # Cases 1, 3, and 5 are then removed by _filter().
 
-t = _chain(a, b)
-_filter(src, dst, t)
-return t
-
-def _filter(src, dst, t):
-"""filters out invalid copies after chaining"""
 for k, v in list(t.items()):
 # remove copies from files that didn't exist
 if v not in src:
@@ -326,7 +320,8 @@
 if b.rev() is None:
 cm = _committedforwardcopies(a, b.p1(), match)
 # combine copies from dirstate if necessary
-copies = _chainandfilter(a, b, cm, _dirstatecopies(b._repo, match))
+copies = _chain(cm, _dirstatecopies(b._repo, match))
+_filter(a, b, copies)
 else:
 copies  = _committedforwardcopies(a, b, match)
 return copies
@@ -376,8 +371,9 @@
 else:
 if debug:
 repo.ui.debug('debug.copies: search mode: combined\n')
-copies = _chainandfilter(x, y, _backwardrenames(x, a, match=match),
- _forwardcopies(a, y, match=match))
+copies = _chain(_backwardrenames(x, a, match=match),
+_forwardcopies(a, y, match=match))
+_filter(x, y, copies)
 return copies
 
 def mergecopies(repo, c1, c2, base):



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


D6601: copies: remove most early returns from pathcopies() and _forwardcopies()

2019-07-10 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHGa48f6f18dc6d: copies: remove most early returns from 
pathcopies() and _forwardcopies() (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6601?vs=15745&id=15873

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6601/new/

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -326,8 +326,10 @@
 if b.rev() is None:
 cm = _committedforwardcopies(a, b.p1(), match)
 # combine copies from dirstate if necessary
-return _chainandfilter(a, b, cm, _dirstatecopies(b._repo, match))
-return _committedforwardcopies(a, b, match)
+copies = _chainandfilter(a, b, cm, _dirstatecopies(b._repo, match))
+else:
+copies  = _committedforwardcopies(a, b, match)
+return copies
 
 def _backwardrenames(a, b, match):
 if a._repo.ui.config('experimental', 'copytrace') == 'off':
@@ -366,15 +368,17 @@
 if y.rev() is None and x == y.p1():
 # short-circuit to avoid issues with merge states
 return _dirstatecopies(repo, match)
-return _forwardcopies(x, y, match=match)
-if a == y:
+copies = _forwardcopies(x, y, match=match)
+elif a == y:
 if debug:
 repo.ui.debug('debug.copies: search mode: backward\n')
-return _backwardrenames(x, y, match=match)
-if debug:
-repo.ui.debug('debug.copies: search mode: combined\n')
-return _chainandfilter(x, y, _backwardrenames(x, a, match=match),
-   _forwardcopies(a, y, match=match))
+copies = _backwardrenames(x, y, match=match)
+else:
+if debug:
+repo.ui.debug('debug.copies: search mode: combined\n')
+copies = _chainandfilter(x, y, _backwardrenames(x, a, match=match),
+ _forwardcopies(a, y, match=match))
+return copies
 
 def mergecopies(repo, c1, c2, base):
 """



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


D6571: largefiles: make last line of prompts <40 english chars (issue6158)

2019-07-10 Thread spectral (Kyle Lippincott)
Closed by commit rHG421fdf30c37c: largefiles: make last line of prompts <40 
english chars (issue6158) (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6571?vs=15654&id=15868

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6571/new/

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  tests/test-largefiles-misc.t
  tests/test-largefiles-update.t
  tests/test-largefiles.t

CHANGE DETAILS

diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1701,8 +1701,8 @@
   $ hg merge
   largefile sub/large4 has a merge conflict
   ancestor was 971fb41e78fea4f8e0ba5244784239371cb00591
-  keep (l)ocal d846f26643bfa8ec210be40cc93cc6b7ff1128ea or
-  take (o)ther e166e74c7303192238d60af5a9c4ce9bef0b7928? l
+  you can keep (l)ocal d846f26643bfa8ec210be40cc93cc6b7ff1128ea or take 
(o)ther e166e74c7303192238d60af5a9c4ce9bef0b7928.
+  what do you want to do? l
   getting changed largefiles
   1 largefiles updated, 0 removed
   3 files updated, 1 files merged, 0 files removed, 0 files unresolved
diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t
--- a/tests/test-largefiles-update.t
+++ b/tests/test-largefiles-update.t
@@ -133,8 +133,8 @@
   > EOF
   largefile large1 has a merge conflict
   ancestor was 4669e532d5b2c093a78eca010077e708a071bb64
-  keep (l)ocal e5bb990443d6a92aaf7223813720f7566c9dd05b or
-  take (o)ther 58e24f733a964da346e2407a2bee99d9001184f5? o
+  you can keep (l)ocal e5bb990443d6a92aaf7223813720f7566c9dd05b or take 
(o)ther 58e24f733a964da346e2407a2bee99d9001184f5.
+  what do you want to do? o
   merging normal1
   warning: conflicts while merging normal1! (edit, then use 'hg resolve 
--mark')
   getting changed largefiles
@@ -161,8 +161,8 @@
   > EOF
   largefile large1 has a merge conflict
   ancestor was 4669e532d5b2c093a78eca010077e708a071bb64
-  keep (l)ocal e5bb990443d6a92aaf7223813720f7566c9dd05b or
-  take (o)ther 58e24f733a964da346e2407a2bee99d9001184f5? o
+  you can keep (l)ocal e5bb990443d6a92aaf7223813720f7566c9dd05b or take 
(o)ther 58e24f733a964da346e2407a2bee99d9001184f5.
+  what do you want to do? o
   getting changed largefiles
   large1: largefile 58e24f733a964da346e2407a2bee99d9001184f5 not available 
from file:/*/$TESTTMP/repo (glob)
   0 largefiles updated, 0 removed
@@ -361,8 +361,8 @@
   > EOF
   largefile large1 has a merge conflict
   ancestor was 4669e532d5b2c093a78eca010077e708a071bb64
-  keep (l)ocal ba94c2efe5b7c5e0af8d189295ce00553b0612b7 or
-  take (o)ther e5bb990443d6a92aaf7223813720f7566c9dd05b? o
+  you can keep (l)ocal ba94c2efe5b7c5e0af8d189295ce00553b0612b7 or take 
(o)ther e5bb990443d6a92aaf7223813720f7566c9dd05b.
+  what do you want to do? o
   getting changed largefiles
   1 largefiles updated, 0 removed
   1 files updated, 1 files merged, 0 files removed, 0 files unresolved
@@ -380,8 +380,8 @@
   $ hg update 3 --config debug.dirstate.delaywrite=2
   largefile large1 has a merge conflict
   ancestor was 4669e532d5b2c093a78eca010077e708a071bb64
-  keep (l)ocal ba94c2efe5b7c5e0af8d189295ce00553b0612b7 or
-  take (o)ther e5bb990443d6a92aaf7223813720f7566c9dd05b? l
+  you can keep (l)ocal ba94c2efe5b7c5e0af8d189295ce00553b0612b7 or take 
(o)ther e5bb990443d6a92aaf7223813720f7566c9dd05b.
+  what do you want to do? l
   1 files updated, 1 files merged, 0 files removed, 0 files unresolved
   $ hg status -A large1
   M large1
@@ -461,8 +461,8 @@
   keep (l)argefile or use (n)ormal file? l
   largefile large1 has a merge conflict
   ancestor was 4669e532d5b2c093a78eca010077e708a071bb64
-  keep (l)ocal ba94c2efe5b7c5e0af8d189295ce00553b0612b7 or
-  take (o)ther e5bb990443d6a92aaf7223813720f7566c9dd05b? l
+  you can keep (l)ocal ba94c2efe5b7c5e0af8d189295ce00553b0612b7 or take 
(o)ther e5bb990443d6a92aaf7223813720f7566c9dd05b.
+  what do you want to do? l
   2 files updated, 1 files merged, 0 files removed, 0 files unresolved
   updated to "d65e59e952a9: #5"
   1 other heads for branch "default"
@@ -497,8 +497,8 @@
   keep (l)argefile or use (n)ormal file? l
   largefile large1 has a merge conflict
   ancestor was 4669e532d5b2c093a78eca010077e708a071bb64
-  keep (l)ocal ba94c2efe5b7c5e0af8d189295ce00553b0612b7 or
-  take (o)ther e5bb990443d6a92aaf7223813720f7566c9dd05b? l
+  you can keep (l)ocal ba94c2efe5b7c5e0af8d189295ce00553b0612b7 or take 
(o)ther e5bb990443d6a92aaf7223813720f7566c9dd05b.
+  what do you want to do? l
   2 files updated, 1 files merged, 0 files removed, 0 files unresolved
   updated to "d65e59e952a9: #5"
   1 other heads for branch "default"
@@ -552,8 +552,8 @@
   keep (l)argefile or use (n)ormal file? l
   largefile large1 has a merge conflict
   ancestor was 4669e532d5b2c093a78eca0

D6600: copies: move short-circuiting of dirstate copies out of _forwardcopies()

2019-07-10 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHGbcb4b5c5964b: copies: move short-circuiting of dirstate 
copies out of _forwardcopies() (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6600?vs=15744&id=15872

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6600/new/

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -324,10 +324,6 @@
 match = a.repo().narrowmatch(match)
 # check for working copy
 if b.rev() is None:
-if a == b.p1():
-# short-circuit to avoid issues with merge states
-return _dirstatecopies(b._repo, match)
-
 cm = _committedforwardcopies(a, b.p1(), match)
 # combine copies from dirstate if necessary
 return _chainandfilter(a, b, cm, _dirstatecopies(b._repo, match))
@@ -367,6 +363,9 @@
 if a == x:
 if debug:
 repo.ui.debug('debug.copies: search mode: forward\n')
+if y.rev() is None and x == y.p1():
+# short-circuit to avoid issues with merge states
+return _dirstatecopies(repo, match)
 return _forwardcopies(x, y, match=match)
 if a == y:
 if debug:



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


D6599: tests: add more tests of copy tracing with removed and re-added files

2019-07-10 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHGab416b5d9b91: tests: add more tests of copy tracing with 
removed and re-added files (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6599?vs=15743&id=15871#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6599?vs=15743&id=15871

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6599/new/

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

AFFECTED FILES
  tests/test-copies-unrelated.t
  tests/test-rename-merge1.t

CHANGE DETAILS

diff --git a/tests/test-rename-merge1.t b/tests/test-rename-merge1.t
--- a/tests/test-rename-merge1.t
+++ b/tests/test-rename-merge1.t
@@ -184,52 +184,3 @@
   $ hg status
   M newfile
   $ cd ..
-
-Check that file is considered unrelated when deleted and recreated
-
-  $ hg init unrelated
-  $ cd unrelated
-  $ echo foo > file
-  $ hg add file
-  $ hg commit -m "added file"
-  $ hg cp file newfile
-  $ hg commit -m "copy file"
-  $ hg update 0
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ hg rm file
-  $ hg commit -m "deleted file"
-  created new head
-  $ echo bar > file
-  $ hg add file
-  $ hg ci -m 'recreate file'
-  $ hg log -G -T '{rev} {desc}\n'
-  @  3 recreate file
-  |
-  o  2 deleted file
-  |
-  | o  1 copy file
-  |/
-  o  0 added file
-  
-BROKEN: this is inconsistent with `hg merge` (below), which doesn't consider
-'file' renamed same since it was deleted for a while
-  $ hg st --copies --rev 3 --rev 1
-  M file
-  A newfile
-file
-  $ hg merge --debug 1
-unmatched files in other:
- newfile
-all copies found (* = to merge, ! = divergent, % = renamed and deleted):
- src: 'file' -> dst: 'newfile' 
-checking for directory renames
-  resolving manifests
-   branchmerge: True, force: False, partial: False
-   ancestor: 19d7f95df299, local: 4e4a42b1cbdf+, remote: 45b14aae7432
-   newfile: remote created -> g
-  getting newfile
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  (branch merge, don't forget to commit)
-  $ hg status
-  M newfile
-  $ cd ..
diff --git a/tests/test-copies-unrelated.t b/tests/test-copies-unrelated.t
--- a/tests/test-copies-unrelated.t
+++ b/tests/test-copies-unrelated.t
@@ -34,48 +34,336 @@
   $ newrepo
   $ echo x > x
   $ hg ci -Aqm 'add x'
+  $ echo x2 > x
+  $ hg ci -m 'modify x'
+  $ hg co -q 0
   $ hg cp x y
-  $ hg ci -m 'copy x to y'
+  $ hg ci -qm 'copy x to y'
   $ hg rm y
   $ hg ci -m 'remove y'
   $ hg cp -f x y
   $ hg ci -m 'copy x onto y (again)'
   $ hg l
-  @  3 copy x onto y (again)
+  @  4 copy x onto y (again)
+  |  y
+  o  3 remove y
   |  y
-  o  2 remove y
+  o  2 copy x to y
   |  y
-  o  1 copy x to y
-  |  y
+  | o  1 modify x
+  |/   x
   o  0 add x
  x
-  $ hg debugp1copies -r 3
+  $ hg debugp1copies -r 4
   x -> y
-  $ hg debugpathcopies 0 3
+  $ hg debugpathcopies 0 4
   x -> y
+  $ hg graft -r 1
+  grafting 1:* "modify x" (glob)
+  merging y and x to y
+  $ hg co -qC 1
+  $ hg graft -r 4
+  grafting 4:* "copy x onto y (again)" (glob)
+  merging x and y to y
 
-Copy x to y, then remove y, then add back y. With copy metadata in the 
changeset, this could easily
-end up reporting y as copied from x (if we don't unmark it as a copy when it's 
removed).
+Copy x to y, then remove y, then add back y. With copy metadata in the
+changeset, this could easily end up reporting y as copied from x (if we don't
+unmark it as a copy when it's removed). Despite x and y not being related, we
+want grafts to propagate across the rename.
   $ newrepo
   $ echo x > x
   $ hg ci -Aqm 'add x'
+  $ echo x2 > x
+  $ hg ci -m 'modify x'
+  $ hg co -q 0
   $ hg mv x y
-  $ hg ci -m 'rename x to y'
+  $ hg ci -qm 'rename x to y'
   $ hg rm y
   $ hg ci -qm 'remove y'
   $ echo x > y
   $ hg ci -Aqm 'add back y'
   $ hg l
-  @  3 add back y
+  @  4 add back y
+  |  y
+  o  3 remove y
   |  y
-  o  2 remove y
-  |  y
-  o  1 rename x to y
+  o  2 rename x to y
+  |  x y
+  | o  1 modify x
+  |/   x
+  o  0 add x
+ x
+  $ hg debugpathcopies 0 4
+BROKEN: This should succeed and merge the changes from x into y
+  $ hg graft -r 1
+  grafting 1:* "modify x" (glob)
+  file 'x' was deleted in local [local] but was modified in other [graft].
+  You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
+  What do you want to do? u
+  abort: unresolved conflicts, can't continue
+  (use 'hg resolve' and 'hg graft --continue')
+  [255]
+
+Add x, remove it, then add it back, then rename x to y. Similar to the case
+above, but here the break in history is before the rename.
+  $ newrepo
+  $ echo x > x
+  $ hg ci -Aqm 'add x'
+  $ echo x2 > x
+  $ hg ci -m 'modify x'
+  $ hg co -q 0
+  $ hg rm x
+  $ hg ci -qm 'remove x'
+  $ echo x > x
+  $ hg ci -Aqm 'add x again'
+  $ hg mv x y
+  $ hg c

D6598: tests: split out tests for unrelated copy source/target into separate file

2019-07-10 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHG67bf11597eb8: tests: split out tests for unrelated copy 
source/target into separate file (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6598?vs=15742&id=15870

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6598/new/

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

AFFECTED FILES
  tests/test-copies-unrelated.t
  tests/test-copies.t

CHANGE DETAILS

diff --git a/tests/test-copies.t b/tests/test-copies.t
--- a/tests/test-copies.t
+++ b/tests/test-copies.t
@@ -96,30 +96,6 @@
 Incorrectly doesn't show the rename
   $ hg debugpathcopies 0 1
 
-Copy a file, then delete destination, then copy again. This does not create a 
new filelog entry.
-  $ newrepo
-  $ echo x > x
-  $ hg ci -Aqm 'add x'
-  $ hg cp x y
-  $ hg ci -m 'copy x to y'
-  $ hg rm y
-  $ hg ci -m 'remove y'
-  $ hg cp -f x y
-  $ hg ci -m 'copy x onto y (again)'
-  $ hg l
-  @  3 copy x onto y (again)
-  |  y
-  o  2 remove y
-  |  y
-  o  1 copy x to y
-  |  y
-  o  0 add x
- x
-  $ hg debugp1copies -r 3
-  x -> y
-  $ hg debugpathcopies 0 3
-  x -> y
-
 Rename file in a loop: x->y->z->x
   $ newrepo
   $ echo x > x
@@ -144,29 +120,6 @@
  x
   $ hg debugpathcopies 0 3
 
-Copy x to y, then remove y, then add back y. With copy metadata in the 
changeset, this could easily
-end up reporting y as copied from x (if we don't unmark it as a copy when it's 
removed).
-  $ newrepo
-  $ echo x > x
-  $ hg ci -Aqm 'add x'
-  $ hg mv x y
-  $ hg ci -m 'rename x to y'
-  $ hg rm y
-  $ hg ci -qm 'remove y'
-  $ echo x > y
-  $ hg ci -Aqm 'add back y'
-  $ hg l
-  @  3 add back y
-  |  y
-  o  2 remove y
-  |  y
-  o  1 rename x to y
-  |  x y
-  o  0 add x
- x
-  $ hg debugp1copies -r 3
-  $ hg debugpathcopies 0 3
-
 Copy x to z, then remove z, then copy x2 (same content as x) to z. With copy 
metadata in the
 changeset, the two copies here will have the same filelog entry, so 
ctx['z'].introrev() might point
 to the first commit that added the file. We should still report the copy as 
being from x2.
@@ -234,25 +187,6 @@
  x
   $ hg debugpathcopies 1 2
 
-Copies via null revision (there shouldn't be any)
-  $ newrepo
-  $ echo x > x
-  $ hg ci -Aqm 'add x'
-  $ hg cp x y
-  $ hg ci -m 'copy x to y'
-  $ hg co -q null
-  $ echo x > x
-  $ hg ci -Aqm 'add x (again)'
-  $ hg l
-  @  2 add x (again)
- x
-  o  1 copy x to y
-  |  y
-  o  0 add x
- x
-  $ hg debugpathcopies 1 2
-  $ hg debugpathcopies 2 1
-
 Merge rename from other branch
   $ newrepo
   $ echo x > x
diff --git a/tests/test-copies.t b/tests/test-copies-unrelated.t
copy from tests/test-copies.t
copy to tests/test-copies-unrelated.t
--- a/tests/test-copies.t
+++ b/tests/test-copies-unrelated.t
@@ -30,72 +30,6 @@
   > cd repo-$REPONUM
   > }
 
-Simple rename case
-  $ newrepo
-  $ echo x > x
-  $ hg ci -Aqm 'add x'
-  $ hg mv x y
-  $ hg debugp1copies
-  x -> y
-  $ hg debugp2copies
-  $ hg ci -m 'rename x to y'
-  $ hg l
-  @  1 rename x to y
-  |  x y
-  o  0 add x
- x
-  $ hg debugp1copies -r 1
-  x -> y
-  $ hg debugpathcopies 0 1
-  x -> y
-  $ hg debugpathcopies 1 0
-  y -> x
-Test filtering copies by path. We do filtering by destination.
-  $ hg debugpathcopies 0 1 x
-  $ hg debugpathcopies 1 0 x
-  y -> x
-  $ hg debugpathcopies 0 1 y
-  x -> y
-  $ hg debugpathcopies 1 0 y
-
-Copy a file onto another file
-  $ newrepo
-  $ echo x > x
-  $ echo y > y
-  $ hg ci -Aqm 'add x and y'
-  $ hg cp -f x y
-  $ hg debugp1copies
-  x -> y
-  $ hg debugp2copies
-  $ hg ci -m 'copy x onto y'
-  $ hg l
-  @  1 copy x onto y
-  |  y
-  o  0 add x and y
- x y
-  $ hg debugp1copies -r 1
-  x -> y
-Incorrectly doesn't show the rename
-  $ hg debugpathcopies 0 1
-
-Copy a file onto another file with same content. If metadata is stored in 
changeset, this does not
-produce a new filelog entry. The changeset's "files" entry should still list 
the file.
-  $ newrepo
-  $ echo x > x
-  $ echo x > x2
-  $ hg ci -Aqm 'add x and x2 with same content'
-  $ hg cp -f x x2
-  $ hg ci -m 'copy x onto x2'
-  $ hg l
-  @  1 copy x onto x2
-  |  x2
-  o  0 add x and x2 with same content
- x x2
-  $ hg debugp1copies -r 1
-  x -> x2
-Incorrectly doesn't show the rename
-  $ hg debugpathcopies 0 1
-
 Copy a file, then delete destination, then copy again. This does not create a 
new filelog entry.
   $ newrepo
   $ echo x > x
@@ -120,30 +54,6 @@
   $ hg debugpathcopies 0 3
   x -> y
 
-Rename file in a loop: x->y->z->x
-  $ newrepo
-  $ echo x > x
-  $ hg ci -Aqm 'add x'
-  $ hg mv x y
-  $ hg debugp1copies
-  x -> y
-  $ hg debugp2copies
-  $ hg ci -m 'rename x to y'
-  $ hg mv y z
-  $ hg ci -m 'rename y to z'
-  $ hg mv z x
-  $ hg ci -m 'rename z to x'
-  $ hg l
-  @  3 rename z to x
-  |  x z
-  o  2 rename y to z
-  |  y 

D6611: blackbox: disable extremely verbose logging (issue6110)

2019-07-10 Thread durin42 (Augie Fackler)
durin42 added inline comments.

INLINE COMMENTS

> blackbox.py:97
>  self._trackedevents = set(ui.configlist('blackbox', 'track'))
> +self._untrackedevents = {'chgserver', 'cmdserver', 'extension'}
>  self._maxfiles = ui.configint('blackbox', 'maxfiles')

Let's make this configurable, and this is the default. Maybe blackbox.ignore, 
with a default of the things you've specified?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6611/new/

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

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


D6588: abort: added support for merge

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15867.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6588?vs=15864&id=15867

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6588/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  mercurial/state.py
  tests/test-commit-unresolved.t
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -718,11 +718,16 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
+
+#if abortflag
+  $ hg unshelve --abort
+  abort: no unshelve in progress
+  [255]
+#else
   $ hg abort
-  abort: no unshelve in progress (abortflag !)
-  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#endif
   $ cd ..
 
 Unshelve respects --keep even if user intervention is needed
diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t
--- a/tests/test-commit-unresolved.t
+++ b/tests/test-commit-unresolved.t
@@ -1,3 +1,11 @@
+#testcases abortcommand abortflag
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = merge --abort
+  > EOF
+#endif
+
   $ addcommit () {
   > echo $1 > $1
   > hg add $1
@@ -36,9 +44,11 @@
 
 Testing the abort functionality first in case of conflicts
 
-  $ hg merge --abort
-  abort: no merge in progress
+  $ hg abort
+  abort: no merge in progress (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
+
   $ hg merge
   merging A
   warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
@@ -53,7 +63,13 @@
   abort: cannot specify both --rev and --abort
   [255]
 
-  $ hg merge --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  merge in progress, will be aborted
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,7 @@
   abort: cannot specify --preview with --abort
   [255]
 
-  $ hg merge --abort
+  $ hg abort
   aborting the merge, updating back to 68352a18a7c4
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -205,13 +205,6 @@
  'To mark the changeset bad: hg bisect --bad\n'
  'To abort:  hg bisect --reset\n')
 )
-addunfinished(
-'merge', fname=None, clearable=True, allowcommit=True,
-cmdmsg=_('outstanding uncommitted merge'),
-statushint=_('To continue:hg commit\n'
- 'To abort:   hg merge --abort'),
-cmdhint=_("use 'hg commit' or 'hg merge --abort'")
-)
 
 def getrepostate(repo):
 # experimental config: commands.status.skipstates
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -956,23 +956,11 @@
   abort=False):
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
-if not abort:
-stats = mergemod.update(repo, node, branchmerge=True, force=force,
-mergeforce=mergeforce, labels=labels)
-else:
-ms = mergemod.mergestate.read(repo)
-if ms.active():
-# there were conflicts
-node = ms.localctx.hex()
-else:
-# there were no conficts, mergestate was not stored
-node = repo['.'].hex()
-
-repo.ui.status(_("aborting the merge, updating back to"
- " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
-
+if abort:
+return abortmerge(repo.ui, repo, labels=labels)
+
+stats = mergemod.update(repo, node, branchmerge=True, force=force,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
@@ -981,6 +969,22 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+ms = mergemod.mergestate.read(repo)
+if ms.active():
+# there were conflicts
+node = ms.localctx.hex()
+else:
+# there were no conficts, mergestate was not stored
+node = repo['.'].hex()
+
+repo.ui.status(_("aborting the merge, updating back to"
+ " %s\n") % node[:12])
+stats = mergemod.update(repo, node, branchmerge=False, force=True,
+labe

D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15866.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6579?vs=15863&id=15866

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.py
  mercurial/state.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -1,4 +1,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
-  $ hg unshelve --abort
+
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  unshelve in progress, will be aborted
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
-  $ hg unshelve --abort
-  abort: no unshelve in progress
+  $ hg abort
+  abort: no unshelve in progress (abortflag !)
+  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,7 @@
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [1]
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 Unshelve without .shelve metadata (can happen when upgrading a repository with 
old shelve)
@@ -843,7 +860,7 @@
   [1]
   $ cat .hg/shelved/default.shelve
   node=82e0cb9893247d12667017593ce1e5655860f1ac
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 #endif
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,10 +194,6 @@
 _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-'unshelve', fname='shelvedstate', continueflag=True,
-cmdmsg=_('unshelve already in progress')
-)
-addunfinished(
 'update', fname='updatestate', clearable=True,
 cmdmsg=_('last update was interrupted'),
 cmdhint=_("use 'hg update' to get a consistent checkout"),
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, opts):
+try:
+state = shelvedstate.load(repo)
+if opts.get('keep') is None:
+opts['keep'] = state.keep
+except IOError as err:
+if err.errno != errno.ENOENT:
+raise
+cmdutil.wrongtooltocontinue(repo, _('unshelve'))
+except error.CorruptedState as err:
+ui.debug(pycompat.bytestr(err) + '\n')
+if opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return state
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui, repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -665,7 +694,6 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-
 def unshelvecontinue(ui, repo, state, opts):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
@@ -

D6636: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 edited the summary of this revision.
taapas1128 updated this revision to Diff 15865.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6636?vs=15856&id=15865

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6636/new/

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -696,8 +696,10 @@
 
 Unshelve --abort works with a corrupted shelvedstate
   $ hg unshelve --abort
-  could not read shelved state file, your working copy may be in an unexpected 
state
+  abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
+  
+  [255]
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -880,12 +880,10 @@
  'operation')
 raise error.Abort(msg, hint=hint)
 elif abortf:
-msg = _('could not read shelved state file, your working copy '
-'may be in an unexpected state\nplease update to some '
-'commit\n')
-ui.warn(msg)
 shelvedstate.clear(repo)
-return
+raise error.Abort(_('could not read shelved state file, your '
+ 'working copy may be in an unexpected state\n'
+ 'please update to some commit\n'))
 
 if abortf:
 return unshelveabort(ui, repo, state, opts)



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


D6588: abort: added support for merge

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15864.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6588?vs=15858&id=15864

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6588/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  mercurial/state.py
  tests/test-commit-unresolved.t
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -718,11 +718,16 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
+
+#if abortflag
+  $ hg unshelve --abort
+  abort: no unshelve in progress
+  [255]
+#else
   $ hg abort
-  abort: no unshelve in progress (abortflag !)
-  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#endif
   $ cd ..
 
 Unshelve respects --keep even if user intervention is needed
diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t
--- a/tests/test-commit-unresolved.t
+++ b/tests/test-commit-unresolved.t
@@ -1,3 +1,11 @@
+#testcases abortcommand abortflag
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = merge --abort
+  > EOF
+#endif
+
   $ addcommit () {
   > echo $1 > $1
   > hg add $1
@@ -36,9 +44,11 @@
 
 Testing the abort functionality first in case of conflicts
 
-  $ hg merge --abort
-  abort: no merge in progress
+  $ hg abort
+  abort: no merge in progress (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
+
   $ hg merge
   merging A
   warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
@@ -53,7 +63,13 @@
   abort: cannot specify both --rev and --abort
   [255]
 
-  $ hg merge --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  merge in progress, will be aborted
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,7 @@
   abort: cannot specify --preview with --abort
   [255]
 
-  $ hg merge --abort
+  $ hg abort
   aborting the merge, updating back to 68352a18a7c4
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -205,13 +205,6 @@
  'To mark the changeset bad: hg bisect --bad\n'
  'To abort:  hg bisect --reset\n')
 )
-addunfinished(
-'merge', fname=None, clearable=True, allowcommit=True,
-cmdmsg=_('outstanding uncommitted merge'),
-statushint=_('To continue:hg commit\n'
- 'To abort:   hg merge --abort'),
-cmdhint=_("use 'hg commit' or 'hg merge --abort'")
-)
 
 def getrepostate(repo):
 # experimental config: commands.status.skipstates
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -956,23 +956,11 @@
   abort=False):
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
-if not abort:
-stats = mergemod.update(repo, node, branchmerge=True, force=force,
-mergeforce=mergeforce, labels=labels)
-else:
-ms = mergemod.mergestate.read(repo)
-if ms.active():
-# there were conflicts
-node = ms.localctx.hex()
-else:
-# there were no conficts, mergestate was not stored
-node = repo['.'].hex()
-
-repo.ui.status(_("aborting the merge, updating back to"
- " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
-
+if abort:
+return abortmerge(repo.ui, repo, labels=labels)
+
+stats = mergemod.update(repo, node, branchmerge=True, force=force,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
@@ -981,6 +969,22 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+ms = mergemod.mergestate.read(repo)
+if ms.active():
+# there were conflicts
+node = ms.localctx.hex()
+else:
+# there were no conficts, mergestate was not stored
+node = repo['.'].hex()
+
+repo.ui.status(_("aborting the merge, updating back to"
+ " %s\n") % node[:12])
+stats = mergemod.update(repo, node, branchmerge=False, force=True,
+labe

D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15863.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6579?vs=15861&id=15863

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.py
  mercurial/state.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -1,4 +1,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
-  $ hg unshelve --abort
+
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  unshelve in progress, will be aborted
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
-  $ hg unshelve --abort
-  abort: no unshelve in progress
+  $ hg abort
+  abort: no unshelve in progress (abortflag !)
+  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,7 @@
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [1]
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 Unshelve without .shelve metadata (can happen when upgrading a repository with 
old shelve)
@@ -843,7 +860,7 @@
   [1]
   $ cat .hg/shelved/default.shelve
   node=82e0cb9893247d12667017593ce1e5655860f1ac
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 #endif
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,10 +194,6 @@
 _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-'unshelve', fname='shelvedstate', continueflag=True,
-cmdmsg=_('unshelve already in progress')
-)
-addunfinished(
 'update', fname='updatestate', clearable=True,
 cmdmsg=_('last update was interrupted'),
 cmdhint=_("use 'hg update' to get a consistent checkout"),
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, opts):
+try:
+state = shelvedstate.load(repo)
+if opts.get('keep') is None:
+opts['keep'] = state.keep
+except IOError as err:
+if err.errno != errno.ENOENT:
+raise
+cmdutil.wrongtooltocontinue(repo, _('unshelve'))
+except error.CorruptedState as err:
+ui.debug(pycompat.bytestr(err) + '\n')
+if opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return state
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui, repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -665,7 +694,6 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-
 def unshelvecontinue(ui, repo, state, opts):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
@@ -

D6637: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

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

REVISION SUMMARY
  This changes the message type of Corruptedstate error in case of `hg unshelve 
--abort`
  to error.Abort from warning message. This is done so as to avoid the return 
statement
  after the warning.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -696,8 +696,10 @@
 
 Unshelve --abort works with a corrupted shelvedstate
   $ hg unshelve --abort
-  could not read shelved state file, your working copy may be in an unexpected 
state
+  abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
+  
+  [255]
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -880,12 +880,10 @@
  'operation')
 raise error.Abort(msg, hint=hint)
 elif abortf:
-msg = _('could not read shelved state file, your working copy '
-'may be in an unexpected state\nplease update to some '
-'commit\n')
-ui.warn(msg)
 shelvedstate.clear(repo)
-return
+raise error.Abort(_('could not read shelved state file, your '
+ 'working copy may be in an unexpected state\n'
+ 'please update to some commit\n'))
 
 if abortf:
 return unshelveabort(ui, repo, state, opts)



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


D6573: prompt: add develwarn about last line of prompt >45 chars (issue6158)

2019-07-10 Thread durin42 (Augie Fackler)
durin42 added a comment.


  Per your note that this will probably make other localizations sad, let's 
just give up on this for now?
  
  Sigh.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6573/new/

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

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


D6625: rust-cargo: reorder dependencies

2019-07-10 Thread durin42 (Augie Fackler)
durin42 added a comment.


  Why? Before it was sorted, and now it's not.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6625/new/

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

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


D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15861.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6579?vs=15860&id=15861

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.py
  mercurial/state.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -1,4 +1,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
-  $ hg unshelve --abort
+
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  unshelve in progress, will be aborted
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
-  $ hg unshelve --abort
-  abort: no unshelve in progress
+  $ hg abort
+  abort: no unshelve in progress (abortflag !)
+  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,7 @@
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [1]
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 Unshelve without .shelve metadata (can happen when upgrading a repository with 
old shelve)
@@ -843,7 +860,7 @@
   [1]
   $ cat .hg/shelved/default.shelve
   node=82e0cb9893247d12667017593ce1e5655860f1ac
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 #endif
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,10 +194,6 @@
 _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-'unshelve', fname='shelvedstate', continueflag=True,
-cmdmsg=_('unshelve already in progress')
-)
-addunfinished(
 'update', fname='updatestate', clearable=True,
 cmdmsg=_('last update was interrupted'),
 cmdhint=_("use 'hg update' to get a consistent checkout"),
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, opts):
+try:
+state = shelvedstate.load(repo)
+if opts.get('keep') is None:
+opts['keep'] = state.keep
+except IOError as err:
+if err.errno != errno.ENOENT:
+raise
+cmdutil.wrongtooltocontinue(repo, _('unshelve'))
+except error.CorruptedState as err:
+ui.debug(pycompat.bytestr(err) + '\n')
+if opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return state
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui, repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -665,7 +694,6 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-
 def unshelvecontinue(ui, repo, state, opts):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
@@ -

D6579: abort: added support for unshelve

2019-07-10 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> shelve.py:648
> +'please update to some commit\n'))
> +return (state, opts)
> +

we can prevent returning opts here. One user does not need it and other one is 
passing by reference.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

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


D6579: abort: added support for unshelve

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


  updated that.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

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


D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 edited the summary of this revision.
taapas1128 updated this revision to Diff 15860.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6579?vs=15859&id=15860

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.py
  mercurial/state.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -1,4 +1,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
-  $ hg unshelve --abort
+
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  unshelve in progress, will be aborted
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
-  $ hg unshelve --abort
-  abort: no unshelve in progress
+  $ hg abort
+  abort: no unshelve in progress (abortflag !)
+  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,7 @@
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [1]
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 Unshelve without .shelve metadata (can happen when upgrading a repository with 
old shelve)
@@ -843,7 +860,7 @@
   [1]
   $ cat .hg/shelved/default.shelve
   node=82e0cb9893247d12667017593ce1e5655860f1ac
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 #endif
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,10 +194,6 @@
 _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-'unshelve', fname='shelvedstate', continueflag=True,
-cmdmsg=_('unshelve already in progress')
-)
-addunfinished(
 'update', fname='updatestate', clearable=True,
 cmdmsg=_('last update was interrupted'),
 cmdhint=_("use 'hg update' to get a consistent checkout"),
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, opts):
+try:
+state = shelvedstate.load(repo)
+if opts.get('keep') is None:
+opts['keep'] = state.keep
+except IOError as err:
+if err.errno != errno.ENOENT:
+raise
+cmdutil.wrongtooltocontinue(repo, _('unshelve'))
+except error.CorruptedState as err:
+ui.debug(pycompat.bytestr(err) + '\n')
+if opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return (state, opts)
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui, repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state, opts = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -864,29 +893,9 @@
 if abortf and opts.get('tool', False):
 ui.warn(_('tool option will be ignored\n'))
 
-try:
-state = shelvedstate.load(repo)
-if opts.get('keep') is None:
-

D6579: abort: added support for unshelve

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


  The commit message is outdated.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

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


D6636: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

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


  > This is fone so as to avoid the return statement
  
  s/fone/done in flight

INLINE COMMENTS

> shelve.py:884
>  shelvedstate.clear(repo)
> -return
> +raise error.Abort(_('could not read shelved state file, your 
> '
> + 'working copy may be in an unexpected 
> state\n'

will fix this indentation in flight.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6636/new/

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

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


D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15859.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6579?vs=15857&id=15859

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.py
  mercurial/state.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -1,4 +1,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
-  $ hg unshelve --abort
+
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  unshelve in progress, will be aborted
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
-  $ hg unshelve --abort
-  abort: no unshelve in progress
+  $ hg abort
+  abort: no unshelve in progress (abortflag !)
+  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,7 @@
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [1]
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 Unshelve without .shelve metadata (can happen when upgrading a repository with 
old shelve)
@@ -843,7 +860,7 @@
   [1]
   $ cat .hg/shelved/default.shelve
   node=82e0cb9893247d12667017593ce1e5655860f1ac
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 #endif
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,10 +194,6 @@
 _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-'unshelve', fname='shelvedstate', continueflag=True,
-cmdmsg=_('unshelve already in progress')
-)
-addunfinished(
 'update', fname='updatestate', clearable=True,
 cmdmsg=_('last update was interrupted'),
 cmdhint=_("use 'hg update' to get a consistent checkout"),
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, opts):
+try:
+state = shelvedstate.load(repo)
+if opts.get('keep') is None:
+opts['keep'] = state.keep
+except IOError as err:
+if err.errno != errno.ENOENT:
+raise
+cmdutil.wrongtooltocontinue(repo, _('unshelve'))
+except error.CorruptedState as err:
+ui.debug(pycompat.bytestr(err) + '\n')
+if opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return (state, opts)
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui,repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state, opts = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -864,29 +893,9 @@
 if abortf and opts.get('tool', False):
 ui.warn(_('tool option will be ignored\n'))
 
-try:
-state = shelvedstate.load(repo)
-if opts.get('keep') is None:
-opts['keep'] = state.keep
-except

D6588: abort: added support for merge

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15858.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6588?vs=15835&id=15858

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6588/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  mercurial/state.py
  tests/test-commit-unresolved.t
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -718,11 +718,16 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
+
+#if abortflag
+  $ hg unshelve --abort
+  abort: no unshelve in progress
+  [255]
+#else
   $ hg abort
-  abort: no unshelve in progress (abortflag !)
-  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#endif
   $ cd ..
 
 Unshelve respects --keep even if user intervention is needed
diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t
--- a/tests/test-commit-unresolved.t
+++ b/tests/test-commit-unresolved.t
@@ -1,3 +1,11 @@
+#testcases abortcommand abortflag
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = merge --abort
+  > EOF
+#endif
+
   $ addcommit () {
   > echo $1 > $1
   > hg add $1
@@ -36,9 +44,11 @@
 
 Testing the abort functionality first in case of conflicts
 
-  $ hg merge --abort
-  abort: no merge in progress
+  $ hg abort
+  abort: no merge in progress (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
+
   $ hg merge
   merging A
   warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
@@ -53,7 +63,13 @@
   abort: cannot specify both --rev and --abort
   [255]
 
-  $ hg merge --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  merge in progress, will be aborted
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,7 @@
   abort: cannot specify --preview with --abort
   [255]
 
-  $ hg merge --abort
+  $ hg abort
   aborting the merge, updating back to 68352a18a7c4
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -205,13 +205,6 @@
  'To mark the changeset bad: hg bisect --bad\n'
  'To abort:  hg bisect --reset\n')
 )
-addunfinished(
-'merge', fname=None, clearable=True, allowcommit=True,
-cmdmsg=_('outstanding uncommitted merge'),
-statushint=_('To continue:hg commit\n'
- 'To abort:   hg merge --abort'),
-cmdhint=_("use 'hg commit' or 'hg merge --abort'")
-)
 
 def getrepostate(repo):
 # experimental config: commands.status.skipstates
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -956,23 +956,11 @@
   abort=False):
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
-if not abort:
-stats = mergemod.update(repo, node, branchmerge=True, force=force,
-mergeforce=mergeforce, labels=labels)
-else:
-ms = mergemod.mergestate.read(repo)
-if ms.active():
-# there were conflicts
-node = ms.localctx.hex()
-else:
-# there were no conficts, mergestate was not stored
-node = repo['.'].hex()
-
-repo.ui.status(_("aborting the merge, updating back to"
- " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
-
+if abort:
+return abortmerge(repo.ui, repo, labels=labels)
+
+stats = mergemod.update(repo, node, branchmerge=True, force=force,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
@@ -981,6 +969,22 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+ms = mergemod.mergestate.read(repo)
+if ms.active():
+# there were conflicts
+node = ms.localctx.hex()
+else:
+# there were no conficts, mergestate was not stored
+node = repo['.'].hex()
+
+repo.ui.status(_("aborting the merge, updating back to"
+ " %s\n") % node[:12])
+stats = mergemod.update(repo, node, branchmerge=False, force=True,
+labe

D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked 5 inline comments as done.
taapas1128 updated this revision to Diff 15857.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6579?vs=15833&id=15857

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.py
  mercurial/state.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -1,4 +1,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
-  $ hg unshelve --abort
+
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  unshelve in progress, will be aborted
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
-  $ hg unshelve --abort
-  abort: no unshelve in progress
+  $ hg abort
+  abort: no unshelve in progress (abortflag !)
+  abort: merge in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,7 @@
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [1]
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 Unshelve without .shelve metadata (can happen when upgrading a repository with 
old shelve)
@@ -843,7 +860,7 @@
   [1]
   $ cat .hg/shelved/default.shelve
   node=82e0cb9893247d12667017593ce1e5655860f1ac
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 #endif
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,10 +194,6 @@
 _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-'unshelve', fname='shelvedstate', continueflag=True,
-cmdmsg=_('unshelve already in progress')
-)
-addunfinished(
 'update', fname='updatestate', clearable=True,
 cmdmsg=_('last update was interrupted'),
 cmdhint=_("use 'hg update' to get a consistent checkout"),
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, opts):
+try:
+state = shelvedstate.load(repo)
+if opts.get('keep') is None:
+opts['keep'] = state.keep
+except IOError as err:
+if err.errno != errno.ENOENT:
+raise
+cmdutil.wrongtooltocontinue(repo, _('unshelve'))
+except error.CorruptedState as err:
+ui.debug(pycompat.bytestr(err) + '\n')
+if opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return (state, opts)
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui,repo):
+"""logic to  abort unshelve using 'hg abort"""
+state, opts = _loadshelvedstate(ui, repo, {'abort' : True})
+with repo.wlock():
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -864,29 +893,9 @@
 if abortf and opts.get('tool', False):
 ui.warn(_('tool option will be ignored\n'))
 
-try:
-state = shelvedstate.load(repo)
-if opts.get('keep') is None:
-

D6636: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

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

REVISION SUMMARY
  This changes the message type of Corruptedstate error in case of `hg unshelve 
--abort`
  to error.Abort from warning message. This is fone so as to avoid the return 
statement
  after the warning.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -696,8 +696,10 @@
 
 Unshelve --abort works with a corrupted shelvedstate
   $ hg unshelve --abort
-  could not read shelved state file, your working copy may be in an unexpected 
state
+  abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
+  
+  [255]
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -880,12 +880,10 @@
  'operation')
 raise error.Abort(msg, hint=hint)
 elif abortf:
-msg = _('could not read shelved state file, your working copy '
-'may be in an unexpected state\nplease update to some '
-'commit\n')
-ui.warn(msg)
 shelvedstate.clear(repo)
-return
+raise error.Abort(_('could not read shelved state file, your '
+ 'working copy may be in an unexpected state\n'
+ 'please update to some commit\n'))
 
 if abortf:
 return unshelveabort(ui, repo, state, opts)



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


[Bug 6170] New: error: pretxnchangegroup.access hook raised an exception: 'derivedrepo:/var/lib/mercurial-server/repos/util

2019-07-10 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6170

Bug ID: 6170
   Summary: error: pretxnchangegroup.access hook raised an
exception:
'derivedrepo:/var/lib/mercurial-server/repos/utilhttps://mercurial-scm.org/wiki/BugTracker
remote: ** Python 2.7.16 (default, Apr  6 2019, 01:42:57) [GCC 8.3.0]
remote: ** Mercurial Distributed SCM (version 4.8.2)
remote: ** Extensions loaded: 
remote: Traceback (most recent call last):
remote:   File "/usr/share/mercurial-server/hg-ssh", line 91, in 
remote: dispatch.dispatch(request(['-R', repo, 'serve', '--stdio']))
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line
220, in dispatch
remote: ret = _runcatch(req) or 0
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line
363, in _runcatch
remote: return _callcatch(ui, _runcatchfunc)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line
371, in _callcatch
remote: return scmutil.callcatch(ui, func)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/scmutil.py", line
166, in callcatch
remote: return func()
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line
354, in _runcatchfunc
remote: return _dispatch(req)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line
994, in _dispatch
remote: cmdpats, cmdoptions)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line
737, in runcommand
remote: ret = _runcommand(ui, options, cmd, d)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line
1003, in _runcommand
remote: return cmdfunc()
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line
991, in 
remote: d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 1646,
in check
remote: return func(*args, **kwargs)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/commands.py", line
5207, in serve
remote: s.serve_forever()
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/wireprotoserver.py",
line 797, in serve_forever
remote: self.serveuntil(threading.Event())
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/wireprotoserver.py",
line 804, in serveuntil
remote: _runsshserver(self._ui, self._repo, self._fin, self._fout, ev)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/wireprotoserver.py",
line 656, in _runsshserver
remote: rsp = wireprotov1server.dispatch(repo, proto, request)
remote:   File
"/usr/lib/python2.7/dist-packages/mercurial/wireprotov1server.py", line 74, in
dispatch
remote: return func(repo, proto, *args)
remote:   File
"/usr/lib/python2.7/dist-packages/mercurial/wireprotov1server.py", line 599, in
unbundle
remote: proto.client())
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/exchange.py", line
2377, in unbundle
remote: op = bundle2.processbundle(repo, cg, op=op)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/bundle2.py", line
460, in processbundle
remote: processparts(repo, op, unbundler)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/bundle2.py", line
467, in processparts
remote: _processpart(op, part)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/bundle2.py", line
534, in _processpart
remote: handler(op, part)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/bundle2.py", line
1829, in handlechangegroup
remote: expectedtotal=nbchangesets, **extrakwargs)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/bundle2.py", line
470, in _processchangegroup
remote: ret = cg.apply(op.repo, tr, source, url, **kwargs)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/changegroup.py",
line 366, in apply
remote: throw=True, **pycompat.strkwargs(hookargs))
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line
1370, in hook
remote: return hook.hook(self.ui, self, name, throw, **args)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/hook.py", line 218,
in hook
remote: res = runhooks(ui, repo, htype, hooks, throw=throw, **args)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/hook.py", line 270,
in runhooksremote: throw)
remote:   File "/usr/lib/python2.7/dist-packages/mercurial/hook.py", line 98,
in pythonhook
remote: r = obj(ui=ui, repo=repo, hooktype=htype,
**pycompat.strkwargs(args))
remote:   File "/usr/share/mercurial-server/mercurialserver/access.py", line
24, in hook
remote: for ctx in changes.changes(repo, node):
remote:   File "/usr/share/mercurial-server/mercurialserver/changes.py", line
6, in changes
remote: start = repo.changectx(node).rev()
remote: AttributeError: 'derivedrepo:/var/lib/mercurial-server/repos/utilhttps://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6588: abort: added support for merge

2019-07-10 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> hg.py:985
> +labels=labels)
> +_showstats(repo, stats)
> +

We lost `return stats.unresolvedcount > 0` in this code movement.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6588/new/

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

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


D6579: abort: added support for unshelve

2019-07-10 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> shelve.py:628
>  
> -def unshelveabort(ui, repo, state, opts):
> +def _loadshelvedstate(ui, repo, continuef=False, abortf=False, **opts):
> +try:

continuef and abortf can be read from opts, no need to pass them separately.

Also, `opts` should be pass as a dictionary here, no need to pass that as 
kwargs.

> shelve.py:648
> +'commit\n')
> +ui.warn(msg)
> +shelvedstate.clear(repo)

I think we can convert this `ui.warn()` to `error.Abort()` and hence get rid of 
`sys.exit()`. Send a standalone patch before this one which make this an error 
instead of warn.

> shelve.py:656
> +if not state:
> +statetuple = _loadshelvedstate(ui, repo, abortf=True)
> +state, opts = statetuple

nit: `state, opts = _loadshelvedstate(ui, repo, {'abort'=True})`

> shelve.py:658
> +state, opts = statetuple
> +with repo.wlock(), repo.lock():
>  try:

let's take `wlock()` only again when if we are processing `hg abort`. We can 
define this function as `unshelveabort(ui, repo, state, abortcommand=False)` 
and pass state as None, and abortcommand as True. When abortcommand is True, 
reassign state to new one and take wlock. Also make sure to release the wlock 
later in case of abortcommand.

> shelve.py:896
>  
> -try:
> -state = shelvedstate.load(repo)
> -if opts.get('keep') is None:
> -opts['keep'] = state.keep
> -except IOError as err:
> -if err.errno != errno.ENOENT:
> -raise
> -cmdutil.wrongtooltocontinue(repo, _('unshelve'))
> -except error.CorruptedState as err:
> -ui.debug(pycompat.bytestr(err) + '\n')
> -if continuef:
> -msg = _('corrupted shelved state file')
> -hint = _('please run hg unshelve --abort to abort unshelve '
> - 'operation')
> -raise error.Abort(msg, hint=hint)
> -elif abortf:
> -msg = _('could not read shelved state file, your working 
> copy '
> -'may be in an unexpected state\nplease update to 
> some '
> -'commit\n')
> -ui.warn(msg)
> -shelvedstate.clear(repo)
> -return
> +statetuple = _loadshelvedstate(ui, repo, continuef=continuef,
> +   abortf=abortf, **opts)

same as a comment above related to directly assigning it to `state, opts`

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6579/new/

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

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


D6613: commit: improve the files field of changelog for merges (RFC)

2019-07-10 Thread mharbison72 (Matt Harbison)
mharbison72 added a comment.
mharbison72 added a subscriber: yuja.


  In D6613#96822 , 
@valentin.gatienbaron wrote:
  
  > Ok. Maybe it would be simpler or more robust to do the direct thing: 
optionally treat the files list in the input commit as input and reuse them 
blindly in the resulting commit, when doing a hg->hg conversion without filemap.
  
  Maybe.  I've been wondering if it's possible to just pass along the manifest 
and changelog instead of recalculating it.  It seems there have been other 
issues over the years[1].  @yuja fixed something manifest related around the 
time of that thread IIRC.  Even if a filemap is in use, the map may not modify 
early commits.  And when those are changed unexpectedly, it makes me wonder 
what got lost/mangled.  I looked through the repos I converted last year 
without any file mapping, and there were manifest node changes, but also 
differences in `files` and `files+` in the changelog.
  
  > (btw, a tweak to test-merge-combinations shows the cases where convert is 
not the identity: 12-- and -1--, so cases where a file is absent in p1, that p2 
added or modified, and the merge redeletes the file. Commit shows such files 
are modified (rightly) but convert doesn't)
  
  Is that a non-tracked test?  Can you throw a patch up somewhere showing this? 
 One of the things I noticed last year was that I'd get better results if 
`cleanp2`[2] was forced to be empty.  I was unable to come up with a simple 
test case showing a different hash with shipping code and a forcibly emptied 
`cleanp2`, circa 4.6.  What you're describing seems to be the opposite of 
216fa1ba9993 
, 
but something is wrong with that calculation, so maybe it's worth a try.
  
  [1] https://www.mercurial-scm.org/pipermail/mercurial/2018-June/050921.html
  [2] https://www.mercurial-scm.org/repo/hg/file/5.0.2/hgext/convert/hg.py#l552

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6613/new/

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

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


D6623: py3: store _origdoc as str

2019-07-10 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 15855.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6623?vs=15827&id=15855

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6623/new/

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

AFFECTED FILES
  hgext/show.py
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -64,8 +64,8 @@
 raise error.ProgrammingError(msg)
 
 if func.__doc__ and not util.safehasattr(func, '_origdoc'):
-doc = pycompat.sysbytes(func.__doc__).strip()
-func._origdoc = doc
+func._origdoc = func.__doc__.strip()
+doc = pycompat.sysbytes(func._origdoc)
 func.__doc__ = pycompat.sysstr(self._formatdoc(decl, doc))
 
 self._table[name] = func
diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -460,8 +460,8 @@
 longest = max(map(len, showview._table.keys()))
 entries = []
 for key in sorted(showview._table.keys()):
-entries.append(pycompat.sysstr('%s   %s' % (
-key.ljust(longest), showview._table[key]._origdoc)))
+entries.append(r'%s   %s' % (
+pycompat.sysstr(key.ljust(longest)), 
showview._table[key]._origdoc))
 
 cmdtable['show'][0].__doc__ = pycompat.sysstr('%s\n\n%s\n') % (
 cmdtable['show'][0].__doc__.rstrip(),



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


D6623: py3: store _origdoc as str

2019-07-10 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> show.py:463
>  for key in sorted(showview._table.keys()):
> -entries.append(pycompat.sysstr('%s   %s' % (
> -key.ljust(longest), showview._table[key]._origdoc)))
> +entries.append(pycompat.sysstr('%s   %s') % (
> +pycompat.sysstr(key.ljust(longest)), 
> showview._table[key]._origdoc))

Hmm, I guess I should have just used r'' here. I'll update that.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6623/new/

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

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


D6594: RFC dirstatemap

2019-07-10 Thread Raphaël Gomès
Alphare added a comment.


  I have updated and split this RFC into a new series 
(https://phab.mercurial-scm.org/D6625, see the Stack tab). 
  This differential can be considered outdated.
  
  @kevincox: I will try my best to take into account the comments you've 
already left here after the new series was published.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6594/new/

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

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


D6635: rust-utils: add docstrings and doctests for utils.rs

2019-07-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  rust/hg-core/src/lib.rs
  rust/hg-core/src/utils.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/utils.rs b/rust/hg-core/src/utils.rs
--- a/rust/hg-core/src/utils.rs
+++ b/rust/hg-core/src/utils.rs
@@ -1,10 +1,25 @@
 pub mod files;
 
+/// Replaces the `from` slice with the `to` slice inside the `buf` slice.
+///
+/// # Examples
+///
+/// ```
+/// use crate::hg::utils::replace_slice;
+/// let mut line = b"I hate writing tests!".to_vec();
+/// replace_slice(&mut line, b"hate", b"love");
+/// assert_eq!(
+/// line,
+/// b"I love writing tests!".to_vec()
+///);
+///
+/// ```
 pub fn replace_slice(buf: &mut [T], from: &[T], to: &[T])
 where
 T: Clone + PartialEq,
 {
-if buf.len() < from.len() || from.len() != to.len() {
+assert_eq!(from.len(), to.len());
+if buf.len() < from.len() {
 return;
 }
 for i in 0..=buf.len() - from.len() {
@@ -15,8 +30,9 @@
 }
 
 pub trait SliceExt {
+fn trim_end(&self) -> &Self;
+fn trim_start(&self) -> &Self;
 fn trim(&self) -> &Self;
-fn trim_end(&self) -> &Self;
 }
 
 fn is_not_whitespace(c: &u8) -> bool {
@@ -24,17 +40,6 @@
 }
 
 impl SliceExt for [u8] {
-fn trim(&self) -> &[u8] {
-if let Some(first) = self.iter().position(is_not_whitespace) {
-if let Some(last) = self.iter().rposition(is_not_whitespace) {
-&self[first..last + 1]
-} else {
-unreachable!();
-}
-} else {
-&[]
-}
-}
 fn trim_end(&self) -> &[u8] {
 if let Some(last) = self.iter().rposition(is_not_whitespace) {
 &self[..last + 1]
@@ -42,4 +47,30 @@
 &[]
 }
 }
+fn trim_start(&self) -> &[u8] {
+if let Some(first) = self.iter().position(is_not_whitespace) {
+&self[first..]
+} else {
+&[]
+}
+}
+
+/// ```
+/// use hg::utils::SliceExt;
+/// assert_eq!(
+/// b"  to trim  ".trim(),
+/// b"to trim"
+/// );
+/// assert_eq!(
+/// b"to trim  ".trim(),
+/// b"to trim"
+/// );
+/// assert_eq!(
+/// b"  to trim".trim(),
+/// b"to trim"
+/// );
+/// ```
+fn trim(&self) -> &[u8] {
+self.trim_start().trim_end()
+}
 }
diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -15,7 +15,7 @@
 DirstateVec,
 };
 mod filepatterns;
-mod utils;
+pub mod utils;
 
 pub use filepatterns::{
 build_single_regex, read_pattern_file, PatternSyntax, PatternTuple,



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


D6594: RFC dirstatemap

2019-07-10 Thread kevincox (Kevin Cox)
kevincox added a comment.


  In D6594#96518 , @yuja wrote:
  
  > Yes, so we'll probably want to minimize the data exchanged between Rust
  > and Python. This means we'll eventually move more logic to Rust side, which
  > hopefully reduce the number of elements to be exposed through the iterator
  > interface. Until then, it might be better to move iterator-heavy objects
  > to CPython/PyO3 layer. Just my guess.
  
  This is likely true. But I suspect we don't need to worry too much unless 
performance is shown to be an issue. Then it makes sense to make 
spot-optimizations.
  
  Especially if there are plans to move more code into Rust over time it will 
be very easy to spend a lot of time optimizing the interface only to find that 
the interface has moved a layer up in 4 months.

INLINE COMMENTS

> dirstate_map.rs:275
> +let parents;
> +if file_contents.len() == 40 {
> +parents = DirstateParents {

Give this magic number a name?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6594/new/

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

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


D6593: rust-minor-fixes: remove Deref in favor of explicit methods

2019-07-10 Thread kevincox (Kevin Cox)
kevincox added inline comments.

INLINE COMMENTS

> dirs_multiset.rs:131
> +
> +pub fn iter(&self) -> Iter, u32> {
> +self.inner.iter()

Returning a `std::collections::hash_map::Iter` binds you to this 
implementation. I would recommend instead returning `impl Iterator`.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6593/new/

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

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


D6597: rust-2018: switch hg-core and hg-cpython to rust 2018 edition

2019-07-10 Thread Raphaël Gomès
Alphare edited the summary of this revision.
Alphare updated this revision to Diff 15853.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6597?vs=15741&id=15853

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6597/new/

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

AFFECTED FILES
  rust/hg-core/Cargo.toml
  rust/hg-core/src/dirstate.rs
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-core/src/dirstate/mod.rs
  rust/hg-core/src/dirstate/parsers.rs
  rust/hg-core/src/filepatterns.rs
  rust/hg-core/src/lib.rs
  rust/hg-core/src/utils.rs
  rust/hg-core/src/utils/mod.rs
  rust/hg-core/tests/test_missing_ancestors.rs
  rust/hg-cpython/Cargo.toml
  rust/hg-cpython/src/ancestors.rs
  rust/hg-cpython/src/cindex.rs
  rust/hg-cpython/src/dagops.rs
  rust/hg-cpython/src/dirstate.rs
  rust/hg-cpython/src/discovery.rs
  rust/hg-cpython/src/exceptions.rs
  rust/hg-cpython/src/filepatterns.rs
  rust/hg-cpython/src/lib.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/lib.rs b/rust/hg-cpython/src/lib.rs
--- a/rust/hg-cpython/src/lib.rs
+++ b/rust/hg-cpython/src/lib.rs
@@ -19,10 +19,10 @@
 //! 'Generic DAG ancestor algorithms - Rust implementation'
 //! ```
 
+/// This crate uses nested private macros, `extern crate` is still needed in
+/// 2018 edition.
 #[macro_use]
 extern crate cpython;
-extern crate hg;
-extern crate libc;
 
 pub mod ancestors;
 mod cindex;
diff --git a/rust/hg-cpython/src/filepatterns.rs 
b/rust/hg-cpython/src/filepatterns.rs
--- a/rust/hg-cpython/src/filepatterns.rs
+++ b/rust/hg-cpython/src/filepatterns.rs
@@ -10,10 +10,10 @@
 //! `hg-core` crate. From Python, this will be seen as `rustext.filepatterns`
 //! and can be used as replacement for the the pure `filepatterns` Python 
module.
 //!
+use crate::exceptions::{PatternError, PatternFileError};
 use cpython::{
 PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject,
 };
-use exceptions::{PatternError, PatternFileError};
 use hg::{build_single_regex, read_pattern_file, LineNumber, PatternTuple};
 
 /// Rust does not like functions with different return signatures.
diff --git a/rust/hg-cpython/src/exceptions.rs 
b/rust/hg-cpython/src/exceptions.rs
--- a/rust/hg-cpython/src/exceptions.rs
+++ b/rust/hg-cpython/src/exceptions.rs
@@ -12,8 +12,10 @@
 //! existing Python exceptions if appropriate.
 //!
 //! [`GraphError`]: struct.GraphError.html
-use cpython::exc::{RuntimeError, ValueError};
-use cpython::{exc, PyErr, Python};
+use cpython::{
+exc::{IOError, RuntimeError, ValueError},
+py_exception, PyErr, Python,
+};
 use hg;
 
 py_exception!(rustext, GraphError, ValueError);
@@ -55,7 +57,7 @@
 match inner {
 hg::PatternFileError::IO(e) => {
 let value = (e.raw_os_error().unwrap_or(2), e.to_string());
-PyErr::new::(py, value)
+PyErr::new::(py, value)
 }
 hg::PatternFileError::Pattern(e, l) => match e {
 hg::PatternError::UnsupportedSyntax(m) => {
diff --git a/rust/hg-cpython/src/discovery.rs b/rust/hg-cpython/src/discovery.rs
--- a/rust/hg-cpython/src/discovery.rs
+++ b/rust/hg-cpython/src/discovery.rs
@@ -12,13 +12,15 @@
 //! - [`PartialDiscover`] is the Rust implementation of
 //!   `mercurial.setdiscovery.partialdiscovery`.
 
-use crate::conversion::{py_set, rev_pyiter_collect};
-use cindex::Index;
+use crate::{
+cindex::Index,
+conversion::{py_set, rev_pyiter_collect},
+exceptions::GraphError,
+};
 use cpython::{
 ObjectProtocol, PyDict, PyModule, PyObject, PyResult, Python,
 PythonObject, ToPyObject,
 };
-use exceptions::GraphError;
 use hg::discovery::PartialDiscovery as CorePartialDiscovery;
 use hg::Revision;
 
diff --git a/rust/hg-cpython/src/dirstate.rs b/rust/hg-cpython/src/dirstate.rs
--- a/rust/hg-cpython/src/dirstate.rs
+++ b/rust/hg-cpython/src/dirstate.rs
@@ -19,17 +19,14 @@
 DirstateEntry, DirstateMapError, DirstatePackError, DirstateParents,
 DirstateParseError, DirstateVec,
 };
+use libc::{c_char, c_int};
+#[cfg(feature = "python27")]
+use python27_sys::PyCapsule_Import;
+#[cfg(feature = "python3")]
+use python3_sys::PyCapsule_Import;
+use std::cell::RefCell;
 use std::collections::HashMap;
 use std::ffi::CStr;
-
-#[cfg(feature = "python27")]
-extern crate python27_sys as python_sys;
-#[cfg(feature = "python3")]
-extern crate python3_sys as python_sys;
-
-use self::python_sys::PyCapsule_Import;
-use libc::{c_char, c_int};
-use std::cell::RefCell;
 use std::mem::transmute;
 
 /// C code uses a custom `dirstate_tuple` type, checks in multiple instances
diff --git a/rust/hg-cpython/src/dagops.rs b/rust/hg-cpython/src/dagops.rs
--- a/rust/hg-cpython/src/dagops.rs
+++ b/rust/hg-cpython/src/dagops.rs
@@ -9,10 +9,12 @@
 //! `hg-core` package.
 //!
 //! From Python, this will be seen as `mercurial.rustext.dagop`
-use crate::conversion::{py_set, rev_pyiter_collect};
-use cindex::Index;
+use crate::{
+ci

D6597: rust-2018: switch hg-core and hg-cpython to rust 2018 edition

2019-07-10 Thread Raphaël Gomès
Alphare added inline comments.

INLINE COMMENTS

> kevincox wrote in utils.rs:3
> This could really use a doc comment.

I'll address those points in a separate (parent) changeset.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6597/new/

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

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


D6597: rust-2018: switch hg-core and hg-cpython to rust 2018 edition

2019-07-10 Thread Raphaël Gomès
Alphare added a comment.


  In D6597#96317 , @pulkit wrote:
  
  > Can you add link of mailing list thread in your commit message? Link from 
markmail or https://www.mercurial-scm.org/pipermail/mercurial-devel/.
  
  Sure, will amend.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6597/new/

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

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


D6597: rust-2018: switch hg-core and hg-cpython to rust 2018 edition

2019-07-10 Thread Raphaël Gomès
Alphare added a comment.


  In D6597#96881 , @kevincox wrote:
  
  > Is the SliceExt change related to the 2018 change? If not could you split 
the two?
  
  It is indeed related to 2018: `mod.rs` files are not needed anymore and this 
makes it both simpler in terms of file structure, but also for development, as 
having 5 `mod.rs` files open is not fun.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6597/new/

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

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


D6597: rust-2018: switch hg-core and hg-cpython to rust 2018 edition

2019-07-10 Thread kevincox (Kevin Cox)
kevincox added a comment.
kevincox accepted this revision.


  Is the SliceExt change related to the 2018 change? If not could you split the 
two?

INLINE COMMENTS

> utils.rs:3
> +
> +pub fn replace_slice(buf: &mut [T], from: &[T], to: &[T])
> +where

This could really use a doc comment.

> utils.rs:7
> +{
> +if buf.len() < from.len() || from.len() != to.len() {
> +return;

from.len() != to.len() sounds like a bug and I would probably use an 
`assert!()`. Unless this is expected to be common and "okay".

> utils.rs:12
> +if buf[i..].starts_with(from) {
> +buf[i..(i + from.len())].clone_from_slice(to);
> +}

This allows overlapping replacements. I don't know if this is intended.

> utils.rs:38
> +}
> +fn trim_end(&self) -> &[u8] {
> +if let Some(last) = self.iter().rposition(is_not_whitespace) {

Why not define `trim` as `self.trim_start().trim_end()`?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6597/new/

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

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


Re: [PATCH 1 of 2] rust-dirstate: add helper to iterate ancestor paths

2019-07-10 Thread Martin von Zweigbergk via Mercurial-devel
On Sun, Jun 30, 2019, 04:17 Yuya Nishihara  wrote:

> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1561887163 -32400
> #  Sun Jun 30 18:32:43 2019 +0900
> # Node ID 72ab74c704053b2212b874a902574fedadad4252
> # Parent  904e0da2e195d2a29977ceccdd25480233c34d7a
> rust-dirstate: add helper to iterate ancestor paths
>
> This is modeled after std::path::Path::ancestors().
>
> find_dirs(b"") yields b"" because Mercurial's util.finddirs() works in that
> way, and the test case for DirsMultiset expects such behavior.
>

That's also how std::path::Path::ancestors() works, it seems.


> diff --git a/rust/hg-core/src/utils/files.rs b/rust/hg-core/src/utils/
> files.rs
> --- a/rust/hg-core/src/utils/files.rs
> +++ b/rust/hg-core/src/utils/files.rs
> @@ -1,3 +1,4 @@
> +use std::iter::FusedIterator;
>  use std::path::Path;
>
>  pub fn get_path_from_bytes(bytes: &[u8]) -> &Path {
> @@ -17,3 +18,66 @@ pub fn get_path_from_bytes(bytes: &[u8])
>
>  Path::new(os_str)
>  }
> +
> +/// An iterator over repository path yielding itself and its ancestors.
> +#[derive(Copy, Clone, Debug)]
> +pub struct Ancestors<'a> {
> +next: Option<&'a [u8]>,
> +}
> +
> +impl<'a> Iterator for Ancestors<'a> {
> +// if we had an HgPath type, this would yield &'a HgPath
> +type Item = &'a [u8];
> +
> +fn next(&mut self) -> Option {
> +let next = self.next;
> +self.next = match self.next {
> +Some(s) if s.is_empty() => None,
> +Some(s) => {
> +let p = s.iter().rposition(|&c| c == b'/').unwrap_or(0);
> +Some(&s[..p])
> +}
> +None => None,
> +};
> +next
> +}
> +}
> +
> +impl<'a> FusedIterator for Ancestors<'a> {}
> +
> +/// Returns an iterator yielding ancestor directories of the given
> repository
> +/// path.
> +///
> +/// The path is separated by '/', and must not start with '/'.
> +///
> +/// The path itself isn't included unless it is b"" (meaning the root
> +/// directory.)
> +pub fn find_dirs<'a>(path: &'a [u8]) -> Ancestors<'a> {
> +let mut dirs = Ancestors { next: Some(path) };
> +if !path.is_empty() {
> +dirs.next(); // skip itself
> +}
> +dirs
> +}
> +
> +#[cfg(test)]
> +mod tests {
> +#[test]
> +fn find_dirs_some() {
> +let mut dirs = super::find_dirs(b"foo/bar/baz");
> +assert_eq!(dirs.next(), Some(b"foo/bar".as_ref()));
> +assert_eq!(dirs.next(), Some(b"foo".as_ref()));
> +assert_eq!(dirs.next(), Some(b"".as_ref()));
> +assert_eq!(dirs.next(), None);
> +assert_eq!(dirs.next(), None);
> +}
> +
> +#[test]
> +fn find_dirs_empty() {
> +// looks weird, but mercurial.util.finddirs(b"") yields b""
> +let mut dirs = super::find_dirs(b"");
> +assert_eq!(dirs.next(), Some(b"".as_ref()));
> +assert_eq!(dirs.next(), None);
> +assert_eq!(dirs.next(), None);
> +}
> +}
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6634: rust-dirstate: call rust dirstatemap from Python

2019-07-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Since Rust-backed Python classes cannot be used as baseclasses (for
  rust-cpython anyway), we use composition rather than inheritance.
  
  This also allows us to keep the IO operations in the Python side, removing
  (for now) the need to rewrite VFS in Rust, which would be a heavy undertaking.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -27,14 +27,14 @@
 util,
 )
 
-orig_parsers = policy.importmod(r'parsers')
-parsers = policy.importrust(r'parsers', default=orig_parsers)
+parsers = policy.importmod(r'parsers')
+rustmod = policy.importrust(r'dirstate')
 
 propertycache = util.propertycache
 filecache = scmutil.filecache
 _rangemask = 0x7fff
 
-dirstatetuple = orig_parsers.dirstatetuple
+dirstatetuple = parsers.dirstatetuple
 
 class repocache(filecache):
 """filecache for files in .hg/"""
@@ -652,7 +652,8 @@
 delaywrite = self._ui.configint('debug', 'dirstate.delaywrite')
 if delaywrite > 0:
 # do we have any files to delay for?
-for f, e in self._map.iteritems():
+items = self._map.iteritems()
+for f, e in items:
 if e[0] == 'n' and e[3] == now:
 import time # to avoid useless import
 # rather than sleep n seconds, sleep until the next
@@ -663,6 +664,12 @@
 time.sleep(end - clock)
 now = end # trust our estimate that the end is near now
 break
+# since the iterator is potentially not depleted,
+# delete the iterator to release the reference for the Rust
+# implementation.
+# TODO make the Rust implementation behave like Python
+# since this would not work with a non ref-counting GC.
+del items
 
 self._map.write(st, now)
 self._lastnormaltime = 0
@@ -1516,3 +1523,187 @@
 for name in self._dirs:
 f[normcase(name)] = name
 return f
+
+
+if rustmod is not None:
+class dirstatemap(object):
+def __init__(self, ui, opener, root):
+self._ui = ui
+self._opener = opener
+self._root = root
+self._filename = 'dirstate'
+self._parents = None
+self._dirtyparents = False
+
+# for consistent view between _pl() and _read() invocations
+self._pendingmode = None
+
+
+def addfile(self, *args, **kwargs):
+return self._rustmap.addfile(*args, **kwargs)
+
+def removefile(self, *args, **kwargs):
+return self._rustmap.removefile(*args, **kwargs)
+
+def dropfile(self, *args, **kwargs):
+return self._rustmap.dropfile(*args, **kwargs)
+
+def clearambiguoustimes(self, *args, **kwargs):
+return self._rustmap.clearambiguoustimes(*args, **kwargs)
+
+def nonnormalentries(self):
+return self._rustmap.nonnormalentries()
+
+def get(self, *args, **kwargs):
+return self._rustmap.get(*args, **kwargs)
+
+@propertycache
+def _rustmap(self):
+self._rustmap = rustmod.DirstateMap(self._root)
+self.read()
+return self._rustmap
+
+@property
+def copymap(self):
+return self._rustmap.copymap()
+
+def preload(self):
+self._rustmap
+
+def clear(self):
+self._rustmap.clear()
+self.setparents(nullid, nullid)
+util.clearcachedproperty(self, "_dirs")
+util.clearcachedproperty(self, "_alldirs")
+util.clearcachedproperty(self, "dirfoldmap")
+
+def items(self):
+return self._rustmap.items()
+
+def keys(self):
+return iter(self._rustmap)
+
+def __contains__(self, key):
+return key in self._rustmap
+
+def __getitem__(self, item):
+return self._rustmap[item]
+
+def __len__(self):
+return len(self._rustmap)
+
+def __iter__(self):
+return iter(self._rustmap)
+
+# forward for python2,3 compat
+iteritems = items
+
+def _opendirstatefile(self):
+fp, mode = txnutil.trypending(self._root, self._opener,
+  self._filename)
+if self._pendingmode is not None and self._pendingmode != mode:
+fp.close()
+raise error.Abort(_('working directory state may be '
+'changed parallelly'))
+self._pendingmode = mode
+return fp
+

D6633: rust-dirstate: rust-cpython bridge for dirstatemap

2019-07-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This change also showcases the limitations of the `py_shared_ref!` macro.
  
  See the previous commit 'rust-dirstate: rust implementation of dirstatemap`
  for an explanation for the TODOs in the code.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  rust/hg-cpython/src/dirstate/copymap.rs
  rust/hg-cpython/src/dirstate/dirstate_map.rs
  rust/hg-cpython/src/dirstate/mod.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/mod.rs 
b/rust/hg-cpython/src/dirstate/mod.rs
--- a/rust/hg-cpython/src/dirstate/mod.rs
+++ b/rust/hg-cpython/src/dirstate/mod.rs
@@ -26,10 +26,13 @@
 use libc::{c_char, c_int};
 use std::mem::transmute;
 
+mod copymap;
 mod dirs_multiset;
+mod dirstate_map;
 use dirstate::dirs_multiset::Dirs;
+use dirstate::dirstate_map::DirstateMap;
+use exceptions::AlreadyBorrowed;
 use std::convert::TryFrom;
-use exceptions::AlreadyBorrowed;
 
 /// C code uses a custom `dirstate_tuple` type, checks in multiple instances
 /// for this type, and raises a Python `Exception` if the check does not pass.
@@ -100,6 +103,7 @@
 m.add(py, "__doc__", "Dirstate - Rust implementation")?;
 
 m.add_class::(py)?;
+m.add_class::(py)?;
 m.add(py, "AlreadyBorrowed", py.get_type::())?;
 
 let sys = PyModule::import(py, "sys")?;
diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs 
b/rust/hg-cpython/src/dirstate/dirstate_map.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -0,0 +1,505 @@
+// dirstate_map.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Bindings for the `hg::dirstate::dirstate_map` file provided by the
+//! `hg-core` package.
+
+use std::cell::{RefCell, RefMut};
+use std::collections::hash_map::Iter;
+use std::convert::TryInto;
+use std::time::Duration;
+
+use cpython::{
+exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyObject,
+PyResult, PyTuple, Python, PythonObject, ToPyObject,
+};
+use libc::c_char;
+
+use dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator};
+use dirstate::decapsule_make_dirstate_tuple;
+use dirstate::dirs_multiset::Dirs;
+use exceptions::AlreadyBorrowed;
+use hg::{
+DirsIterable, DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap,
+DirstateParents, DirstateParseError, EntryState,
+};
+
+/// TODO
+/// This object needs to share references to multiple members of its Rust
+/// inner struct, namely `copy_map`, `dirs` and `all_dirs`.
+/// Right now `CopyMap` is done, but it needs to have an explicit reference
+/// to `RustDirstateMap` which itself needs to have an encapsulation for
+/// every method in `CopyMap` (copymapcopy, etc.).
+/// This is ugly and hard to maintain.
+/// The same logic applies to `dirs` and `all_dirs`, however the `Dirs`
+/// `py_class!` is already implemented and does not mention
+/// `RustDirstateMap`, rightfully so.
+/// All attributes also have to have a separate refcount data attribute for
+/// leaks, with all methods that go along for reference sharing.
+py_class!(pub class DirstateMap |py| {
+data inner: RefCell;
+data leak_count: RefCell;
+
+def __new__(_cls, _root: PyObject) -> PyResult {
+let inner = RustDirstateMap::default();
+Self::create_instance(py, RefCell::new(inner), RefCell::new(0))
+}
+
+def clear(&self) -> PyResult {
+self.borrow_mut(py)?.clear();
+Ok(py.None())
+}
+
+def get(
+&self,
+key: PyObject,
+default: Option = None
+) -> PyResult> {
+let key = key.extract::(py)?;
+match self.inner(py).borrow().get(key.data(py)) {
+Some(entry) => {
+// Explicitly go through u8 first, then cast to
+// platform-specific `c_char`.
+let state: u8 = entry.state.into();
+Ok(Some(decapsule_make_dirstate_tuple(py)?(
+state as c_char,
+entry.mode,
+entry.size,
+entry.mtime,
+)))
+},
+None => Ok(default)
+}
+}
+
+def addfile(
+&self,
+f: PyObject,
+oldstate: PyObject,
+state: PyObject,
+mode: PyObject,
+size: PyObject,
+mtime: PyObject
+) -> PyResult {
+self.borrow_mut(py)?.add_file(
+f.extract::(py)?.data(py),
+oldstate.extract::(py)?.data(py)[0]
+.try_into()
+.map_err(|e: DirstateParseError| {
+PyErr::new::(py, e.to_string())
+})?,
+DirstateEntry

D6632: rust-dirstate: rust implementation of dirstatemap

2019-07-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The `dirstatemap` is one of the last building blocks needed to get to a
  `dirstate.walk` Rust implementation.
  
  Disclaimer: This change is part of a big (10) series of patches, all of which
  started as one big changeset that took a long time to write.
  This `dirstatemap` implementation is a compromise in terms of complexity both
  for me and for the reviewers. I chose to submit this patch right now because
  while it is not perfect, it works and is simple enough (IMHO) to be reviewed.
  
  The Python implementation uses a lot of lazy propertycaches, breaks
  encapsulation and is used as an iterator in a lot of places, all of which
  dictated the somewhat unidiomatic patterns in this change.
  Like written in the comments, rewriting this struct to use the typestate
  pattern might be a good idea, but this is a good first step.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-core/src/dirstate/mod.rs
  rust/hg-core/src/lib.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -18,6 +18,7 @@
 pub mod testing; // unconditionally built, for use from integration tests
 pub use dirstate::{
 dirs_multiset::DirsMultiset,
+dirstate_map::DirstateMap,
 parsers::{pack_dirstate, parse_dirstate},
 CopyMap, DirsIterable, DirstateEntry, DirstateParents, EntryState,
 StateMap,
diff --git a/rust/hg-core/src/dirstate/mod.rs b/rust/hg-core/src/dirstate/mod.rs
--- a/rust/hg-core/src/dirstate/mod.rs
+++ b/rust/hg-core/src/dirstate/mod.rs
@@ -10,6 +10,7 @@
 use DirstateParseError;
 
 pub mod dirs_multiset;
+pub mod dirstate_map;
 pub mod parsers;
 
 #[derive(Debug, PartialEq, Clone)]
diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -0,0 +1,431 @@
+// dirstate_map.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+use core::borrow::Borrow;
+use dirstate::parsers::PARENT_SIZE;
+use dirstate::EntryState;
+use std::collections::{HashMap, HashSet};
+use std::iter::FromIterator;
+use std::ops::Deref;
+use std::time::Duration;
+use {
+pack_dirstate, parse_dirstate, CopyMap, DirsIterable, DirsMultiset,
+DirstateEntry, DirstateError, DirstateMapError, DirstateParents,
+DirstateParseError, StateMap,
+};
+
+pub type FileFoldMap = HashMap, Vec>;
+
+const NULL_REVISION: &[u8] = b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+const MTIME_UNSET: i32 = -1;
+const SIZE_DIRTY: i32 = -2;
+
+#[derive(Default)]
+pub struct DirstateMap {
+state_map: StateMap,
+pub copy_map: CopyMap,
+file_fold_map: Option,
+pub dirs: Option,
+pub all_dirs: Option,
+non_normal_set: HashSet>,
+other_parent_set: HashSet>,
+parents: Option,
+dirty_parents: bool,
+}
+
+/// Should only really be used in python interface code, for clarity
+impl Deref for DirstateMap {
+type Target = StateMap;
+
+fn deref(&self) -> &Self::Target {
+&self.state_map
+}
+}
+
+impl FromIterator<(Vec, DirstateEntry)> for DirstateMap {
+fn from_iter, DirstateEntry)>>(
+iter: I,
+) -> Self {
+Self {
+state_map: iter.into_iter().collect(),
+..Self::default()
+}
+}
+}
+
+impl DirstateMap {
+pub fn new() -> Self {
+Self::default()
+}
+
+pub fn clear(&mut self) {
+self.state_map.clear();
+self.copy_map.clear();
+self.file_fold_map = None;
+self.non_normal_set.clear();
+self.other_parent_set.clear();
+self.set_parents(DirstateParents {
+p1: NULL_REVISION.to_vec(),
+p2: NULL_REVISION.to_vec(),
+})
+}
+
+/// Add a tracked file to the dirstate
+pub fn add_file(
+&mut self,
+filename: &[u8],
+old_state: EntryState,
+entry: DirstateEntry,
+) {
+if old_state == EntryState::Unknown || old_state == EntryState::Removed
+{
+if let Some(ref mut dirs) = self.dirs {
+dirs.add_path(filename)
+}
+}
+if old_state == EntryState::Unknown {
+if let Some(ref mut all_dirs) = self.all_dirs {
+all_dirs.add_path(filename)
+}
+}
+self.state_map.insert(filename.to_owned(), entry.to_owned());
+
+if entry.state != EntryState::Normal || entry.mtime == MTIME_UNSET {
+self.non_normal_set.insert(filename.to_owned());
+}
+
+if entry.size == SIZE_DIRTY {
+self.

Re: [PATCH 1 of 2] rust-dirstate: add helper to iterate ancestor paths

2019-07-10 Thread Pulkit Goyal
On Sun, Jun 30, 2019 at 2:16 PM Yuya Nishihara  wrote:

> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1561887163 -32400
> #  Sun Jun 30 18:32:43 2019 +0900
> # Node ID 72ab74c704053b2212b874a902574fedadad4252
> # Parent  904e0da2e195d2a29977ceccdd25480233c34d7a
> rust-dirstate: add helper to iterate ancestor paths
>
> This is modeled after std::path::Path::ancestors().
>
> find_dirs(b"") yields b"" because Mercurial's util.finddirs() works in that
> way, and the test case for DirsMultiset expects such behavior.
>

Queued this one, many thanks. The next one fails to apply on tip of default.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6566: abort: added logic for of hg abort

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGbb135a784b70: abort: added logic for of hg abort (authored 
by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6566?vs=15836&id=15845

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6566/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/state.py
  tests/test-blackbox.t
  tests/test-completion.t
  tests/test-help.t
  tests/test-hgweb-json.t

CHANGE DETAILS

diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -1875,6 +1875,10 @@
   {
 "earlycommands": [
   {
+"summary": "abort an unfinished operation (EXPERIMENTAL)",
+"topic": "abort"
+  },
+  {
 "summary": "add the specified files on the next commit",
 "topic": "add"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -402,6 +402,7 @@
   
   basic commands:
   
+   abort abort an unfinished operation (EXPERIMENTAL)
add   add the specified files on the next commit
annotate, blame
  show changeset information by line for each file
@@ -2353,6 +2354,13 @@
   Main 
Commands
   
   
+  
+  abort
+  
+  
+  abort an unfinished operation (EXPERIMENTAL)
+  
+  
   
   add
   
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -1,5 +1,6 @@
 Show all commands except debug commands
   $ hg debugcomplete
+  abort
   add
   addremove
   annotate
@@ -59,6 +60,7 @@
 
 Show all commands that start with "a"
   $ hg debugcomplete a
+  abort
   add
   addremove
   annotate
@@ -235,6 +237,7 @@
 
 Show all commands + options
   $ hg debugcommands
+  abort: dry-run
   add: include, exclude, subrepos, dry-run
   addremove: similarity, subrepos, include, exclude, dry-run
   annotate: rev, follow, no-follow, text, user, file, date, number, changeset, 
line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, include, exclude, template
diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -7,7 +7,7 @@
   > @command(b'crash', [], b'hg crash')
   > def crash(ui, *args, **kwargs):
   > raise Exception("oops")
-  > @command(b'abort', [], b'hg abort')
+  > @command(b'abortcmd', [], b'hg abortcmd')
   > def abort(ui, *args, **kwargs):
   > raise error.Abort(b"oops")
   > EOF
@@ -52,10 +52,10 @@
 
 abort exit code
   $ rm ./.hg/blackbox.log
-  $ hg abort 2> /dev/null
+  $ hg abortcmd 2> /dev/null
   [255]
   $ hg blackbox -l 2
-  1970/01/01 00:00:00 bob @ (5000)> 
abort exited 255 after * seconds (glob)
+  1970/01/01 00:00:00 bob @ (5000)> 
abortcmd exited 255 after * seconds (glob)
   1970/01/01 00:00:00 bob @ (5000)> 
blackbox -l 2
 
 unhandled exception
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -98,7 +98,8 @@
 """
 
 def __init__(self, opname, fname, clearable, allowcommit, reportonly,
- continueflag, stopflag, cmdmsg, cmdhint, statushint):
+ continueflag, stopflag, cmdmsg, cmdhint, statushint,
+ abortfunc):
 self._opname = opname
 self._fname = fname
 self._clearable = clearable
@@ -109,6 +110,7 @@
 self._cmdmsg = cmdmsg
 self._cmdhint = cmdhint
 self._statushint = statushint
+self.abortfunc = abortfunc
 
 def statusmsg(self):
 """returns the hint message corresponding to the command for
@@ -157,7 +159,7 @@
 
 def addunfinished(opname, fname, clearable=False, allowcommit=False,
   reportonly=False, continueflag=False, stopflag=False,
-  cmdmsg="", cmdhint="", statushint=""):
+  cmdmsg="", cmdhint="", statushint="", abortfunc=None):
 """this registers a new command or operation to unfinishedstates
 opname is the name the command or operation
 fname is the file name in which data should be stored in .hg directory.
@@ -181,10 +183,11 @@
 statushint is used to pass a different status message in case standard
 message of the format ('To continue:hg cmdname --continue'
 'To abort:   hg cmdname --abort') is not desired
+abortfunc stores the function required to abort an unfinished state.
 """
 statecheckobj = _statecheck(opname, fname, clearable, allowcommit,
 reportonly, continueflag, stopflag, cmdmsg,
-cmdhint, statushint)
+cmdhint, statushint, abortfunc)
 if opname == 'merge':

D6567: abort: added support for graft

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG5171937ad0f9: abort: added support for graft (authored by 
taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6567?vs=15831&id=15846

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6567/new/

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/state.py
  tests/test-graft.t

CHANGE DETAILS

diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1,9 +1,18 @@
+#testcases abortcommand abortflag
+
   $ cat >> $HGRCPATH < [extdiff]
   > # for portability:
   > pdiff = sh "$RUNTESTDIR/pdiff"
   > EOF
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = graft --abort
+  > EOF
+#endif
+
 Create a repo with some stuff in it:
 
   $ hg init a
@@ -1986,8 +1995,9 @@
   $ hg up 9150fe93bec6
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-  $ hg graft --abort
-  abort: no interrupted graft to abort
+  $ hg abort
+  abort: no interrupted graft to abort (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
 
 when stripping is required
@@ -2016,7 +2026,13 @@
   abort: cannot specify any other flag with '--abort'
   [255]
 
-  $ hg graft --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  graft in progress, will be aborted
+#endif
+
+  $ hg abort
   graft aborted
   working directory is now at 9150fe93bec6
   $ hg log -GT "{rev}:{node|short} {desc}"
@@ -2041,7 +2057,7 @@
   (use 'hg resolve' and 'hg graft --continue')
   [255]
 
-  $ hg graft --abort
+  $ hg abort
   graft aborted
   working directory is now at 9150fe93bec6
   $ hg log -GT "{rev}:{node|short} {desc}"
@@ -2085,7 +2101,7 @@
   
   $ hg phase -r 6 --public
 
-  $ hg graft --abort
+  $ hg abort
   cannot clean up public changesets 6ec71c037d94
   graft aborted
   working directory is now at 6ec71c037d94
@@ -2162,7 +2178,7 @@
   new changesets 311dfc6cf3bf (1 drafts)
   (run 'hg heads .' to see heads, 'hg merge' to merge)
 
-  $ hg graft --abort
+  $ hg abort
   new changesets detected on destination branch, can't strip
   graft aborted
   working directory is now at 6b98ff0062dd
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,11 +194,6 @@
 _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-'graft', fname='graftstate', clearable=True, stopflag=True,
-continueflag=True,
-cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
-)
-addunfinished(
 'unshelve', fname='shelvedstate', continueflag=True,
 cmdmsg=_('unshelve already in progress')
 )
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2677,6 +2677,12 @@
 ui.status(_("working directory is now at %s\n") % pctx.hex()[:12])
 return 0
 
+statemod.addunfinished(
+'graft', fname='graftstate', clearable=True, stopflag=True,
+continueflag=True, abortfunc=cmdutil.hgabortgraft,
+cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
+)
+
 @command('grep',
 [('0', 'print0', None, _('end fields with NUL')),
 ('', 'all', None, _('print all revisions that match (DEPRECATED) ')),
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3419,3 +3419,9 @@
 except error.CorruptedState:
 nodes = repo.vfs.read('graftstate').splitlines()
 return {'nodes': nodes}
+
+def hgabortgraft(ui, repo):
+""" abort logic for aborting graft using 'hg abort'"""
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+return abortgraft(ui, repo, graftstate)



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


D6582: abort: added support for histedit

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGdb5560c07a28: abort: added support for histedit (authored 
by taapas1128).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6582?vs=15834&id=15848#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6582?vs=15834&id=15848

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6582/new/

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

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t
  tests/test-histedit-no-backup.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
@@ -1,3 +1,12 @@
+#testcases abortcommand abortflag
+
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = histedit --abort
+  > EOF
+#endif
+
   $ . "$TESTDIR/histedit-helpers.sh"
 
 Enable obsolete
@@ -522,7 +531,13 @@
   (hg histedit --continue to resume)
   [1]
 
-  $ hg histedit --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  histedit in progress, will be aborted
+#endif
+
+  $ hg abort
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to 
$TESTTMP/abort/.hg/strip-backup/4dc06258baa6-dff4ef05-backup.hg
 
diff --git a/tests/test-histedit-no-backup.t b/tests/test-histedit-no-backup.t
--- a/tests/test-histedit-no-backup.t
+++ b/tests/test-histedit-no-backup.t
@@ -1,3 +1,12 @@
+#testcases abortcommand abortflag
+
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = histedit --abort
+  > EOF
+#endif
+
   $ . "$TESTDIR/histedit-helpers.sh"
 
 Enable extension used by this test
@@ -44,7 +53,7 @@
   Editing (7d5187087c79), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
-  $ hg histedit --abort
+  $ hg abort
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to 
$TESTTMP/foo/.hg/strip-backup/1d8f701c7b35-cf7be322-backup.hg
   saved backup bundle to 
$TESTTMP/foo/.hg/strip-backup/5c0056670bce-b54b65d0-backup.hg
@@ -66,5 +75,6 @@
   Editing (7d5187087c79), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
-  $ hg histedit --abort
+
+  $ hg abort
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -1,3 +1,12 @@
+#testcases abortcommand abortflag
+
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = histedit --abort
+  > EOF
+#endif
+
 Test argument handling and various data parsing
 ==
 
@@ -47,8 +56,9 @@
   $ hg histedit --continue
   abort: no histedit in progress
   [255]
-  $ hg histedit --abort
-  abort: no histedit in progress
+  $ hg abort
+  abort: no histedit in progress (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
 
 Run a dummy edit to make sure we get tip^^ correctly via revsingle.
@@ -358,7 +368,7 @@
 Corrupt histedit state file
   $ sed 's/8fda0c726bf2/123456789012/' .hg/histedit-state > ../corrupt-histedit
   $ mv ../corrupt-histedit .hg/histedit-state
-  $ hg histedit --abort
+  $ hg abort
   warning: encountered an exception during histedit --abort; the repository 
may not have been completely cleaned up
   abort: $TESTTMP/foo/.hg/strip-backup/*-histedit.hg: $ENOENT$ (glob) (windows 
!)
   abort: $ENOENT$: '$TESTTMP/foo/.hg/strip-backup/*-histedit.hg' (glob) 
(no-windows !)
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1919,6 +1919,14 @@
 finally:
 state.clear()
 
+def hgaborthistedit(ui, repo):
+state = histeditstate(repo)
+nobackup = not ui.configbool('rewrite', 'backup-bundle')
+with repo.wlock() as wlock, repo.lock() as lock:
+state.wlock = wlock
+state.lock = lock
+_aborthistedit(ui, repo, state, nobackup=nobackup)
+
 def _edithisteditplan(ui, repo, state, rules):
 state.read()
 if not rules:
@@ -2314,5 +2322,5 @@
 def extsetup(ui):
 cmdutil.summaryhooks.add('histedit', summaryhook)
 statemod.addunfinished('histedit', fname='histedit-state', 
allowcommit=True,
-continueflag=True)
+continueflag=True, abortfunc=hgaborthistedit)
 



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


D6624: tests: update test-commit-interactive.t for no-execbit platforms

2019-07-10 Thread mharbison72 (Matt Harbison)
Closed by commit rHGebf353aa4385: tests: update test-commit-interactive.t for 
no-execbit platforms (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6624?vs=15837&id=15849

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6624/new/

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

AFFECTED FILES
  tests/test-commit-interactive.t

CHANGE DETAILS

diff --git a/tests/test-commit-interactive.t b/tests/test-commit-interactive.t
--- a/tests/test-commit-interactive.t
+++ b/tests/test-commit-interactive.t
@@ -1216,13 +1216,15 @@
   > EOF
   diff --git a/subdir/f1 b/subdir/f1
   1 hunks, 1 lines changed
-  examine changes to 'subdir/f1'? [Ynesfdaq?] y
+  examine changes to 'subdir/f1'?
+  (enter ? for help) [Ynesfdaq?] y
   
   @@ -1,2 +1,3 @@
a
a
   +a
-  record this change to 'subdir/f1'? [Ynesfdaq?] y
+  record this change to 'subdir/f1'?
+  (enter ? for help) [Ynesfdaq?] y
   
 
   $ hg tip --config diff.git=True -p
@@ -1251,14 +1253,16 @@
   > EOF
   diff --git a/subdir/f1 b/subdir/f1
   1 hunks, 1 lines changed
-  examine changes to 'subdir/f1'? [Ynesfdaq?] y
+  examine changes to 'subdir/f1'?
+  (enter ? for help) [Ynesfdaq?] y
   
   @@ -1,3 +1,4 @@
a
a
a
   +b
-  record this change to 'subdir/f1'? [Ynesfdaq?] y
+  record this change to 'subdir/f1'?
+  (enter ? for help) [Ynesfdaq?] y
   
 
   $ hg tip --config diff.git=True -p
@@ -1289,14 +1293,16 @@
   > EOF
   diff --git a/subdir/f1 b/subdir/f1
   1 hunks, 1 lines changed
-  examine changes to 'subdir/f1'? [Ynesfdaq?] y
+  examine changes to 'subdir/f1'?
+  (enter ? for help) [Ynesfdaq?] y
   
   @@ -2,3 +2,4 @@ a
a
a
b
   +c
-  record this change to 'subdir/f1'? [Ynesfdaq?] y
+  record this change to 'subdir/f1'?
+  (enter ? for help) [Ynesfdaq?] y
   
 
   $ hg tip --config diff.git=True -p



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


D6568: abort: added support for rebase

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGb9bc47211cf5: abort: added support for rebase (authored by 
taapas1128).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6568?vs=15832&id=15847#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6568?vs=15832&id=15847

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6568/new/

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-abort.t

CHANGE DETAILS

diff --git a/tests/test-rebase-abort.t b/tests/test-rebase-abort.t
--- a/tests/test-rebase-abort.t
+++ b/tests/test-rebase-abort.t
@@ -1,3 +1,5 @@
+#testcases abortcommand abortflag
+
   $ cat >> $HGRCPATH < [extensions]
   > rebase=
@@ -9,6 +11,12 @@
   > tglog = log -G --template "{rev}:{phase} '{desc}' {branches}\n"
   > EOF
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = rebase --abort
+  > EOF
+#endif
 
   $ hg init a
   $ cd a
@@ -114,7 +122,13 @@
 
 Abort (should clear out unsupported merge state):
 
-  $ hg rebase --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  rebase in progress, will be aborted
+#endif
+
+  $ hg abort
   saved backup bundle to 
$TESTTMP/a/.hg/strip-backup/3e046f2ecedb-6beef7d5-backup.hg
   rebase aborted
   $ hg debugmergestate
@@ -154,7 +168,7 @@
   [255]
   $ hg summary | grep '^rebase: '
   rebase: (use "hg rebase --abort" to clear broken state)
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted (no revision is removed, only broken state is cleared)
 
   $ cd ..
@@ -271,7 +285,7 @@
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted
   $ hg log -G --template "{rev} {desc} {bookmarks}"
   @  3 C foo
@@ -324,7 +338,7 @@
 
   $ cat a
   new
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted
   $ cat a
   new
@@ -405,7 +419,7 @@
   (use 'hg rebase --continue' or 'hg rebase --abort')
   [255]
 
-  $ hg rebase --abort
+  $ hg abort
   saved backup bundle to 
$TESTTMP/interrupted/.hg/strip-backup/3d8812cf300d-93041a90-backup.hg
   rebase aborted
   $ hg log -G --template "{rev} {desc} {bookmarks}"
@@ -456,7 +470,7 @@
   rebasing 2:e4ea5cdc9789 "conflicting 1"
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted
   $ hg summary
   parent: 3:b16646383533 tip
@@ -497,7 +511,7 @@
   warning: conflicts while merging root! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted
   $ cd ..
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1923,6 +1923,11 @@
 obsoleteextinctsuccessors,
 )
 
+def abortrebase(ui, repo):
+with repo.wlock(), repo.lock():
+rbsrt = rebaseruntime(repo, ui)
+rbsrt._prepareabortorcontinue(isabort=True)
+
 def summaryhook(ui, repo):
 if not repo.vfs.exists('rebasestate'):
 return
@@ -1951,4 +1956,4 @@
  _("specify merge tool for rebase")))
 cmdutil.summaryhooks.add('rebase', summaryhook)
 statemod.addunfinished('rebase', fname='rebasestate', stopflag=True,
-continueflag=True)
+continueflag=True, abortfunc=abortrebase)



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


D6582: abort: added support for histedit

2019-07-10 Thread pulkit (Pulkit Goyal)
This revision is now accepted and ready to land.
pulkit added inline comments.
pulkit accepted this revision.

INLINE COMMENTS

> test-histedit-no-backup.t:63
>  Enable config option:
> +
>$ cat >>$HGRCPATH 

D6613: commit: improve the files field of changelog for merges (RFC)

2019-07-10 Thread valentin.gatienbaron (Valentin Gatien-Baron)
valentin.gatienbaron added a comment.


  Ok. Maybe it would be simpler or more robust to do the direct thing: 
optionally treat the files list in the input commit as input and reuse them 
blindly in the resulting commit, when doing a hg->hg conversion without filemap.
  (btw, a tweak to test-merge-combinations shows the cases where convert is not 
the identity: 12-- and -1--, so cases where a file is absent in p1, that p2 
added or modified, and the merge redeletes the file. Commit shows such files 
are modified (rightly) but convert doesn't)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6613/new/

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

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


D6631: rust-cpython: add macro for sharing references

2019-07-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Following an experiment done by Georges Racinet, we now have a working way of
  sharing references between Python and Rust. This is needed in many points of
  the codebase, for example every time we need to expose an iterator to a
  Rust-backed Python class.
  
  In a few words, references are (unsafely) marked as `'static` and coupled
  with manual reference counting; we are doing manual borrow-checking.
  
  This changes introduces two declarative macro to help reduce boilerplate.
  While it is better than not using macros, they are not perfect. They need to:
  
  - Integrate with the garbage collector for container types (not needed
  
  as of yet), as stated in the docstring
  
  - Allow for leaking multiple attributes at the same time
  - Inject the `leaked_count` data attribute in `py_class`-generated
  
  structs
  
  - Automatically namespace the functions and attributes they generate
  
  For at least the last two points, we will need to write a procedural macro
  instead of a declarative one.
  While this reference-sharing mechanism is being ironed out I thought it best
  not to implement it yet.
  
  Lastly, and implementation detail renders our Rust-backed Python iterators too
  strict to be proper drop-in replacements, as will be illustrated in a future
  patch: if the data structure referenced by a non-depleted iterator is mutated,
  an `AlreadyBorrowed` exception is raised, whereas Python would allow it, only
  to raise a `RuntimeError` if `next` is called on said iterator. This will have
  to be addressed at some point.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  rust/hg-cpython/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/dirstate/mod.rs
  rust/hg-cpython/src/exceptions.rs
  rust/hg-cpython/src/lib.rs
  rust/hg-cpython/src/macros.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/macros.rs b/rust/hg-cpython/src/macros.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-cpython/src/macros.rs
@@ -0,0 +1,254 @@
+// macros.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Macros for use in the `hg-cpython` bridge library.
+
+/// Allows a `py_class!` generated struct to share references to one of its
+/// data members with Python.
+///
+/// # Warning
+///
+/// The targeted `py_class!` needs to have the
+/// `data leak_count: RefCell;` data attribute to compile.
+/// A better, more complicated macro is needed to automatically insert the
+/// leak count, which is not yet really battle tested (what happens when
+/// multiple references are needed?). See the example below.
+///
+/// TODO allow Python container types: for now, integration with the garbage
+/// collector does not extend to Rust structs holding references to Python
+/// objects. Should the need surface, `__traverse__` and `__clear__` will
+/// need to be written as per the `rust-cpython` docs on GC integration.
+///
+/// # Parameters
+///
+/// * `$name` is the same identifier used in for `py_class!` macro call.
+/// * `$inner_struct` is the identifier of the underlying Rust struct
+/// * `$data_member` is the identifier of the data member of `$inner_struct`
+/// that will be shared.
+/// * `$leaked` is the identifier to give to the struct that will manage
+/// references to `$name`, to be used for example in other macros like
+/// `py_shared_mapping_iterator`.
+///
+/// # Example
+///
+/// ```
+/// struct MyStruct {
+/// inner: Vec;
+/// }
+///
+/// py_class!(pub class MyType |py| {
+/// data inner: RefCell;
+/// data leak_count: RefCell;
+/// });
+///
+/// py_shared_ref!(MyType, MyStruct, inner, MyTypeLeakedRef);
+/// ```
+macro_rules! py_shared_ref {
+(
+$name: ident,
+$inner_struct: ident,
+$data_member: ident,
+$leaked: ident
+) => {
+impl $name {
+fn leak_immutable(&self, py: Python) -> &'static $inner_struct {
+let ptr = self.$data_member(py).as_ptr();
+*self.leak_count(py).borrow_mut() += 1;
+unsafe { &*ptr }
+}
+
+fn borrow_mut<'a>(
+&'a self,
+py: Python<'a>,
+) -> PyResult> {
+match *self.leak_count(py).borrow() {
+0 => Ok(self.$data_member(py).borrow_mut()),
+// TODO
+// For now, this works differently than Python references
+// in the case of iterators.
+// Python does not complain when the data an iterator
+// points to is modified if the iterator is never used
+// afterwards.
+// Her

D6628: rust-parsers: switch to parse/pack_dirstate to mutate-on-loop

2019-07-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, mjpieters, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Both `parse_dirstate` and `pack_dirstate` can operate directly on the data
  they're passed, which prevents the creation of intermediate data structures,
  simplifies the function signatures and reduces boilerplate. They are exposed
  directly to the Python for now, but a later patch will make use of them inside
  `hg-core`.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-core/src/dirstate/mod.rs
  rust/hg-core/src/dirstate/parsers.rs
  rust/hg-core/src/lib.rs
  rust/hg-cpython/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/dirstate/mod.rs
  rust/hg-cpython/src/parsers.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/parsers.rs b/rust/hg-cpython/src/parsers.rs
--- a/rust/hg-cpython/src/parsers.rs
+++ b/rust/hg-cpython/src/parsers.rs
@@ -12,17 +12,18 @@
 //!
 use cpython::{
 exc, PyBytes, PyDict, PyErr, PyInt, PyModule, PyResult, PyTuple, Python,
-ToPyObject, PythonObject
+ToPyObject,
 };
 use hg::{
-pack_dirstate, parse_dirstate, CopyVecEntry, DirstateEntry,
-DirstatePackError, DirstateParents, DirstateParseError,
+pack_dirstate, parse_dirstate, DirstateEntry, DirstatePackError,
+DirstateParents, DirstateParseError,
 };
 use std::collections::HashMap;
 
 use libc::c_char;
 
-use dirstate::{decapsule_make_dirstate_tuple, extract_dirstate_vec};
+use dirstate::{decapsule_make_dirstate_tuple, extract_dirstate};
+use std::time::Duration;
 
 fn parse_dirstate_wrapper(
 py: Python,
@@ -30,12 +31,15 @@
 copymap: PyDict,
 st: PyBytes,
 ) -> PyResult {
-match parse_dirstate(st.data(py)) {
-Ok((parents, dirstate_vec, copies)) => {
-for (filename, entry) in dirstate_vec {
+let mut dirstate_map = HashMap::new();
+let mut copies = HashMap::new();
+
+match parse_dirstate(&mut dirstate_map, &mut copies, st.data(py)) {
+Ok(parents) => {
+for (filename, entry) in dirstate_map {
 dmap.set_item(
 py,
-PyBytes::new(py, &filename[..]),
+PyBytes::new(py, &filename),
 decapsule_make_dirstate_tuple(py)?(
 entry.state as c_char,
 entry.mode,
@@ -44,15 +48,17 @@
 ),
 )?;
 }
-for CopyVecEntry { path, copy_path } in copies {
+for (path, copy_path) in copies {
 copymap.set_item(
 py,
-PyBytes::new(py, path),
-PyBytes::new(py, copy_path),
+PyBytes::new(py, &path),
+PyBytes::new(py, ©_path),
 )?;
 }
-Ok((PyBytes::new(py, parents.p1), PyBytes::new(py, parents.p2))
-.to_py_object(py))
+Ok(
+(PyBytes::new(py, &parents.p1), PyBytes::new(py, &parents.p2))
+.to_py_object(py),
+)
 }
 Err(e) => Err(PyErr::new::(
 py,
@@ -64,6 +70,9 @@
 "overflow in dirstate".to_string()
 }
 DirstateParseError::CorruptedEntry(e) => e,
+DirstateParseError::Damaged => {
+"dirstate appears to be damaged".to_string()
+}
 },
 )),
 }
@@ -81,7 +90,7 @@
 let p2 = pl.get_item(py, 1).extract::(py)?;
 let p2: &[u8] = p2.data(py);
 
-let dirstate_vec = extract_dirstate_vec(py, &dmap)?;
+let mut dirstate_map = extract_dirstate(py, &dmap)?;
 
 let copies: Result, Vec>, PyErr> = copymap
 .items(py)
@@ -95,12 +104,15 @@
 .collect();
 
 match pack_dirstate(
-&dirstate_vec,
+&mut dirstate_map,
 &copies?,
-DirstateParents { p1, p2 },
-now.as_object().extract::(py)?,
+DirstateParents {
+p1: p1.to_owned(),
+p2: p2.to_owned(),
+},
+Duration::from_secs(now.value(py) as u64),
 ) {
-Ok((packed, new_dirstate_vec)) => {
+Ok(packed) => {
 for (
 filename,
 DirstateEntry {
@@ -109,7 +121,7 @@
 size,
 mtime,
 },
-) in new_dirstate_vec
+) in dirstate_map
 {
 dmap.set_item(
 py,
diff --git a/rust/hg-cpython/src/dirstate/mod.rs 
b/rust/hg-cpython/src/dirstate/mod.rs
--- a/rust/hg-cpython/src/dirstate/mod.rs
+++ b/rust/hg-cpython/src/dirstate/mod.rs
@@ -13,7 +13,7 @@
 use cpython::{
 PyBytes, PyDict, PyErr, PyModule, PyObject, PyResult, PySequence, Python,
 };
-use hg::{DirstateEntry, DirstateVec};
+use hg::{DirstateEn

D6629: rust-dirstate: use EntryState enum instead of literals

2019-07-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This improves code readability quite a bit, while also adding a layer of
  safety because we're checking the state byte against the enum.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-core/src/dirstate/mod.rs
  rust/hg-core/src/dirstate/parsers.rs
  rust/hg-core/src/lib.rs
  rust/hg-cpython/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/dirstate/mod.rs
  rust/hg-cpython/src/parsers.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/parsers.rs b/rust/hg-cpython/src/parsers.rs
--- a/rust/hg-cpython/src/parsers.rs
+++ b/rust/hg-cpython/src/parsers.rs
@@ -37,11 +37,15 @@
 match parse_dirstate(&mut dirstate_map, &mut copies, st.data(py)) {
 Ok(parents) => {
 for (filename, entry) in dirstate_map {
+// Explicitly go through u8 first, then cast to
+// platform-specific `c_char`.
+let state: u8 = entry.state.into();
+
 dmap.set_item(
 py,
 PyBytes::new(py, &filename),
 decapsule_make_dirstate_tuple(py)?(
-entry.state as c_char,
+state as c_char,
 entry.mode,
 entry.size,
 entry.mtime,
@@ -123,6 +127,9 @@
 },
 ) in dirstate_map
 {
+// Explicitly go through u8 first, then cast to
+// platform-specific `c_char`.
+let state: u8 = state.into();
 dmap.set_item(
 py,
 PyBytes::new(py, &filename[..]),
diff --git a/rust/hg-cpython/src/dirstate/mod.rs 
b/rust/hg-cpython/src/dirstate/mod.rs
--- a/rust/hg-cpython/src/dirstate/mod.rs
+++ b/rust/hg-cpython/src/dirstate/mod.rs
@@ -11,9 +11,10 @@
 //! From Python, this will be seen as `mercurial.rustext.dirstate`
 
 use cpython::{
-PyBytes, PyDict, PyErr, PyModule, PyObject, PyResult, PySequence, Python,
+exc, PyBytes, PyDict, PyErr, PyModule, PyObject, PyResult, PySequence,
+Python,
 };
-use hg::{DirstateEntry, StateMap};
+use hg::{DirstateEntry, DirstateParseError, EntryState, StateMap};
 use std::ffi::CStr;
 
 #[cfg(feature = "python27")]
@@ -27,6 +28,7 @@
 
 mod dirs_multiset;
 use dirstate::dirs_multiset::Dirs;
+use std::convert::TryFrom;
 
 /// C code uses a custom `dirstate_tuple` type, checks in multiple instances
 /// for this type, and raises a Python `Exception` if the check does not pass.
@@ -65,7 +67,11 @@
 .map(|(filename, stats)| {
 let stats = stats.extract::(py)?;
 let state = stats.get_item(py, 0)?.extract::(py)?;
-let state = state.data(py)[0] as i8;
+let state = EntryState::try_from(state.data(py)[0]).map_err(
+|e: DirstateParseError| {
+PyErr::new::(py, e.to_string())
+},
+)?;
 let mode = stats.get_item(py, 1)?.extract(py)?;
 let size = stats.get_item(py, 2)?.extract(py)?;
 let mtime = stats.get_item(py, 3)?.extract(py)?;
diff --git a/rust/hg-cpython/src/dirstate/dirs_multiset.rs 
b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
@@ -16,7 +16,11 @@
 };
 
 use dirstate::extract_dirstate;
-use hg::{DirsIterable, DirsMultiset, DirstateMapError};
+use hg::{
+DirsIterable, DirsMultiset, DirstateMapError, DirstateParseError,
+EntryState,
+};
+use std::convert::TryInto;
 
 py_class!(pub class Dirs |py| {
 data dirs_map: RefCell;
@@ -28,9 +32,15 @@
 map: PyObject,
 skip: Option = None
 ) -> PyResult {
-let mut skip_state: Option = None;
+let mut skip_state: Option = None;
 if let Some(skip) = skip {
-skip_state = Some(skip.extract::(py)?.data(py)[0] as i8);
+skip_state = Some(
+skip.extract::(py)?.data(py)[0]
+.try_into()
+.map_err(|e: DirstateParseError| {
+PyErr::new::(py, e.to_string())
+})?,
+);
 }
 let inner = if let Ok(map) = map.cast_as::(py) {
 let dirstate = extract_dirstate(py, &map)?;
diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -6,10 +6,12 @@
 extern crate memchr;
 #[macro_use]
 extern crate lazy_static;
+extern crate core;
 extern crate regex;
 
 mod ancestors;
 pub mod dagops;
+pub mod utils;
 pub use ancestors::{AncestorsIterator, LazyAncestors, MissingAncestors};
 mod dirstate;
 pub mod discovery;
@@ -17,10 +19,10 @@
 pub us

D6630: rust-docstrings: add missing module docstrings

2019-07-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  rust/hg-core/src/filepatterns.rs
  rust/hg-core/src/utils/files.rs
  rust/hg-core/src/utils/mod.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/utils/mod.rs b/rust/hg-core/src/utils/mod.rs
--- a/rust/hg-core/src/utils/mod.rs
+++ b/rust/hg-core/src/utils/mod.rs
@@ -1,3 +1,12 @@
+// utils module
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Contains useful functions, traits, structs, etc. for use in core.
+
 pub mod files;
 
 pub fn replace_slice(buf: &mut [T], from: &[T], to: &[T])
diff --git a/rust/hg-core/src/utils/files.rs b/rust/hg-core/src/utils/files.rs
--- a/rust/hg-core/src/utils/files.rs
+++ b/rust/hg-core/src/utils/files.rs
@@ -1,3 +1,12 @@
+// files.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Functions for fiddling with files.
+
 use std::path::Path;
 
 pub fn get_path_from_bytes(bytes: &[u8]) -> &Path {
diff --git a/rust/hg-core/src/filepatterns.rs b/rust/hg-core/src/filepatterns.rs
--- a/rust/hg-core/src/filepatterns.rs
+++ b/rust/hg-core/src/filepatterns.rs
@@ -1,3 +1,12 @@
+// filepatterns.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Handling of Mercurial-specific patterns.
+
 use crate::{LineNumber, PatternError, PatternFileError};
 use regex::bytes::Regex;
 use std::collections::HashMap;



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


D6627: rust-parsers: move parser bindings to their own file and Python module

2019-07-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This tidies up the Rust side while simplifying the Python side.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/dirstate.py
  rust/hg-cpython/src/dirstate/mod.rs
  rust/hg-cpython/src/lib.rs
  rust/hg-cpython/src/parsers.rs
  tests/fakedirstatewritetime.py

CHANGE DETAILS

diff --git a/tests/fakedirstatewritetime.py b/tests/fakedirstatewritetime.py
--- a/tests/fakedirstatewritetime.py
+++ b/tests/fakedirstatewritetime.py
@@ -30,6 +30,7 @@
 )
 
 parsers = policy.importmod(r'parsers')
+rustmod = policy.importrust(r'parsers')
 
 def pack_dirstate(fakenow, orig, dmap, copymap, pl, now):
 # execute what original parsers.pack_dirstate should do actually
@@ -57,16 +58,21 @@
 # 'fakenow' value and 'touch -t mmddHHMM' argument easy
 fakenow = dateutil.parsedate(fakenow, [b'%Y%m%d%H%M'])[0]
 
-if rustext is not None:
-orig_module = rustext.dirstate
-orig_pack_dirstate = rustext.dirstate.pack_dirstate
-else:
-orig_module = parsers
-orig_pack_dirstate = parsers.pack_dirstate
+if rustmod is not None:
+# The Rust implementation does not use public parse/pack dirstate
+# to prevent conversion round-trips
+orig_dirstatemap_write = dirstate.dirstatemap.write
+wrapper = lambda self, st, now: orig_dirstatemap_write(self,
+   st,
+   fakenow)
+dirstate.dirstatemap.write = wrapper
 
 orig_dirstate_getfsnow = dirstate._getfsnow
 wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args)
 
+orig_module = parsers
+orig_pack_dirstate = parsers.pack_dirstate
+
 orig_module.pack_dirstate = wrapper
 dirstate._getfsnow = lambda *args: fakenow
 try:
@@ -74,6 +80,8 @@
 finally:
 orig_module.pack_dirstate = orig_pack_dirstate
 dirstate._getfsnow = orig_dirstate_getfsnow
+if rustmod is not None:
+dirstate.dirstatemap.write = orig_dirstatemap_write
 
 def _poststatusfixup(orig, workingctx, status, fixup):
 ui = workingctx.repo().ui
diff --git a/rust/hg-cpython/src/parsers.rs b/rust/hg-cpython/src/parsers.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-cpython/src/parsers.rs
@@ -0,0 +1,177 @@
+// parsers.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Bindings for the `hg::dirstate::parsers` module provided by the
+//! `hg-core` package.
+//!
+//! From Python, this will be seen as `mercurial.rustext.parsers`
+//!
+use cpython::{
+exc, PyBytes, PyDict, PyErr, PyInt, PyModule, PyResult, PyTuple, Python,
+ToPyObject, PythonObject
+};
+use hg::{
+pack_dirstate, parse_dirstate, CopyVecEntry, DirstateEntry,
+DirstatePackError, DirstateParents, DirstateParseError,
+};
+use std::collections::HashMap;
+
+use libc::c_char;
+
+use dirstate::{decapsule_make_dirstate_tuple, extract_dirstate_vec};
+
+fn parse_dirstate_wrapper(
+py: Python,
+dmap: PyDict,
+copymap: PyDict,
+st: PyBytes,
+) -> PyResult {
+match parse_dirstate(st.data(py)) {
+Ok((parents, dirstate_vec, copies)) => {
+for (filename, entry) in dirstate_vec {
+dmap.set_item(
+py,
+PyBytes::new(py, &filename[..]),
+decapsule_make_dirstate_tuple(py)?(
+entry.state as c_char,
+entry.mode,
+entry.size,
+entry.mtime,
+),
+)?;
+}
+for CopyVecEntry { path, copy_path } in copies {
+copymap.set_item(
+py,
+PyBytes::new(py, path),
+PyBytes::new(py, copy_path),
+)?;
+}
+Ok((PyBytes::new(py, parents.p1), PyBytes::new(py, parents.p2))
+.to_py_object(py))
+}
+Err(e) => Err(PyErr::new::(
+py,
+match e {
+DirstateParseError::TooLittleData => {
+"too little data for parents".to_string()
+}
+DirstateParseError::Overflow => {
+"overflow in dirstate".to_string()
+}
+DirstateParseError::CorruptedEntry(e) => e,
+},
+)),
+}
+}
+
+fn pack_dirstate_wrapper(
+py: Python,
+dmap: PyDict,
+copymap: PyDict,
+pl: PyTuple,
+now: PyInt,
+) -> PyResult {
+let p1 = pl.get_item(py, 0).extract::(py)?;
+let p1: &[u8] = p1.data(py);
+let p2 = pl.get_i

D6626: rust-dirstate: create dirstate submodule in hg-cpython

2019-07-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This module will soon hold multiple files, this change is to make the
  review process easier.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  rust/hg-cpython/src/dirstate.rs
  rust/hg-cpython/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/dirstate/mod.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/mod.rs 
b/rust/hg-cpython/src/dirstate/mod.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-cpython/src/dirstate/mod.rs
@@ -0,0 +1,244 @@
+// dirstate.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Bindings for the `hg::dirstate` module provided by the
+//! `hg-core` package.
+//!
+//! From Python, this will be seen as `mercurial.rustext.dirstate`
+
+use cpython::{
+exc, PyBytes, PyDict, PyErr, PyInt, PyModule, PyObject, PyResult,
+PySequence, PyTuple, Python, PythonObject, ToPyObject,
+};
+use hg::{
+pack_dirstate, parse_dirstate, CopyVecEntry, DirstateEntry,
+DirstatePackError, DirstateParents, DirstateParseError, DirstateVec,
+};
+use std::collections::HashMap;
+use std::ffi::CStr;
+
+#[cfg(feature = "python27")]
+extern crate python27_sys as python_sys;
+#[cfg(feature = "python3")]
+extern crate python3_sys as python_sys;
+
+use self::python_sys::PyCapsule_Import;
+use libc::{c_char, c_int};
+use std::mem::transmute;
+
+mod dirs_multiset;
+use dirstate::dirs_multiset::Dirs;
+
+/// C code uses a custom `dirstate_tuple` type, checks in multiple instances
+/// for this type, and raises a Python `Exception` if the check does not pass.
+/// Because this type differs only in name from the regular Python tuple, it
+/// would be a good idea in the near future to remove it entirely to allow
+/// for a pure Python tuple of the same effective structure to be used,
+/// rendering this type and the capsule below useless.
+type MakeDirstateTupleFn = extern "C" fn(
+state: c_char,
+mode: c_int,
+size: c_int,
+mtime: c_int,
+) -> PyObject;
+
+/// This is largely a copy/paste from cindex.rs, pending the merge of a
+/// `py_capsule_fn!` macro in the rust-cpython project:
+/// https://github.com/dgrunwald/rust-cpython/pull/169
+fn decapsule_make_dirstate_tuple(py: Python) -> PyResult {
+unsafe {
+let caps_name = CStr::from_bytes_with_nul_unchecked(
+b"mercurial.cext.parsers.make_dirstate_tuple_CAPI\0",
+);
+let from_caps = PyCapsule_Import(caps_name.as_ptr(), 0);
+if from_caps.is_null() {
+return Err(PyErr::fetch(py));
+}
+Ok(transmute(from_caps))
+}
+}
+
+fn parse_dirstate_wrapper(
+py: Python,
+dmap: PyDict,
+copymap: PyDict,
+st: PyBytes,
+) -> PyResult {
+match parse_dirstate(st.data(py)) {
+Ok((parents, dirstate_vec, copies)) => {
+for (filename, entry) in dirstate_vec {
+dmap.set_item(
+py,
+PyBytes::new(py, &filename[..]),
+decapsule_make_dirstate_tuple(py)?(
+entry.state as c_char,
+entry.mode,
+entry.size,
+entry.mtime,
+),
+)?;
+}
+for CopyVecEntry { path, copy_path } in copies {
+copymap.set_item(
+py,
+PyBytes::new(py, path),
+PyBytes::new(py, copy_path),
+)?;
+}
+Ok((PyBytes::new(py, parents.p1), PyBytes::new(py, parents.p2))
+.to_py_object(py))
+}
+Err(e) => Err(PyErr::new::(
+py,
+match e {
+DirstateParseError::TooLittleData => {
+"too little data for parents".to_string()
+}
+DirstateParseError::Overflow => {
+"overflow in dirstate".to_string()
+}
+DirstateParseError::CorruptedEntry(e) => e,
+},
+)),
+}
+}
+
+fn extract_dirstate_vec(
+py: Python,
+dmap: &PyDict,
+) -> Result {
+dmap.items(py)
+.iter()
+.map(|(filename, stats)| {
+let stats = stats.extract::(py)?;
+let state = stats.get_item(py, 0)?.extract::(py)?;
+let state = state.data(py)[0] as i8;
+let mode = stats.get_item(py, 1)?.extract(py)?;
+let size = stats.get_item(py, 2)?.extract(py)?;
+let mtime = stats.get_item(py, 3)?.extract(py)?;
+let filename = filename.extract::(py)?;
+let filename = filename.data(py);
+Ok((
+filename.to_owned(),
+   

D6625: rust-cargo: reorder dependencies

2019-07-10 Thread Raphaël Gomès
Alphare 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/D6625

AFFECTED FILES
  rust/Cargo.lock
  rust/hg-core/Cargo.toml

CHANGE DETAILS

diff --git a/rust/hg-core/Cargo.toml b/rust/hg-core/Cargo.toml
--- a/rust/hg-core/Cargo.toml
+++ b/rust/hg-core/Cargo.toml
@@ -13,6 +13,6 @@
 
 [dependencies]
 byteorder = "1.3.1"
+memchr = "2.2.0"
 lazy_static = "1.3.0"
-memchr = "2.2.0"
-regex = "^1.1"
+regex = "^1.1"
\ No newline at end of file
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -36,7 +36,7 @@
 version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "python27-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "python3-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -65,7 +65,7 @@
 dependencies = [
  "cpython 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "hg-core 0.1.0",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
  "python27-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "python3-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -75,7 +75,7 @@
 version = "0.1.0"
 dependencies = [
  "hg-core 0.1.0",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -85,7 +85,7 @@
 
 [[package]]
 name = "libc"
-version = "0.2.45"
+version = "0.2.55"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 
 [[package]]
@@ -103,7 +103,7 @@
 version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -112,7 +112,7 @@
 version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -122,7 +122,7 @@
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
  "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -177,7 +177,7 @@
 version = "0.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -189,7 +189,7 @@
 dependencies = [
  "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -307,7 +307,7 @@
 "checksum cpython 0.2.1 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"b489034e723e7f5109fecd19b719e664f89ef925be785885252469e9822fa940"
 "checksum fuchsia-cprng 0.1.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"81f7f8eb465745ea9b02e2704612a9946a59fa40572086c6fd49d6ddcf30bf31"
 "checksum lazy_static 1.3.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
-"checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" 
= "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74"
+"checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" 
= "42914d39aad277d9e