D8294: tests: make test-doctest.t automatically find files to run tests on

2020-03-16 Thread spectral (Kyle Lippincott)
Closed by commit rHG0af56d3ee24c: tests: make test-doctest.t automatically find 
files to run tests on (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/D8294?vs=20788=20810

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

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

AFFECTED FILES
  tests/test-doctest.py

CHANGE DETAILS

diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -1,10 +1,12 @@
 # this is hack to make sure no escape characters are inserted into the output
 
 from __future__ import absolute_import
+from __future__ import print_function
 
 import doctest
 import os
 import re
+import subprocess
 import sys
 
 ispy3 = sys.version_info[0] >= 3
@@ -49,46 +51,116 @@
 runner.summarize()
 
 
-testmod('mercurial.changelog')
-testmod('mercurial.cmdutil')
-testmod('mercurial.color')
-testmod('mercurial.config')
-testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
-testmod('mercurial.encoding')
-testmod('mercurial.fancyopts')
-testmod('mercurial.formatter')
-testmod('mercurial.hg')
-testmod('mercurial.hgweb.hgwebdir_mod')
-testmod('mercurial.match')
-testmod('mercurial.mdiff')
-testmod('mercurial.minirst')
-testmod('mercurial.parser')
-testmod('mercurial.patch')
-testmod('mercurial.pathutil')
-testmod('mercurial.pycompat')
-testmod('mercurial.revlogutils.deltas')
-testmod('mercurial.revset')
-testmod('mercurial.revsetlang')
-testmod('mercurial.simplemerge')
-testmod('mercurial.smartset')
-testmod('mercurial.store')
-testmod('mercurial.subrepo')
-testmod('mercurial.templater')
-testmod('mercurial.ui')
-testmod('mercurial.util')
-testmod('mercurial.util', testtarget='platform')  # windows.py or posix.py
-testmod('mercurial.utils.dateutil')
-testmod('mercurial.utils.stringutil')
-testmod('hgext.convert.convcmd')
-testmod('hgext.convert.cvsps')
-testmod('hgext.convert.filemap')
-testmod('hgext.convert.p4')
-testmod('hgext.convert.subversion')
-testmod('hgext.fix')
-testmod('hgext.mq')
-# Helper scripts in tests/ that have doctests:
-testmod('drawdag')
-testmod('test-run-tests')
+DONT_RUN = []
+
+# Exceptions to the defaults for a given detected module. The value for each
+# module name is a list of dicts that specify the kwargs to pass to testmod.
+# testmod is called once per item in the list, so an empty list will cause the
+# module to not be tested.
+testmod_arg_overrides = {
+'i18n.check-translation': DONT_RUN,  # may require extra installation
+'mercurial.dagparser': [{'optionflags': doctest.NORMALIZE_WHITESPACE}],
+'mercurial.keepalive': DONT_RUN,  # >>> is an example, not a doctest
+'mercurial.posix': DONT_RUN,  # run by mercurial.platform
+'mercurial.statprof': DONT_RUN,  # >>> is an example, not a doctest
+'mercurial.util': [{}, {'testtarget': 'platform'}],  # run twice!
+'mercurial.windows': DONT_RUN,  # run by mercurial.platform
+'tests.test-url': [{'optionflags': doctest.NORMALIZE_WHITESPACE}],
+}
+
+doctest_indicator = '\n\\s*>>> '
+fileset = 'set:(**.py and grep("%s"))' % doctest_indicator
+
+files = subprocess.check_output(
+"hg files --print0 '%s'" % fileset,
+shell=True,
+cwd=os.path.dirname(os.environ['TESTDIR']),
+).split(b'\0')
+
+mods_tested = set()
+for f in files:
+if not f:
+continue
+
+if ispy3:
+f = f.decode()
+
+modname = f.replace('.py', '').replace('\\', '.').replace('/', '.')
+
+# Third-party modules aren't our responsibility to test, and the modules in
+# contrib generally do not have doctests in a good state, plus they're hard
+# to import if this test is running with py2, so we just skip both for now.
+if modname.startswith('mercurial.thirdparty.') or modname.startswith(
+'contrib.'
+):
+continue
+
+for kwargs in testmod_arg_overrides.get(modname, [{}]):
+mods_tested.add((modname, '%r' % (kwargs,)))
+if modname.startswith('tests.'):
+# On py2, we can't import from tests.foo, but it works on both py2
+# and py3 with the way that PYTHONPATH is setup to import without
+# the 'tests.' prefix, so we do that.
+modname = modname[len('tests.') :]
+
+testmod(modname, **kwargs)
 
-# Disabled since it requires extra modules that might not be installed.
-# testmod('i18n.check-translation')
+# Meta-test: let's make sure that we actually ran what we expected to, above.
+# Each item in the set is a 2-tuple of module name and stringified kwargs 
passed
+# to testmod.
+expected_mods_tested = set(
+[
+('hgext.convert.convcmd', '{}'),
+('hgext.convert.cvsps', '{}'),
+('hgext.convert.filemap', '{}'),
+('hgext.convert.p4', '{}'),
+

D8278: rust-core: add missing `Debug` traits

2020-03-16 Thread Raphaël Gomès
Closed by commit rHGece43c79333e: rust-core: add missing `Debug` traits 
(authored by Alphare).
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/D8278?vs=20762=20807

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

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.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
@@ -103,6 +103,7 @@
 }
 }
 
+#[derive(Debug)]
 pub enum DirstateError {
 Parse(DirstateParseError),
 Pack(DirstatePackError),
diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -623,6 +623,7 @@
 );
 }
 
+#[derive(Debug)]
 pub struct DirstateStatus<'a> {
 pub modified: Vec>,
 pub added: Vec>,
@@ -679,6 +680,7 @@
 )
 }
 
+#[derive(Debug)]
 pub enum StatusError {
 IO(std::io::Error),
 Path(HgPathError),



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


D8280: tests: make test-doctest.t module list match reality

2020-03-16 Thread spectral (Kyle Lippincott)
Closed by commit rHG529cb23155bc: tests: make test-doctest.t module list match 
reality (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/D8280?vs=20766=20809

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

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

AFFECTED FILES
  tests/test-doctest.py

CHANGE DETAILS

diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -49,14 +49,11 @@
 runner.summarize()
 
 
-testmod('mercurial.changegroup')
 testmod('mercurial.changelog')
 testmod('mercurial.cmdutil')
 testmod('mercurial.color')
 testmod('mercurial.config')
-testmod('mercurial.context')
 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
-testmod('mercurial.dispatch')
 testmod('mercurial.encoding')
 testmod('mercurial.fancyopts')
 testmod('mercurial.formatter')
@@ -65,23 +62,21 @@
 testmod('mercurial.match')
 testmod('mercurial.mdiff')
 testmod('mercurial.minirst')
+testmod('mercurial.parser')
 testmod('mercurial.patch')
 testmod('mercurial.pathutil')
-testmod('mercurial.parser')
 testmod('mercurial.pycompat')
-testmod('mercurial.revlog')
 testmod('mercurial.revlogutils.deltas')
 testmod('mercurial.revset')
 testmod('mercurial.revsetlang')
+testmod('mercurial.simplemerge')
 testmod('mercurial.smartset')
 testmod('mercurial.store')
 testmod('mercurial.subrepo')
-testmod('mercurial.templatefilters')
 testmod('mercurial.templater')
 testmod('mercurial.ui')
-testmod('mercurial.url')
 testmod('mercurial.util')
-testmod('mercurial.util', testtarget='platform')
+testmod('mercurial.util', testtarget='platform')  # windows.py or posix.py
 testmod('mercurial.utils.dateutil')
 testmod('mercurial.utils.stringutil')
 testmod('hgext.convert.convcmd')
@@ -93,3 +88,7 @@
 testmod('hgext.mq')
 # Helper scripts in tests/ that have doctests:
 testmod('drawdag')
+testmod('test-run-tests')
+
+# Disabled since it requires extra modules that might not be installed.
+# testmod('i18n.check-translation')



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


D8279: tests: remove doctest in narrowspec, it is broken

2020-03-16 Thread spectral (Kyle Lippincott)
Closed by commit rHG1922694d638f: tests: remove doctest in narrowspec, it is 
broken (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/D8279?vs=20763=20808

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

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

AFFECTED FILES
  mercurial/narrowspec.py

CHANGE DETAILS

diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -233,21 +233,6 @@
 :param repo_includes: repo includes
 :param repo_excludes: repo excludes
 :return: include patterns, exclude patterns, and invalid include patterns.
-
->>> restrictpatterns({'f1','f2'}, {}, ['f1'], [])
-(set(['f1']), {}, [])
->>> restrictpatterns({'f1'}, {}, ['f1','f2'], [])
-(set(['f1']), {}, [])
->>> restrictpatterns({'f1/fc1', 'f3/fc3'}, {}, ['f1','f2'], [])
-(set(['f1/fc1']), {}, [])
->>> restrictpatterns({'f1_fc1'}, {}, ['f1','f2'], [])
-([], set(['path:.']), [])
->>> restrictpatterns({'f1/../f2/fc2'}, {}, ['f1','f2'], [])
-(set(['f2/fc2']), {}, [])
->>> restrictpatterns({'f1/../f3/fc3'}, {}, ['f1','f2'], [])
-([], set(['path:.']), [])
->>> restrictpatterns({'f1/$non_exitent_var'}, {}, ['f1','f2'], [])
-(set(['f1/$non_exitent_var']), {}, [])
 """
 res_excludes = set(req_excludes)
 res_excludes.update(repo_excludes)



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


D8276: cext-index: propagate inline_scan error in `index_deref`

2020-03-16 Thread marmoute (Pierre-Yves David)
Closed by commit rHG864e9534d3d4: cext-index: propagate inline_scan error in 
`index_deref` (authored by marmoute).
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/D8276?vs=20760=20806

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

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

AFFECTED FILES
  mercurial/cext/revlog.c

CHANGE DETAILS

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -157,7 +157,10 @@
 sizeof(*self->offsets));
if (self->offsets == NULL)
return (const char *)PyErr_NoMemory();
-   inline_scan(self, self->offsets);
+   Py_ssize_t ret = inline_scan(self, self->offsets);
+   if (ret == -1) {
+   return NULL;
+   };
}
return self->offsets[pos];
}



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


D8275: heptapod-ci: fix test paths in the listing file

2020-03-16 Thread marmoute (Pierre-Yves David)
Closed by commit rHGdaf083140b5b: heptapod-ci: fix test paths in the listing 
file (authored by marmoute).
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/D8275?vs=20759=20805

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

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

AFFECTED FILES
  contrib/heptapod-ci.yml

CHANGE DETAILS

diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml
--- a/contrib/heptapod-ci.yml
+++ b/contrib/heptapod-ci.yml
@@ -6,7 +6,7 @@
 - hg clone . /tmp/mercurial-ci/ --noupdate
 - hg -R /tmp/mercurial-ci/ update `hg log --rev '.' --template '{node}'`
 - cd /tmp/mercurial-ci/
-- (cd tests; ls -1 test-check-*.*) > /tmp/check-tests.txt
+- ls -1 tests/test-check-*.* > /tmp/check-tests.txt
 
 variables:
 PYTHON: python



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


D8284: fix: disallow `hg fix --all --working-dir`

2020-03-16 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHG40f4a75938ba: fix: disallow `hg fix --all --working-dir` 
(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/D8284?vs=20771=20803

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

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

AFFECTED FILES
  hgext/fix.py
  tests/test-fix-topology.t

CHANGE DETAILS

diff --git a/tests/test-fix-topology.t b/tests/test-fix-topology.t
--- a/tests/test-fix-topology.t
+++ b/tests/test-fix-topology.t
@@ -271,6 +271,9 @@
 
   $ hg init fixall
   $ cd fixall
+  $ hg fix --all --working-dir
+  abort: cannot specify both --working-dir and --all
+  [255]
 
 #if obsstore-on
   $ printf "one\n" > foo.whole
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -250,6 +250,7 @@
 """
 opts = pycompat.byteskwargs(opts)
 cmdutil.check_at_most_one_arg(opts, b'all', b'rev')
+cmdutil.check_incompatible_arguments(opts, b'working_dir', [b'all'])
 if opts[b'all']:
 opts[b'rev'] = [b'not public() and not obsolete()']
 opts[b'working_dir'] = True



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


D8285: fix: refactor getrevstofix() to define revisions first, then validate them

2020-03-16 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHG368f85c5dfc0: fix: refactor getrevstofix() to define 
revisions first, then validate them (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/D8285?vs=20799=20804

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

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

AFFECTED FILES
  hgext/fix.py

CHANGE DETAILS

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -400,15 +400,16 @@
 def getrevstofix(ui, repo, opts):
 """Returns the set of revision numbers that should be fixed"""
 revs = set(scmutil.revrange(repo, opts[b'rev']))
+if opts.get(b'working_dir'):
+revs.add(wdirrev)
 for rev in revs:
 checkfixablectx(ui, repo, repo[rev])
-if revs:
+# Allow fixing only wdir() even if there's an unfinished operation
+if not (len(revs) == 1 and wdirrev in revs):
 cmdutil.checkunfinished(repo)
 rewriteutil.precheck(repo, revs, b'fix')
-if opts.get(b'working_dir'):
-revs.add(wdirrev)
-if list(merge.mergestate.read(repo).unresolved()):
-raise error.Abort(b'unresolved conflicts', hint=b"use 'hg 
resolve'")
+if wdirrev in revs and list(merge.mergestate.read(repo).unresolved()):
+raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
 if not revs:
 raise error.Abort(
 b'no changesets specified', hint=b'use --rev or --working-dir'



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


D8286: fix: move handling of --all into getrevstofix() for consistency

2020-03-16 Thread durin42 (Augie Fackler)
This revision now requires changes to proceed.
durin42 added a comment.
durin42 requested changes to this revision.


  LGTM but needs rebased?

REPOSITORY
  rHG Mercurial

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

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

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


D8287: fix: add a -s option to format a revision and its descendants

2020-03-16 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 20801.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8287?vs=20780=20801

BRANCH
  default

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

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

AFFECTED FILES
  hgext/fix.py
  tests/test-fix-topology.t
  tests/test-fix.t

CHANGE DETAILS

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -104,12 +104,13 @@
   
   options ([+] can be repeated):
   
-  --all  fix all non-public non-obsolete revisions
-  --base REV [+] revisions to diff against (overrides automatic selection,
- and applies to every revision being fixed)
-   -r --rev REV [+]  revisions to fix
-   -w --working-dir  fix the working directory
-  --wholealways fix every line of a file
+  --allfix all non-public non-obsolete revisions
+  --base REV [+]   revisions to diff against (overrides automatic 
selection,
+   and applies to every revision being fixed)
+   -r --rev REV [+]revisions to fix
+   -s --source REV [+] fix the specified revisions and their descendants
+   -w --working-dirfix the working directory
+  --whole  always fix every line of a file
   
   (some details hidden, use --verbose to show complete help)
 
diff --git a/tests/test-fix-topology.t b/tests/test-fix-topology.t
--- a/tests/test-fix-topology.t
+++ b/tests/test-fix-topology.t
@@ -21,6 +21,7 @@
   $ cat >> $HGRCPATH < [extensions]
   > fix =
+  > strip =
   > [fix]
   > uppercase-whole-file:command="$PYTHON" $UPPERCASEPY
   > uppercase-whole-file:pattern=set:**
@@ -262,6 +263,111 @@
 
   $ cd ..
 
+
+Test the --source option. We only do this with obsstore on to avoid duplicating
+test code. We rely on the other tests to prove that obsolescence is not an
+important factor here.
+
+#if obsstore-on
+  $ hg init source-arg
+  $ cd source-arg
+  $ printf "\n" > a
+  $ hg commit -Am "change A"
+  adding a
+  $ printf "\n" > b
+  $ hg commit -Am "change B"
+  adding b
+  $ printf "\n" > c
+  $ hg commit -Am "change C"
+  adding c
+  $ hg checkout 0
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ printf "\n" > d
+  $ hg commit -Am "change D"
+  adding d
+  created new head
+  $ hg log --graph --template '{rev} {desc}\n'
+  @  3 change D
+  |
+  | o  2 change C
+  | |
+  | o  1 change B
+  |/
+  o  0 change A
+  
+
+Test passing 'wdir()' to --source
+  $ printf "\n" > x
+  $ hg add x
+  $ hg fix -s 'wdir()'
+  $ cat *
+  
+  
+  
+
+Test passing '.' to --source
+  $ printf "\n" > x
+  $ hg fix -s .
+  $ hg log --graph --template '{rev} {desc}\n'
+  @  4 change D
+  |
+  | o  2 change C
+  | |
+  | o  1 change B
+  |/
+  o  0 change A
+  
+  $ cat *
+  
+  
+  
+  $ hg strip -qf 4
+  $ hg co -q 3
+
+Test passing other branch to --source
+  $ printf "\n" > x
+  $ hg add x
+  $ hg fix -s 2
+  $ hg log --graph --template '{rev} {desc}\n'
+  o  4 change C
+  |
+  | @  3 change D
+  | |
+  o |  1 change B
+  |/
+  o  0 change A
+  
+  $ hg cat -r 4 b c
+  
+  
+  $ cat *
+  
+  
+  
+  $ hg strip -qf 4
+
+Test passing multiple revisions to --source
+  $ hg fix -s '2 + .'
+  $ hg log --graph --template '{rev} {desc}\n'
+  @  5 change D
+  |
+  | o  4 change C
+  | |
+  | o  1 change B
+  |/
+  o  0 change A
+  
+  $ hg cat -r 4 b c
+  
+  
+  $ cat *
+  
+  
+  
+
+  $ cd ..
+#endif
+
 The --all flag should fix anything that wouldn't cause a problem if you fixed
 it, including the working copy. Obsolete revisions are not fixed because that
 could cause divergence. Public revisions would cause an abort because they are
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -214,6 +214,13 @@
 _(b'REV'),
 )
 revopt = (b'r', b'rev', [], _(b'revisions to fix'), _(b'REV'))
+sourceopt = (
+b's',
+b'source',
+[],
+_(b'fix the specified revisions and their descendants'),
+_(b'REV'),
+)
 wdiropt = (b'w', b'working-dir', False, _(b'fix the working directory'))
 wholeopt = (b'', b'whole', False, _(b'always fix every line of a file'))
 usage = _(b'[OPTION]... [FILE]...')
@@ -221,7 +228,7 @@
 
 @command(
 b'fix',
-[allopt, baseopt, revopt, wdiropt, wholeopt],
+[allopt, baseopt, revopt, sourceopt, wdiropt, wholeopt],
 usage,
 helpcategory=command.CATEGORY_FILE_CONTENTS,
 )
@@ -249,7 +256,7 @@
 override this default behavior, though it is not usually desirable to do 
so.
 """
 opts = pycompat.byteskwargs(opts)
-cmdutil.check_at_most_one_arg(opts, b'all', b'rev')
+cmdutil.check_at_most_one_arg(opts, b'all', b'source', b'rev')
 
 with repo.wlock(), repo.lock(), repo.transaction(b'fix'):
 revstofix = getrevstofix(ui, repo, opts)
@@ -398,6 +405,14 @@
 """Returns the set of 

D8288: fix: mark -r as advanced

2020-03-16 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 20802.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8288?vs=20781=20802

BRANCH
  default

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

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

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

CHANGE DETAILS

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -107,7 +107,6 @@
   --allfix all non-public non-obsolete revisions
   --base REV [+]   revisions to diff against (overrides automatic 
selection,
and applies to every revision being fixed)
-   -r --rev REV [+]revisions to fix
-s --source REV [+] fix the specified revisions and their descendants
-w --working-dirfix the working directory
   --whole  always fix every line of a file
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -213,7 +213,7 @@
 ),
 _(b'REV'),
 )
-revopt = (b'r', b'rev', [], _(b'revisions to fix'), _(b'REV'))
+revopt = (b'r', b'rev', [], _(b'revisions to fix (ADVANCED)'), _(b'REV'))
 sourceopt = (
 b's',
 b'source',



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


D8286: fix: move handling of --all into getrevstofix() for consistency

2020-03-16 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 20800.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8286?vs=20773=20800

BRANCH
  default

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

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

AFFECTED FILES
  hgext/fix.py

CHANGE DETAILS

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -250,9 +250,7 @@
 """
 opts = pycompat.byteskwargs(opts)
 cmdutil.check_at_most_one_arg(opts, b'all', b'rev')
-if opts[b'all']:
-opts[b'rev'] = [b'not public() and not obsolete()']
-opts[b'working_dir'] = True
+
 with repo.wlock(), repo.lock(), repo.transaction(b'fix'):
 revstofix = getrevstofix(ui, repo, opts)
 basectxs = getbasectxs(repo, opts, revstofix)
@@ -398,9 +396,12 @@
 
 def getrevstofix(ui, repo, opts):
 """Returns the set of revision numbers that should be fixed"""
-revs = set(scmutil.revrange(repo, opts[b'rev']))
-if opts.get(b'working_dir'):
-revs.add(wdirrev)
+if opts[b'all']:
+revs = repo.revs(b'(not public() and not obsolete()) or wdir()')
+else:
+revs = set(scmutil.revrange(repo, opts[b'rev']))
+if opts.get(b'working_dir'):
+revs.add(wdirrev)
 for rev in revs:
 checkfixablectx(ui, repo, repo[rev])
 # Allow fixing only wdir() even if there's an unfinished operation



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


D8285: fix: refactor getrevstofix() to define revisions first, then validate them

2020-03-16 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 20799.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8285?vs=20772=20799

BRANCH
  default

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

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

AFFECTED FILES
  hgext/fix.py

CHANGE DETAILS

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -399,15 +399,16 @@
 def getrevstofix(ui, repo, opts):
 """Returns the set of revision numbers that should be fixed"""
 revs = set(scmutil.revrange(repo, opts[b'rev']))
+if opts.get(b'working_dir'):
+revs.add(wdirrev)
 for rev in revs:
 checkfixablectx(ui, repo, repo[rev])
-if revs:
+# Allow fixing only wdir() even if there's an unfinished operation
+if not (len(revs) == 1 and wdirrev in revs):
 cmdutil.checkunfinished(repo)
 rewriteutil.precheck(repo, revs, b'fix')
-if opts.get(b'working_dir'):
-revs.add(wdirrev)
-if list(merge.mergestate.read(repo).unresolved()):
-raise error.Abort(b'unresolved conflicts', hint=b"use 'hg 
resolve'")
+if wdirrev in revs and list(merge.mergestate.read(repo).unresolved()):
+raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
 if not revs:
 raise error.Abort(
 b'no changesets specified', hint=b'use --rev or --working-dir'



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


D8284: fix: disallow `hg fix --all --working-dir`

2020-03-16 Thread mharbison72 (Matt Harbison)
mharbison72 added a comment.


  In D8284#123877 , @martinvonz 
wrote:
  
  > In D8284#123873 , @marmoute 
wrote:
  >
  >> In D8284#123872 , @martinvonz 
wrote:
  >>
  >>> In D8284#123838 , @marmoute 
wrote:
  >>>
   If `--working-dir` and `--all` are redundant, I don't see anyharm in 
allowing both to be passed.
  >>>
  >>> The idea was to inform users that they're doing something that's a little 
weird, in case they were hoping for it to do something else. I don't care much 
and I'm fine with dropping this patch if that's the consensus.
  >>
  >> If the intend is to inform, maybe we could issue a warning?
  >
  > Makes sense. I suppose we should do the same for `--all` and `--rev REV` in 
that case. We currently consider that an error. I don't care much about this 
issue, so I'll just move this patch to the side for now. That way the rest of 
the stack (which I care about) can be queued independently.
  
  I can't think of any existing precedent to follow, and it would probably be 
fine to error out or silently ignore it.  But warning here feels weird- what's 
the user supposed to do after the command has run?  There's already enough 
grief with the `did you mean bookmark?` warning, and that's something that the 
user could react to.

REPOSITORY
  rHG Mercurial

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

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

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


D8284: fix: disallow `hg fix --all --working-dir`

2020-03-16 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In D8284#123873 , @marmoute 
wrote:
  
  > In D8284#123872 , @martinvonz 
wrote:
  >
  >> In D8284#123838 , @marmoute 
wrote:
  >>
  >>> If `--working-dir` and `--all` are redundant, I don't see anyharm in 
allowing both to be passed.
  >>
  >> The idea was to inform users that they're doing something that's a little 
weird, in case they were hoping for it to do something else. I don't care much 
and I'm fine with dropping this patch if that's the consensus.
  >
  > If the intend is to inform, maybe we could issue a warning?
  
  Makes sense. I suppose we should do the same for `--all` and `--rev REV` in 
that case. We currently consider that an error. I don't care much about this 
issue, so I'll just move this patch to the side for now. That way the rest of 
the stack (which I care about) can be queued independently.

REPOSITORY
  rHG Mercurial

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

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

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


D6735: update: added support for --abort flag(issue4404)

2020-03-16 Thread mharbison72 (Matt Harbison)
mharbison72 added a comment.


  In D6735#123875 , @khanchi97 
wrote:
  
  > In D6735#100642 , @mharbison72 
wrote:
  >
  >> Here's a case I stumbled upon that is a problem.  It looks like it thinks 
it isn't in the middle of an update, but .hgsubstate isn't put back to the 
pre-update state.
  >>
  >>   diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
  >>   --- a/tests/test-subrepo.t
  >>   +++ b/tests/test-subrepo.t
  >>   @@ -1027,10 +1027,38 @@ filesystem (see also issue4583))
  >>  > [extensions]
  >>  > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
  >>  > EOF
  >>   +  $ hg -R repo st -S
  >>   +  ? s/b
  >>   +  $ hg -R repo diff -S
  >>   +  $ hg -R repo log -r .
  >>   +  changeset:   0:c4018e9aea1b
  >>   +  user:test
  >>   +  date:Thu Jan 01 00:00:00 1970 +
  >>   +  summary: 1
  >>   +
  >>   +  $ cat repo/.hgsubstate
  >>   +  f7b1eb17ad24730a1651fccd46c43826d1bbc2ac s
  >>  $ hg -R repo update
  >>  b: untracked file differs
  >>  abort: untracked files in working directory differ from files in 
requested revision (in subrepository "s")
  >
  > @mharbison72 I am bit confused here.
  >
  > 1. Since `hg -R repo update` resulted with an abort then why we have dirty 
working directory now? Isn't transaction rollback worked correctly?
  
  Two things to keep in mind.
  
  1. updates aren't transactions
  2. even if they were, a transaction is within *one* repo.
  
  When you update with subrepos, you check for dirty from the top, recurse to 
the bottom, and on the way up you update the subrepo.  So in the simple case of 
parent repo P and subrepo S, you check P for dirty (recursively), then update 
S, then update P.  If something goes wrong updating P, S is not rolled back.
  
  > 2. Also if you run `hg status` it says "To continue: run `hg update .`" but 
I don't think it's really a "continue", since we are still on the same 
changeset where we ran the first update command and running `hg update .` won't 
take us to the changeset we wanted to go.
  
  Maybe it needs to continue if it did a partial checkout?  IDK when the parent 
in dirstate is updated- before or after all files are checked out.
  
  > 3. I found that for interrupted update (only for some particular kind of 
interrupted update) we store target node value in `.hg/updatestate` but I 
couldn't find where we exactly use that value. I found some code which check if 
that file exists but not one where we use the value stored in that file.
  
  Sorry, I'm not sure about that either.  I'd imagine it's for the --continue 
case though.  Maybe that isn't fully implemented yet?

REPOSITORY
  rHG Mercurial

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

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

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


D6735: update: added support for --abort flag(issue4404)

2020-03-16 Thread khanchi97 (Sushil khanchi)
khanchi97 added a comment.


  In D6735#100642 , @mharbison72 
wrote:
  
  > Here's a case I stumbled upon that is a problem.  It looks like it thinks 
it isn't in the middle of an update, but .hgsubstate isn't put back to the 
pre-update state.
  >
  >   diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
  >   --- a/tests/test-subrepo.t
  >   +++ b/tests/test-subrepo.t
  >   @@ -1027,10 +1027,38 @@ filesystem (see also issue4583))
  >  > [extensions]
  >  > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
  >  > EOF
  >   +  $ hg -R repo st -S
  >   +  ? s/b
  >   +  $ hg -R repo diff -S
  >   +  $ hg -R repo log -r .
  >   +  changeset:   0:c4018e9aea1b
  >   +  user:test
  >   +  date:Thu Jan 01 00:00:00 1970 +
  >   +  summary: 1
  >   +
  >   +  $ cat repo/.hgsubstate
  >   +  f7b1eb17ad24730a1651fccd46c43826d1bbc2ac s
  >  $ hg -R repo update
  >  b: untracked file differs
  >  abort: untracked files in working directory differ from files in 
requested revision (in subrepository "s")
  
  @mharbison72 I am bit confused here.
  
  1. Since `hg -R repo update` resulted with an abort then why we have dirty 
working directory now? Isn't transaction rollback worked correctly?
  2. Also if you run `hg status` it says "To continue: run `hg update .`" but I 
don't think it's really a "continue", since we are still on the same changeset 
where we ran the first update command and running `hg update .` won't take us 
to the changeset we wanted to go.
  3. I found that for interrupted update (only for some particular kind of 
interrupted update) we store target node value in `.hg/updatestate` but I 
couldn't find where we exactly use that value. I found some code which check if 
that file exists but not one where we use the value stored in that file.
  
  >   [255]
  >
  > +  $ hg -R repo update --abort
  > +  abort: no update in progress
  > +  [255]
  > +  $ hg -R repo diff -S
  > +  diff -r c4018e9aea1b .hgsubstate
  > +  --- a/.hgsubstate Thu Jan 01 00:00:00 1970 +
  > +  +++ b/.hgsubstate Thu Jan 01 00:00:00 1970 +
  > +  @@ -1,1 +1,1 @@
  > +  -f7b1eb17ad24730a1651fccd46c43826d1bbc2ac s
  > +  +cc505f09a8b2644adffa368adb4abc6f70d07bc0 s
  > +  $ hg -R repo log -r .
  > +  changeset:   0:c4018e9aea1b
  > +  user:test
  > +  date:Thu Jan 01 00:00:00 1970 +
  > +  summary: 1
  > +
  > +
  >
  >   $ cat >> repo/.hg/hgrc <   > [extensions]
  >   > fakedirstatewritetime = !
  >
  >   Another good way to induce this .hgsubstate issue is to `hg pull -u` on a 
repo, where the remote subrepo isn't available.  You don't need http for this- 
you can just rename the remote subrepo.

REPOSITORY
  rHG Mercurial

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

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

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


D8284: fix: disallow `hg fix --all --working-dir`

2020-03-16 Thread marmoute (Pierre-Yves David)
marmoute added a comment.


  In D8284#123872 , @martinvonz 
wrote:
  
  > In D8284#123838 , @marmoute 
wrote:
  >
  >> If `--working-dir` and `--all` are redundant, I don't see anyharm in 
allowing both to be passed.
  >
  > The idea was to inform users that they're doing something that's a little 
weird, in case they were hoping for it to do something else. I don't care much 
and I'm fine with dropping this patch if that's the consensus.
  
  If the intend is to inform, maybe we could issue a warning?

REPOSITORY
  rHG Mercurial

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

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

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


D8284: fix: disallow `hg fix --all --working-dir`

2020-03-16 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In D8284#123838 , @marmoute 
wrote:
  
  > If `--working-dir` and `--all` are redundant, I don't see anyharm in 
allowing both to be passed.
  
  The idea was to inform users that they're doing something that's a little 
weird, in case they were hoping for it to do something else. I don't care much 
and I'm fine with dropping this patch if that's the consensus.

REPOSITORY
  rHG Mercurial

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

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

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