Re: D2409: graft: add no-commit mode (issue5631)

2018-02-28 Thread sushil khanchi
Hello there, Can I get a little review on this :)

On Tue, Feb 27, 2018 at 1:58 AM, khanchi97 (Sushil khanchi) <
phabrica...@mercurial-scm.org> wrote:

> khanchi97 updated this revision to Diff 6132.
>
> REPOSITORY
>   rHG Mercurial
>
> CHANGES SINCE LAST UPDATE
>   https://phab.mercurial-scm.org/D2409?vs=6028=6132
>
> REVISION DETAIL
>   https://phab.mercurial-scm.org/D2409
>
> AFFECTED FILES
>   mercurial/commands.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
> @@ -1373,3 +1373,69 @@
>note: graft of 7:d3c3f2b38ecc created no changes to commit
>
>$ cd ..
> +
> +Graft a change from a branch without making any commit using --no-commit
> option
> +
> +  $ hg init dirtochecknocommit
> +  $ cd dirtochecknocommit
> +  $ echo a > a
> +  $ hg ci -qAm0
> +  $ echo b > b
> +  $ hg ci -qAm1
> +  $ hg up -q 0
> +  $ echo c > c
> +  $ hg ci -qAm2
> +  $ hg graft 1 --no-commit
> +  grafting 1:925d80f479bb "1"
> +
> +  $ hg tip -T "rev: {rev}\n"
> +  rev: 2
> +
> +  $ hg diff
> +  diff -r db815d6d32e6 b
> +  --- /dev/nullThu Jan 01 00:00:00 1970 +
> +  +++ b/b  Thu Jan 01 00:00:00 1970 +
> +  @@ -0,0 +1,1 @@
> +  +b
> +
> +  $ hg ci -qm3
> +
> +Make a conflict between two heads and check --no-commit is resepected
> after --continue
> +
> +  $ echo A>a
> +  $ hg ci -qm4
> +  $ hg up -q 1
> +  $ echo B>a
> +  $ hg ci -qm5
> +  $ hg graft 4 --no-commit
> +  grafting 4:a08bb3910e7c "4"
> +  merging a
> +  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
> +  abort: unresolved conflicts, can't continue
> +  (use 'hg resolve' and 'hg graft --continue')
> +  [255]
> +
> +Edit:
> +
> +  $ echo A>a
> +  $ hg resolve --mark
> +  (no more unresolved files)
> +  continue: hg graft --continue
> +
> +Continue:
> +
> +  $ hg graft --continue
> +  grafting 4:a08bb3910e7c "4"
> +
> +  $ hg tip -T "rev: {rev}\n"
> +  rev: 5
> +
> +  $ hg diff
> +  diff -r b1d5b5056844 a
> +  --- a/a  Thu Jan 01 00:00:00 1970 +
> +  +++ b/a  Thu Jan 01 00:00:00 1970 +
> +  @@ -1,1 +1,1 @@
> +  -B
> +  +A
> +
> +  $ cd ..
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -2074,6 +2074,8 @@
>   ('c', 'continue', False, _('resume interrupted graft')),
>   ('e', 'edit', False, _('invoke editor on commit messages')),
>   ('', 'log', None, _('append graft info to log message')),
> + ('', 'no-commit', None,
> +  _("don't commit, just apply the changes in working directory")),
>   ('f', 'force', False, _('force graft')),
>   ('D', 'currentdate', False,
>_('record the current date as commit date')),
> @@ -2153,6 +2155,9 @@
>  revs = list(revs)
>  revs.extend(opts.get('rev'))
>
> +if opts.get('no_commit'):
> +# write out flag for --continue
> +repo.vfs.write('nocommitflag','do not commit\n')
>  if not opts.get('user') and opts.get('currentuser'):
>  opts['user'] = ui.username()
>  if not opts.get('date') and opts.get('currentdate'):
> @@ -2314,16 +2319,18 @@
>  cont = False
>
>  # commit
> -node = repo.commit(text=message, user=user,
> -date=date, extra=extra, editor=editor)
> -if node is None:
> -ui.warn(
> -_('note: graft of %d:%s created no changes to commit\n') %
> -(ctx.rev(), ctx))
> +if not repo.vfs.exists('nocommitflag'):
> +node = repo.commit(text=message, user=user,
> +date=date, extra=extra, editor=editor)
> +if node is None:
> +ui.warn(
> +_('note: graft of %d:%s created no changes to
> commit\n') %
> +(ctx.rev(), ctx))
>
>  # remove state when we complete successfully
>  if not opts.get('dry_run'):
>  repo.vfs.unlinkpath('graftstate', ignoremissing=True)
> +repo.vfs.unlinkpath('nocommitflag', ignoremissing=True)
>
>  return 0
>
>
>
>
> To: khanchi97, #hg-reviewers
> Cc: pulkit, mercurial-devel
> ___
> 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


D2495: narrow: drop safehasattr() checks for always-present repo.narrowmatch

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa9d88301d495: narrow: drop safehasattr() checks for 
always-present repo.narrowmatch (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2495?vs=6195=6227

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

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowchangegroup.py
  hgext/narrow/narrowcopies.py
  hgext/narrow/narrowmerge.py
  hgext/narrow/narrowpatch.py
  hgext/narrow/narrowtemplates.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowtemplates.py b/hgext/narrow/narrowtemplates.py
--- a/hgext/narrow/narrowtemplates.py
+++ b/hgext/narrow/narrowtemplates.py
@@ -10,7 +10,6 @@
 from mercurial import (
 registrar,
 revlog,
-util,
 )
 
 keywords = {}
@@ -33,8 +32,8 @@
 def outsidenarrow(repo, ctx, templ, **args):
 """String. 'outsidenarrow' if the change affects no tracked files,
 else ''."""
-if util.safehasattr(repo, 'narrowmatch'):
-m = repo.narrowmatch()
+m = repo.narrowmatch()
+if not m.always():
 if not any(m(f) for f in ctx.files()):
 return 'outsidenarrow'
 return ''
diff --git a/hgext/narrow/narrowpatch.py b/hgext/narrow/narrowpatch.py
--- a/hgext/narrow/narrowpatch.py
+++ b/hgext/narrow/narrowpatch.py
@@ -10,14 +10,13 @@
 from mercurial import (
 extensions,
 patch,
-util,
 )
 
 def setup(repo):
 def _filepairs(orig, *args):
 """Only includes files within the narrow spec in the diff."""
-if util.safehasattr(repo, 'narrowmatch'):
-narrowmatch = repo.narrowmatch()
+narrowmatch = repo.narrowmatch()
+if not narrowmatch.always():
 for x in orig(*args):
 f1, f2, copyop = x
 if ((not f1 or narrowmatch(f1)) and
@@ -29,8 +28,8 @@
 
 def trydiff(orig, repo, revs, ctx1, ctx2, modified, added, removed,
 copy, getfilectx, *args, **kwargs):
-if util.safehasattr(repo, 'narrowmatch'):
-narrowmatch = repo.narrowmatch()
+narrowmatch = repo.narrowmatch()
+if not narrowmatch.always():
 modified = [f for f in modified if narrowmatch(f)]
 added = [f for f in added if narrowmatch(f)]
 removed = [f for f in removed if narrowmatch(f)]
diff --git a/hgext/narrow/narrowmerge.py b/hgext/narrow/narrowmerge.py
--- a/hgext/narrow/narrowmerge.py
+++ b/hgext/narrow/narrowmerge.py
@@ -13,21 +13,20 @@
 error,
 extensions,
 merge,
-util,
 )
 
 def setup():
 def _manifestmerge(orig, repo, wctx, p2, pa, branchmerge, *args, **kwargs):
 """Filter updates to only lay out files that match the narrow spec."""
 actions, diverge, renamedelete = orig(
 repo, wctx, p2, pa, branchmerge, *args, **kwargs)
 
-if not util.safehasattr(repo, 'narrowmatch'):
+narrowmatch = repo.narrowmatch()
+if narrowmatch.always():
 return actions, diverge, renamedelete
 
 nooptypes = set(['k']) # TODO: handle with nonconflicttypes
 nonconflicttypes = set('a am c cm f g r e'.split())
-narrowmatch = repo.narrowmatch()
 # We mutate the items in the dict during iteration, so iterate
 # over a copy.
 for f, action in list(actions.items()):
@@ -51,8 +50,8 @@
 extensions.wrapfunction(merge, 'manifestmerge', _manifestmerge)
 
 def _checkcollision(orig, repo, wmf, actions):
-if util.safehasattr(repo, 'narrowmatch'):
-narrowmatch = repo.narrowmatch()
+narrowmatch = repo.narrowmatch()
+if not narrowmatch.always():
 wmf = wmf.matches(narrowmatch)
 if actions:
 narrowactions = {}
@@ -68,10 +67,10 @@
 
 def _computenonoverlap(orig, repo, *args, **kwargs):
 u1, u2 = orig(repo, *args, **kwargs)
-if not util.safehasattr(repo, 'narrowmatch'):
+narrowmatch = repo.narrowmatch()
+if not narrowmatch.always():
 return u1, u2
 
-narrowmatch = repo.narrowmatch()
 u1 = [f for f in u1 if narrowmatch(f)]
 u2 = [f for f in u2 if narrowmatch(f)]
 return u1, u2
diff --git a/hgext/narrow/narrowcopies.py b/hgext/narrow/narrowcopies.py
--- a/hgext/narrow/narrowcopies.py
+++ b/hgext/narrow/narrowcopies.py
@@ -11,23 +11,22 @@
 from mercurial import (
 copies,
 extensions,
-util,
 )
 
 def setup(repo):
 def _computeforwardmissing(orig, a, b, match=None):
 missing = orig(a, b, match)
-if util.safehasattr(repo, 'narrowmatch'):
-narrowmatch = repo.narrowmatch()
-missing = [f for f in missing if narrowmatch(f)]
+narrowmatch = repo.narrowmatch()
+if narrowmatch.always():
+return missing
+missing = [f for f in missing if narrowmatch(f)]
 return missing
 
 def 

D2489: narrow: move checking for narrow requirement into _narrowmatch()

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGcb0449f3d9fc: narrow: move checking for narrow requirement 
into _narrowmatch() (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2489?vs=6189=6222

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

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowcommands.py
  hgext/narrow/narrowrepo.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -38,7 +38,7 @@
 f.write(spec)
 return orig(ui, repo, repopath)
 
-def wraprepo(repo, opts_narrow):
+def wraprepo(repo):
 """Enables narrow clone functionality on a single local repository."""
 
 cacheprop = localrepo.storecache
@@ -77,9 +77,9 @@
 
 @localrepo.repofilecache(narrowspec.FILENAME)
 def _narrowmatch(self):
+if changegroup.NARROW_REQUIREMENT not in self.requirements:
+return matchmod.always(self.root, '')
 include, exclude = self.narrowpats
-if not opts_narrow and not include and not exclude:
-return matchmod.always(self.root, '')
 return narrowspec.match(self.root, include=include, 
exclude=exclude)
 
 # TODO(martinvonz): make this property-like instead?
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -101,7 +101,7 @@
 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
 
 def pullnarrow(orig, repo, *args, **kwargs):
-narrowrepo.wraprepo(repo.unfiltered(), opts_narrow)
+narrowrepo.wraprepo(repo.unfiltered())
 if isinstance(repo, repoview.repoview):
 repo.__class__.__bases__ = (repo.__class__.__bases__[0],
 repo.unfiltered().__class__)
diff --git a/hgext/narrow/__init__.py b/hgext/narrow/__init__.py
--- a/hgext/narrow/__init__.py
+++ b/hgext/narrow/__init__.py
@@ -73,7 +73,7 @@
 return
 
 if changegroup.NARROW_REQUIREMENT in repo.requirements:
-narrowrepo.wraprepo(repo, True)
+narrowrepo.wraprepo(repo)
 narrowcopies.setup(repo)
 narrowdirstate.setup(repo)
 narrowpatch.setup(repo)



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


D2487: narrow: move requirement constant to core

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd93553662d0a: narrow: move requirement constant to core 
(authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2487?vs=6187=6220

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

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowchangegroup.py
  hgext/narrow/narrowcommands.py
  hgext/narrow/narrowrepo.py
  mercurial/changegroup.py

CHANGE DETAILS

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -32,6 +32,10 @@
 _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s"
 _CHANGEGROUPV3_DELTA_HEADER = ">20s20s20s20s20sH"
 
+# When narrowing is finalized and no longer subject to format changes,
+# we should move this to just "narrow" or similar.
+NARROW_REQUIREMENT = 'narrowhg-experimental'
+
 readexactly = util.readexactly
 
 def getchunk(stream):
diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -9,6 +9,7 @@
 
 from mercurial import (
 bundlerepo,
+changegroup,
 hg,
 localrepo,
 match as matchmod,
@@ -20,19 +21,15 @@
 narrowrevlog,
 )
 
-# When narrowing is finalized and no longer subject to format changes,
-# we should move this to just "narrow" or similar.
-REQUIREMENT = 'narrowhg-experimental'
-
 def wrappostshare(orig, sourcerepo, destrepo, **kwargs):
 orig(sourcerepo, destrepo, **kwargs)
-if REQUIREMENT in sourcerepo.requirements:
+if changegroup.NARROW_REQUIREMENT in sourcerepo.requirements:
 with destrepo.wlock():
 with destrepo.vfs('shared', 'a') as fp:
 fp.write(narrowspec.FILENAME + '\n')
 
 def unsharenarrowspec(orig, ui, repo, repopath):
-if (REQUIREMENT in repo.requirements
+if (changegroup.NARROW_REQUIREMENT in repo.requirements
 and repo.path == repopath and repo.shared()):
 srcrepo = hg.sharedreposource(repo)
 with srcrepo.vfs(narrowspec.FILENAME) as f:
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -11,6 +11,7 @@
 from mercurial.i18n import _
 from mercurial import (
 cmdutil,
+changegroup,
 commands,
 discovery,
 error,
@@ -105,7 +106,7 @@
 repo.__class__.__bases__ = (repo.__class__.__bases__[0],
 repo.unfiltered().__class__)
 if opts_narrow:
-repo.requirements.add(narrowrepo.REQUIREMENT)
+repo.requirements.add(changegroup.NARROW_REQUIREMENT)
 repo._writerequirements()
 
 return orig(repo, *args, **kwargs)
@@ -118,7 +119,7 @@
 def pullnarrowcmd(orig, ui, repo, *args, **opts):
 """Wraps pull command to allow modifying narrow spec."""
 wrappedextraprepare = util.nullcontextmanager()
-if narrowrepo.REQUIREMENT in repo.requirements:
+if changegroup.NARROW_REQUIREMENT in repo.requirements:
 
 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
 orig(pullop, kwargs)
@@ -132,7 +133,7 @@
 
 def archivenarrowcmd(orig, ui, repo, *args, **opts):
 """Wraps archive command to narrow the default includes."""
-if narrowrepo.REQUIREMENT in repo.requirements:
+if changegroup.NARROW_REQUIREMENT in repo.requirements:
 repo_includes, repo_excludes = repo.narrowpats
 includes = set(opts.get(r'include', []))
 excludes = set(opts.get(r'exclude', []))
@@ -146,7 +147,7 @@
 
 def pullbundle2extraprepare(orig, pullop, kwargs):
 repo = pullop.repo
-if narrowrepo.REQUIREMENT not in repo.requirements:
+if changegroup.NARROW_REQUIREMENT not in repo.requirements:
 return orig(pullop, kwargs)
 
 if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps:
@@ -333,7 +334,7 @@
 empty and will not match any files.
 """
 opts = pycompat.byteskwargs(opts)
-if narrowrepo.REQUIREMENT not in repo.requirements:
+if changegroup.NARROW_REQUIREMENT not in repo.requirements:
 ui.warn(_('The narrow command is only supported on respositories 
cloned'
   ' with --narrow.\n'))
 return 1
diff --git a/hgext/narrow/narrowchangegroup.py 
b/hgext/narrow/narrowchangegroup.py
--- a/hgext/narrow/narrowchangegroup.py
+++ b/hgext/narrow/narrowchangegroup.py
@@ -19,15 +19,11 @@
 util,
 )
 
-from . import (
-narrowrepo,
-)
-
 def setup():
 
 def supportedoutgoingversions(orig, repo):
 versions = orig(repo)
-if narrowrepo.REQUIREMENT in repo.requirements:
+if changegroup.NARROW_REQUIREMENT in repo.requirements:
 versions.discard('01')
 versions.discard('02')
 return versions
diff --git a/hgext/narrow/narrowbundle2.py 

D2490: narrow: consider both local and remote matchers in narrowchangegroup

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGae95b0c81051: narrow: consider both local and remote 
matchers in narrowchangegroup (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2490?vs=6190=6223

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

AFFECTED FILES
  hgext/narrow/narrowchangegroup.py
  tests/test-narrow-exchange.t

CHANGE DETAILS

diff --git a/tests/test-narrow-exchange.t b/tests/test-narrow-exchange.t
--- a/tests/test-narrow-exchange.t
+++ b/tests/test-narrow-exchange.t
@@ -137,13 +137,12 @@
   $ hg pull ssh://user@dummy/narrow2
   pulling from ssh://user@dummy/narrow2
   searching for changes
-  remote: abort: unable to resolve parent while packing 'data/inside2/f.i' 3 
for changeset 5 (?)
   adding changesets
-  remote: abort: unexpected error: unable to resolve parent while packing 
'data/inside2/f.i' 3 for changeset 5
-  transaction abort!
-  rollback completed
-  abort: pull failed on remote
-  [255]
+  adding manifests
+  adding file changes
+  added 1 changesets with 0 changes to 0 files
+  new changesets d78a96df731d
+  (run 'hg update' to get a working copy)
 
 Check that the resulting history is valid in the full repo
 
@@ -204,7 +203,7 @@
   $ hg push ssh://user@dummy/narrow2
   pushing to ssh://user@dummy/narrow2
   searching for changes
-  remote has heads on branch 'default' that are not known locally: d78a96df731d
-  abort: push creates new remote head 5970befb64ba!
-  (pull and merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 0 changes to 0 files
diff --git a/hgext/narrow/narrowchangegroup.py 
b/hgext/narrow/narrowchangegroup.py
--- a/hgext/narrow/narrowchangegroup.py
+++ b/hgext/narrow/narrowchangegroup.py
@@ -13,32 +13,38 @@
 error,
 extensions,
 manifest,
+match as matchmod,
 mdiff,
 node,
 revlog,
 util,
 )
 
 def setup():
 
+def _cgmatcher(cgpacker):
+localmatcher = getattr(cgpacker._repo, 'narrowmatch', lambda: None)()
+remotematcher = getattr(cgpacker, '_narrow_matcher', lambda: None)()
+if localmatcher and remotematcher:
+return matchmod.intersectmatchers(localmatcher, remotematcher)
+else:
+return localmatcher or remotematcher
+
 def prune(orig, self, revlog, missing, commonrevs):
 if isinstance(revlog, manifest.manifestrevlog):
-matcher = getattr(self._repo, 'narrowmatch',
-  getattr(self, '_narrow_matcher', None))
-if (matcher is not None and
-not matcher().visitdir(revlog._dir[:-1] or '.')):
+matcher = _cgmatcher(self)
+if (matcher and
+not matcher.visitdir(revlog._dir[:-1] or '.')):
 return []
 return orig(self, revlog, missing, commonrevs)
 
 extensions.wrapfunction(changegroup.cg1packer, 'prune', prune)
 
 def generatefiles(orig, self, changedfiles, linknodes, commonrevs,
   source):
-matcher = getattr(self._repo, 'narrowmatch',
-  getattr(self, '_narrow_matcher', None))
-if matcher is not None:
-narrowmatch = matcher()
-changedfiles = [f for f in changedfiles if narrowmatch(f)]
+matcher = _cgmatcher(self)
+if matcher:
+changedfiles = filter(matcher, changedfiles)
 if getattr(self, 'is_shallow', False):
 # See comment in generate() for why this sadness is a thing.
 mfdicts = self._mfdicts



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


D2494: narrow: move narrowmatch-related methods to localrepo

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG759a79ce785e: narrow: move narrowmatch-related methods to 
localrepo (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2494?vs=6194=6228

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

AFFECTED FILES
  hgext/narrow/narrowrepo.py
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -43,6 +43,7 @@
 merge as mergemod,
 mergeutil,
 namespaces,
+narrowspec,
 obsolete,
 pathutil,
 peer,
@@ -736,6 +737,37 @@
" working parent %s!\n") % short(node))
 return nullid
 
+@repofilecache(narrowspec.FILENAME)
+def narrowpats(self):
+"""matcher patterns for this repository's narrowspec
+
+A tuple of (includes, excludes).
+"""
+source = self
+if self.shared():
+from . import hg
+source = hg.sharedreposource(self)
+return narrowspec.load(source)
+
+@repofilecache(narrowspec.FILENAME)
+def _narrowmatch(self):
+if changegroup.NARROW_REQUIREMENT not in self.requirements:
+return matchmod.always(self.root, '')
+include, exclude = self.narrowpats
+return narrowspec.match(self.root, include=include, exclude=exclude)
+
+# TODO(martinvonz): make this property-like instead?
+def narrowmatch(self):
+return self._narrowmatch
+
+def setnarrowpats(self, newincludes, newexcludes):
+target = self
+if self.shared():
+from . import hg
+target = hg.sharedreposource(self)
+narrowspec.save(target, newincludes, newexcludes)
+self.invalidate(clearfilecache=True)
+
 def __getitem__(self, changeid):
 if changeid is None:
 return context.workingctx(self)
diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -12,7 +12,6 @@
 changegroup,
 hg,
 localrepo,
-match as matchmod,
 narrowspec,
 scmutil,
 )
@@ -67,35 +66,6 @@
 narrowrevlog.makenarrowfilelog(fl, self.narrowmatch())
 return fl
 
-@localrepo.repofilecache(narrowspec.FILENAME)
-def narrowpats(self):
-"""matcher patterns for this repository's narrowspec
-
-A tuple of (includes, excludes).
-"""
-source = self
-if self.shared():
-source = hg.sharedreposource(self)
-return narrowspec.load(source)
-
-@localrepo.repofilecache(narrowspec.FILENAME)
-def _narrowmatch(self):
-if changegroup.NARROW_REQUIREMENT not in self.requirements:
-return matchmod.always(self.root, '')
-include, exclude = self.narrowpats
-return narrowspec.match(self.root, include=include, 
exclude=exclude)
-
-# TODO(martinvonz): make this property-like instead?
-def narrowmatch(self):
-return self._narrowmatch
-
-def setnarrowpats(self, newincludes, newexcludes):
-target = self
-if self.shared():
-target = hg.sharedreposource(self)
-narrowspec.save(target, newincludes, newexcludes)
-self.invalidate(clearfilecache=True)
-
 # I'm not sure this is the right place to do this filter.
 # context._manifestmatches() would probably be better, or perhaps
 # move it to a later place, in case some of the callers do want to know



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


D2493: narrow: remove dependency from narrowspec module to hg module

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0abed045d325: narrow: remove dependency from narrowspec 
module to hg module (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2493?vs=6193=6226

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

AFFECTED FILES
  hgext/narrow/narrowrepo.py
  mercurial/narrowspec.py

CHANGE DETAILS

diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -12,7 +12,6 @@
 from .i18n import _
 from . import (
 error,
-hg,
 match as matchmod,
 util,
 )
@@ -129,8 +128,6 @@
 return [i for i in includes if i.startswith('include:')]
 
 def load(repo):
-if repo.shared():
-repo = hg.sharedreposource(repo)
 try:
 spec = repo.vfs.read(FILENAME)
 except IOError as e:
@@ -146,8 +143,6 @@
 
 def save(repo, includepats, excludepats):
 spec = format(includepats, excludepats)
-if repo.shared():
-repo = hg.sharedreposource(repo)
 repo.vfs.write(FILENAME, spec)
 
 def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes):
diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -73,7 +73,10 @@
 
 A tuple of (includes, excludes).
 """
-return narrowspec.load(self)
+source = self
+if self.shared():
+source = hg.sharedreposource(self)
+return narrowspec.load(source)
 
 @localrepo.repofilecache(narrowspec.FILENAME)
 def _narrowmatch(self):
@@ -87,7 +90,10 @@
 return self._narrowmatch
 
 def setnarrowpats(self, newincludes, newexcludes):
-narrowspec.save(self, newincludes, newexcludes)
+target = self
+if self.shared():
+target = hg.sharedreposource(self)
+narrowspec.save(target, newincludes, newexcludes)
 self.invalidate(clearfilecache=True)
 
 # I'm not sure this is the right place to do this filter.



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


D2491: narrow: always wrap repo

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd0baa181342a: narrow: always wrap repo (authored by 
martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2491?vs=6191=6224

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

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowcommands.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -30,7 +30,6 @@
 
 from . import (
 narrowbundle2,
-narrowrepo,
 )
 
 table = {}
@@ -101,10 +100,6 @@
 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
 
 def pullnarrow(orig, repo, *args, **kwargs):
-narrowrepo.wraprepo(repo.unfiltered())
-if isinstance(repo, repoview.repoview):
-repo.__class__.__bases__ = (repo.__class__.__bases__[0],
-repo.unfiltered().__class__)
 if opts_narrow:
 repo.requirements.add(changegroup.NARROW_REQUIREMENT)
 repo._writerequirements()
diff --git a/hgext/narrow/__init__.py b/hgext/narrow/__init__.py
--- a/hgext/narrow/__init__.py
+++ b/hgext/narrow/__init__.py
@@ -72,8 +72,8 @@
 if not isinstance(repo, localrepo.localrepository):
 return
 
+narrowrepo.wraprepo(repo)
 if changegroup.NARROW_REQUIREMENT in repo.requirements:
-narrowrepo.wraprepo(repo)
 narrowcopies.setup(repo)
 narrowdirstate.setup(repo)
 narrowpatch.setup(repo)



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


D2492: narrow: reduce depedence on narrowspec.save()

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe5005ade8860: narrow: reduce depedence on narrowspec.save() 
(authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2492?vs=6192=6225

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowcommands.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -88,7 +88,7 @@
 # everything, except what they asked to exclude.
 includepats = {'path:.'}
 
-narrowspec.save(pullop.repo, includepats, excludepats)
+pullop.repo.setnarrowpats(includepats, excludepats)
 
 # This will populate 'includepats' etc with the values from the
 # narrowspec we just saved.
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -361,11 +361,10 @@
 def _handlechangespec_2(op, inpart):
 includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines())
 excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines())
-narrowspec.save(op.repo, includepats, excludepats)
 if not changegroup.NARROW_REQUIREMENT in op.repo.requirements:
 op.repo.requirements.add(changegroup.NARROW_REQUIREMENT)
 op.repo._writerequirements()
-op.repo.invalidate(clearfilecache=True)
+op.repo.setnarrowpats(includepats, excludepats)
 
 @bundle2.parthandler(_CHANGESPECPART)
 def _handlechangespec(op, inpart):



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


D2488: narrow: move changegroup.supportedoutgoingversions() override to core

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGbd947b538f0e: narrow: move 
changegroup.supportedoutgoingversions() override to core (authored by 
martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2488?vs=6188=6221

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

AFFECTED FILES
  hgext/narrow/narrowchangegroup.py
  mercurial/changegroup.py

CHANGE DETAILS

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -898,6 +898,11 @@
 # support versions 01 and 02.
 versions.discard('01')
 versions.discard('02')
+if NARROW_REQUIREMENT in repo.requirements:
+# Versions 01 and 02 don't support revlog flags, and we need to
+# support that for stripping and unbundling to work.
+versions.discard('01')
+versions.discard('02')
 return versions
 
 def localversion(repo):
diff --git a/hgext/narrow/narrowchangegroup.py 
b/hgext/narrow/narrowchangegroup.py
--- a/hgext/narrow/narrowchangegroup.py
+++ b/hgext/narrow/narrowchangegroup.py
@@ -21,16 +21,6 @@
 
 def setup():
 
-def supportedoutgoingversions(orig, repo):
-versions = orig(repo)
-if changegroup.NARROW_REQUIREMENT in repo.requirements:
-versions.discard('01')
-versions.discard('02')
-return versions
-
-extensions.wrapfunction(changegroup, 'supportedoutgoingversions',
-supportedoutgoingversions)
-
 def prune(orig, self, revlog, missing, commonrevs):
 if isinstance(revlog, manifest.manifestrevlog):
 matcher = getattr(self._repo, 'narrowmatch',



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


D2494: narrow: move narrowmatch-related methods to localrepo

2018-02-28 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  I know we're trying to remove methods from `localrepository` so it is 
smaller. `narrowpats` and `_narrowmatch` need to be there because of 
`@repofilecache`. And `narrowmatch` is the thing we want to add to 
`localrepository`. I suppose `setnarrowpats` could live outside the class. But 
we don't have a better place in core yet. So I'm going to call it scope bloat 
and something that can be deferred to a follow-up patch, if desired.

REPOSITORY
  rHG Mercurial

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

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


D2493: narrow: remove dependency from narrowspec module to hg module

2018-02-28 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added inline comments.
This revision is now accepted and ready to land.

INLINE COMMENTS

> narrowrepo.py:76-78
> +source = self
> +if self.shared():
> +source = hg.sharedreposource(self)

It feels like there could be a helper method that returns the repo object 
backing the store. But that's for another patch.

REPOSITORY
  rHG Mercurial

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

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


D2491: narrow: always wrap repo

2018-02-28 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  Yay for getting rid of `__bases__` hackery!

REPOSITORY
  rHG Mercurial

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

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


D2489: narrow: move checking for narrow requirement into _narrowmatch()

2018-02-28 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  Having the requirement imply the use of a narrow matcher seems OK to me. It 
is easy enough to change if we need something else.

REPOSITORY
  rHG Mercurial

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

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


D2487: narrow: move requirement constant to core

2018-02-28 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  I could bikeshed the location. But meh. Anywhere in core is better than 
nowhere in core.
  
  (I would have suggested repository.py)

REPOSITORY
  rHG Mercurial

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

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


[Bug 5806] New: looks like evolve commit 25155eb0 made it incompatible with core < ef3a24a023e

2018-02-28 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5806

Bug ID: 5806
   Summary: looks like evolve commit 25155eb0 made it incompatible
with core < ef3a24a023e
   Product: Mercurial
   Version: unspecified
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: evolution
  Assignee: bugzi...@mercurial-scm.org
  Reporter: martinv...@google.com
CC: mercurial-devel@mercurial-scm.org,
pierre-yves.da...@ens-lyon.org

Evolve commit introduced an unconditional import of
'mercurial.wireprotoserver', which did not exist before core commit
ef3a24a023e.

Note that you'll need to purge any wireprotoserver.pyc file when testing.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2402: stack: introduce an option to limit the selection on the current branch

2018-02-28 Thread lothiraldan (Boris Feld)
lothiraldan updated this revision to Diff 6218.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2402?vs=6016=6218

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/stack.py
  tests/test-stack.t

CHANGE DETAILS

diff --git a/tests/test-stack.t b/tests/test-stack.t
--- a/tests/test-stack.t
+++ b/tests/test-stack.t
@@ -51,6 +51,36 @@
   o  0 other draft c_a
   
 
+Check that stack show draft changesets from all branches by default
+---
+
+  $ hg log -G -r "stack()"
+  @  5 foo draft c_f
+  |
+  o  4 foo draft c_e
+  |
+  o  3 foo draft c_d
+  |
+  o  2 foo draft c_c
+  |
+  o  1 other draft c_b
+  |
+  o  0 other draft c_a
+  
+
+But not if we restrict on the branch
+
+  $ hg log -G -r "stack()" --config experimental.stack.same-branch=true
+  @  5 foo draft c_f
+  |
+  o  4 foo draft c_e
+  |
+  o  3 foo draft c_d
+  |
+  o  2 foo draft c_c
+  |
+  ~
+
 Check that stack doesn't include public changesets
 --
 
diff --git a/mercurial/stack.py b/mercurial/stack.py
--- a/mercurial/stack.py
+++ b/mercurial/stack.py
@@ -44,6 +44,10 @@
 revspecargs.append("not ::merge()")
 revspec.append("%r")
 
+if repo.ui.configbool("experimental", "stack.same-branch"):
+revspecargs.append(revsetlang.formatspec("branch(%s)", rev))
+revspec.append("%r")
+
 finalrevspec = " and ".join(revspec)
 revset = revsetlang.formatspec(finalrevspec, *revspecargs)
 revisions = scmutil.revrange(repo, [revset])
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -953,6 +953,9 @@
 coreconfigitem('stack', 'restrict-ancestors',
 default=True,
 )
+coreconfigitem('experimental', 'stack.same-branch',
+default=False,
+)
 coreconfigitem('subrepos', 'allowed',
 default=dynamicdefault,  # to make backporting simpler
 )



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


D2403: stack: remove destutil.stackbase

2018-02-28 Thread lothiraldan (Boris Feld)
lothiraldan updated this revision to Diff 6219.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2403?vs=6017=6219

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

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

CHANGE DETAILS

diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -357,10 +357,6 @@
 
 return None
 
-def stackbase(ui, repo):
-revs = stack.getstack(repo)
-return revs.first() if revs else None
-
 def _statusotherbook(ui, repo):
 bmheads = bookmarks.headsforactive(repo)
 curhead = repo[repo._activebookmark].node()
diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -35,7 +35,6 @@
 from mercurial import (
 cmdutil,
 commands,
-destutil,
 error,
 formatter,
 graphmod,
@@ -45,6 +44,7 @@
 registrar,
 revset,
 revsetlang,
+stack
 )
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' 
for
@@ -193,17 +193,17 @@
'changeset)\n'))
 return
 
-# TODO extract "find stack" into a function to facilitate
-# customization and reuse.
-
-baserev = destutil.stackbase(ui, repo)
 basectx = None
 
+_stack = stack.getstack(repo)
+baserev = _stack.first()
+
+# TODO doesn't yet handle case where wdir is a draft merge
 if baserev is None:
 baserev = wdirctx.rev()
 stackrevs = {wdirctx.rev()}
 else:
-stackrevs = set(repo.revs('%d::.', baserev))
+stackrevs = set(_stack)
 
 ctx = repo[baserev]
 if ctx.p1().rev() != nullrev:



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


D2400: stack: begin to make the stack revset configurable

2018-02-28 Thread lothiraldan (Boris Feld)
lothiraldan updated this revision to Diff 6216.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2400?vs=6014=6216

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/stack.py

CHANGE DETAILS

diff --git a/mercurial/stack.py b/mercurial/stack.py
--- a/mercurial/stack.py
+++ b/mercurial/stack.py
@@ -12,18 +12,34 @@
 scmutil,
 )
 
+baserevspec = "only(%s) and not public()"
+
 def getstack(repo, rev=None):
 """return a sorted smartrev of the stack containing either rev if it is
 not None or the current working directory parent.
 
 The stack will always contain all drafts changesets which are ancestors to
-the revision and are not merges.
+the revision.
+
+There are several config options to restrict the changesets that will be
+part of the stack:
+
+[stack]
+not-merge = (boolean) # The stack will contains only non-merge changesets
+  # if set to True (default: True)
 """
 if rev is None:
 rev = '.'
 
-revspec = 'reverse(only(%s) and not public() and not ::merge())'
-revset = revsetlang.formatspec(revspec, rev)
+revspecargs = [revsetlang.formatspec(baserevspec, rev)]
+revspec = ["%r"]
+
+if repo.ui.configbool("stack", "not-merge"):
+revspecargs.append("not ::merge()")
+revspec.append("%r")
+
+finalrevspec = " and ".join(revspec)
+revset = revsetlang.formatspec(finalrevspec, *revspecargs)
 revisions = scmutil.revrange(repo, [revset])
 revisions.sort()
 return revisions
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -947,6 +947,9 @@
 coreconfigitem('sparse', 'missingwarning',
 default=True,
 )
+coreconfigitem('stack', 'not-merge',
+default=True,
+)
 coreconfigitem('subrepos', 'allowed',
 default=dynamicdefault,  # to make backporting simpler
 )



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


D2401: stack: introduce an option to disable the restriction on ancestor

2018-02-28 Thread lothiraldan (Boris Feld)
lothiraldan updated this revision to Diff 6217.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2401?vs=6015=6217

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/stack.py

CHANGE DETAILS

diff --git a/mercurial/stack.py b/mercurial/stack.py
--- a/mercurial/stack.py
+++ b/mercurial/stack.py
@@ -12,28 +12,34 @@
 scmutil,
 )
 
-baserevspec = "only(%s) and not public()"
+baserevspec = "not public()"
 
 def getstack(repo, rev=None):
 """return a sorted smartrev of the stack containing either rev if it is
 not None or the current working directory parent.
 
-The stack will always contain all drafts changesets which are ancestors to
-the revision.
+The stack will always contain all drafts changesets.
 
 There are several config options to restrict the changesets that will be
 part of the stack:
 
 [stack]
 not-merge = (boolean) # The stack will contains only non-merge changesets
   # if set to True (default: True)
+restrict-ancestors = (boolean) # The stack will contain only the
+   # ancestors of the revision if set to True
+   # (default: True)
 """
 if rev is None:
 rev = '.'
 
-revspecargs = [revsetlang.formatspec(baserevspec, rev)]
+revspecargs = [baserevspec]
 revspec = ["%r"]
 
+if repo.ui.configbool("stack", "restrict-ancestors"):
+revspecargs.append(revsetlang.formatspec("only(%s)", rev))
+revspec.append("%r")
+
 if repo.ui.configbool("stack", "not-merge"):
 revspecargs.append("not ::merge()")
 revspec.append("%r")
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -950,6 +950,9 @@
 coreconfigitem('stack', 'not-merge',
 default=True,
 )
+coreconfigitem('stack', 'restrict-ancestors',
+default=True,
+)
 coreconfigitem('subrepos', 'allowed',
 default=dynamicdefault,  # to make backporting simpler
 )



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


D2396: stack: import Evolve stack test file

2018-02-28 Thread lothiraldan (Boris Feld)
lothiraldan updated this revision to Diff 6213.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2396?vs=6010=6213

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

AFFECTED FILES
  mercurial/revset.py
  tests/test-stack.t

CHANGE DETAILS

diff --git a/tests/test-stack.t b/tests/test-stack.t
new file mode 100644
--- /dev/null
+++ b/tests/test-stack.t
@@ -0,0 +1,253 @@
+
+This test test the low-level definition of stack, agnostic from all formatting
+
+Initial setup
+
+  $ cat << EOF >> $HGRCPATH
+  > [ui]
+  > logtemplate = {rev} {branch} {phase} {desc|firstline}\n
+  > [extensions]
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers,exchange,allowunstable
+  > EOF
+
+  $ hg init main
+  $ cd main
+  $ hg branch other
+  marked working directory as branch other
+  (branches are permanent and global, did you want a bookmark?)
+  $ echo aaa > aaa
+  $ hg add aaa
+  $ hg commit -m c_a
+  $ echo aaa > bbb
+  $ hg add bbb
+  $ hg commit -m c_b
+  $ hg branch foo
+  marked working directory as branch foo
+  $ echo aaa > ccc
+  $ hg add ccc
+  $ hg commit -m c_c
+  $ echo aaa > ddd
+  $ hg add ddd
+  $ hg commit -m c_d
+  $ echo aaa > eee
+  $ hg add eee
+  $ hg commit -m c_e
+  $ echo aaa > fff
+  $ hg add fff
+  $ hg commit -m c_f
+  $ hg log -G
+  @  5 foo draft c_f
+  |
+  o  4 foo draft c_e
+  |
+  o  3 foo draft c_d
+  |
+  o  2 foo draft c_c
+  |
+  o  1 other draft c_b
+  |
+  o  0 other draft c_a
+  
+
+Check that stack doesn't include public changesets
+--
+
+  $ hg up other
+  0 files updated, 0 files merged, 4 files removed, 0 files unresolved
+  $ hg log -G -r "stack()"
+  @  1 other draft c_b
+  |
+  o  0 other draft c_a
+  
+  $ hg phase --public 'branch("other")'
+  $ hg log -G -r "stack()"
+  $ hg up foo
+  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Simple test
+---
+
+'stack()' list all changeset in the branch
+
+  $ hg branch
+  foo
+  $ hg log -G -r "stack()"
+  @  5 foo draft c_f
+  |
+  o  4 foo draft c_e
+  |
+  o  3 foo draft c_d
+  |
+  o  2 foo draft c_c
+  |
+  ~
+
+Case with some of the branch unstable
+
+
+  $ hg up 3
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo bbb > ddd
+  $ hg commit --amend
+  2 new orphan changesets
+  $ hg log -G
+  @  6 foo draft c_d
+  |
+  | *  5 foo draft c_f
+  | |
+  | *  4 foo draft c_e
+  | |
+  | x  3 foo draft c_d
+  |/
+  o  2 foo draft c_c
+  |
+  o  1 other public c_b
+  |
+  o  0 other public c_a
+  
+  $ hg log -G -r "stack()"
+  @  6 foo draft c_d
+  |
+  ~
+  $ hg up -r "desc(c_e)"
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg log -G -r "stack()"
+  @  4 foo draft c_e
+  |
+  x  3 foo draft c_d
+  |
+  ~
+  $ hg up -r "desc(c_d)"
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+
+  $ hg log -G -r "stack()"
+  @  6 foo draft c_d
+  |
+  ~
+
+Case with multiple topological heads
+
+
+Make things linear again
+
+  $ hg rebase -s 'desc(c_e)' -d 'desc(c_d) - obsolete()'
+  rebasing 4:4f2a69f6d380 "c_e"
+  rebasing 5:913c298d8b0a "c_f"
+  $ hg log -G
+  o  8 foo draft c_f
+  |
+  o  7 foo draft c_e
+  |
+  @  6 foo draft c_d
+  |
+  o  2 foo draft c_c
+  |
+  o  1 other public c_b
+  |
+  o  0 other public c_a
+  
+
+Create the second branch
+
+  $ hg up 'desc(c_d)'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo aaa > ggg
+  $ hg add ggg
+  $ hg commit -m c_g
+  created new head
+  $ echo aaa > hhh
+  $ hg add hhh
+  $ hg commit -m c_h
+  $ hg log -G
+  @  10 foo draft c_h
+  |
+  o  9 foo draft c_g
+  |
+  | o  8 foo draft c_f
+  | |
+  | o  7 foo draft c_e
+  |/
+  o  6 foo draft c_d
+  |
+  o  2 foo draft c_c
+  |
+  o  1 other public c_b
+  |
+  o  0 other public c_a
+  
+
+Test output
+
+  $ hg log -G -r "stack(10)"
+  @  10 foo draft c_h
+  |
+  o  9 foo draft c_g
+  |
+  ~
+  $ hg log -G -r "stack(8)"
+  o  8 foo draft c_f
+  |
+  o  7 foo draft c_e
+  |
+  ~
+  $ hg log -G -r "stack(head())"
+  @  10 foo draft c_h
+  |
+  o  9 foo draft c_g
+  |
+  ~
+  o  8 foo draft c_f
+  |
+  o  7 foo draft c_e
+  |
+  ~
+Check the stack order
+  $ hg log -r "first(stack())"
+  10 foo draft c_h
+  $ hg log -r "first(stack(10))"
+  10 foo draft c_h
+  $ hg log -r "first(stack(8))"
+  8 foo draft c_f
+  $ hg log -r "first(stack(head()))"
+  8 foo draft c_f
+
+Case with multiple heads with unstability involved
+--
+
+We amend the message to make sure the display base pick the right changeset
+
+  $ hg up 'desc(c_d)'
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo ccc > ddd
+  $ hg commit --amend -m 'c_D'
+  4 new orphan changesets
+  $ hg rebase -d . -s 'desc(c_g)'
+  rebasing 9:2ebb6e48ab8a "c_g"
+  rebasing 10:634f38e27a1d "c_h"
+  $ hg 

D2398: histedit: use the new stack definition for histedit

2018-02-28 Thread lothiraldan (Boris Feld)
lothiraldan updated this revision to Diff 6214.
Herald added a reviewer: durin42.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2398?vs=6012=6214

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

AFFECTED FILES
  hgext/histedit.py
  mercurial/destutil.py

CHANGE DETAILS

diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -340,18 +340,20 @@
 onheadcheck=onheadcheck, destspace=destspace)
 return repo[node].rev()
 
-histeditdefaultrevset = 'reverse(only(.) and not public() and not ::merge())'
-
 def desthistedit(ui, repo):
 """Default base revision to edit for `hg histedit`."""
-default = ui.config('histedit', 'defaultrev', histeditdefaultrevset)
-if default:
+default = ui.config('histedit', 'defaultrev')
+
+if default is None:
+revs = stack.getstack(repo)
+elif default:
 revs = scmutil.revrange(repo, [default])
-if revs:
-# The revset supplied by the user may not be in ascending order nor
-# take the first revision. So do this manually.
-revs.sort()
-return revs.first()
+
+if revs:
+# The revset supplied by the user may not be in ascending order nor
+# take the first revision. So do this manually.
+revs.sort()
+return revs.first()
 
 return None
 
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -221,7 +221,7 @@
 default=False,
 )
 configitem('histedit', 'defaultrev',
-default=configitem.dynamicdefault,
+default=None,
 )
 configitem('histedit', 'dropmissing',
 default=False,



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


D2399: stack: return a sorted smartrev by default

2018-02-28 Thread lothiraldan (Boris Feld)
lothiraldan updated this revision to Diff 6215.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2399?vs=6013=6215

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

AFFECTED FILES
  mercurial/destutil.py
  mercurial/stack.py
  tests/test-stack.t

CHANGE DETAILS

diff --git a/tests/test-stack.t b/tests/test-stack.t
--- a/tests/test-stack.t
+++ b/tests/test-stack.t
@@ -205,13 +205,13 @@
   ~
 Check the stack order
   $ hg log -r "first(stack())"
-  10 foo draft c_h
+  9 foo draft c_g
   $ hg log -r "first(stack(10))"
-  10 foo draft c_h
+  9 foo draft c_g
   $ hg log -r "first(stack(8))"
-  8 foo draft c_f
+  7 foo draft c_e
   $ hg log -r "first(stack(head()))"
-  8 foo draft c_f
+  7 foo draft c_e
 
 Case with multiple heads with unstability involved
 --
diff --git a/mercurial/stack.py b/mercurial/stack.py
--- a/mercurial/stack.py
+++ b/mercurial/stack.py
@@ -13,8 +13,8 @@
 )
 
 def getstack(repo, rev=None):
-"""return a smartrev of the stack containing either rev if it is not None
-or the current working directory parent.
+"""return a sorted smartrev of the stack containing either rev if it is
+not None or the current working directory parent.
 
 The stack will always contain all drafts changesets which are ancestors to
 the revision and are not merges.
@@ -24,4 +24,6 @@
 
 revspec = 'reverse(only(%s) and not public() and not ::merge())'
 revset = revsetlang.formatspec(revspec, rev)
-return scmutil.revrange(repo, [revset])
+revisions = scmutil.revrange(repo, [revset])
+revisions.sort()
+return revisions
diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -359,7 +359,7 @@
 
 def stackbase(ui, repo):
 revs = stack.getstack(repo)
-return revs.last() if revs else None
+return revs.first() if revs else None
 
 def _statusotherbook(ui, repo):
 bmheads = bookmarks.headsforactive(repo)



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


D2395: stack: add a new module for stack-related commands

2018-02-28 Thread lothiraldan (Boris Feld)
lothiraldan updated this revision to Diff 6212.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2395?vs=6009=6212

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

AFFECTED FILES
  mercurial/stack.py

CHANGE DETAILS

diff --git a/mercurial/stack.py b/mercurial/stack.py
new file mode 100644
--- /dev/null
+++ b/mercurial/stack.py
@@ -0,0 +1,27 @@
+# stack.py - Mercurial functions for stack definition
+#
+#  Copyright Matt Mackall  and other
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+from __future__ import absolute_import
+
+from . import (
+revsetlang,
+scmutil,
+)
+
+def getstack(repo, rev=None):
+"""return a smartrev of the stack containing either rev if it is not None
+or the current working directory parent.
+
+The stack will always contain all drafts changesets which are ancestors to
+the revision and are not merges.
+"""
+if rev is None:
+rev = '.'
+
+revspec = 'reverse(only(%s) and not public() and not ::merge())'
+revset = revsetlang.formatspec(revspec, rev)
+return scmutil.revrange(repo, [revset])



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


D2511: py3: add 14 new passing tests to whitelist

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit 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/D2511

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -17,6 +17,7 @@
 test-branch-tag-confict.t
 test-bundle-phases.t
 test-bundle-vs-outgoing.t
+test-bundle2-multiple-changegroups.t
 test-cappedreader.py
 test-casecollision.t
 test-cat.t
@@ -44,6 +45,7 @@
 test-copy-move-merge.t
 test-copytrace-heuristics.t
 test-debugbuilddag.t
+test-debugbundle.t
 test-debugindexdot.t
 test-debugrename.t
 test-diff-binary-file.t
@@ -101,6 +103,7 @@
 test-fileset-generated.t
 test-flags.t
 test-generaldelta.t
+test-getbundle.t
 test-git-export.t
 test-glog-topological.t
 test-gpg.t
@@ -112,6 +115,7 @@
 test-histedit-drop.t
 test-histedit-edit.t
 test-histedit-fold-non-commute.t
+test-histedit-fold.t
 test-histedit-no-change.t
 test-histedit-non-commute.t
 test-histedit-obsolete.t
@@ -158,6 +162,7 @@
 test-merge-revert.t
 test-merge-revert2.t
 test-merge-subrepos.t
+test-merge-symlinks.t
 test-merge1.t
 test-merge10.t
 test-merge2.t
@@ -185,6 +190,7 @@
 test-narrow-pull.t
 test-narrow-rebase.t
 test-narrow-shallow-merges.t
+test-narrow-shallow.t
 test-narrow-update.t
 test-newbranch.t
 test-obshistory.t
@@ -194,7 +200,9 @@
 test-obsolete-checkheads.t
 test-obsolete-distributed.t
 test-parents.t
+test-pending.t
 test-permissions.t
+test-phases.t
 test-pull-branch.t
 test-pull-http.t
 test-pull-permission.t
@@ -230,11 +238,15 @@
 test-push-checkheads-unpushed-D7.t
 test-push-http.t
 test-push-warn.t
+test-pushvars.t
+test-rebase-base-flag.t
 test-rebase-bookmarks.t
+test-rebase-brute-force.t
 test-rebase-check-restore.t
 test-rebase-dest.t
 test-rebase-emptycommit.t
 test-rebase-inmemory.t
+test-rebase-interruptions.t
 test-rebase-issue-noparam-single-rev.t
 test-rebase-legacy.t
 test-rebase-named-branches.t
@@ -244,6 +256,7 @@
 test-rebase-rename.t
 test-rebase-transaction.t
 test-record.t
+test-relink.t
 test-remove.t
 test-rename-after-merge.t
 test-rename-dir-merge.t
@@ -253,6 +266,7 @@
 test-repo-compengines.t
 test-revert-flags.t
 test-revert-unknown.t
+test-revlog-ancestry.py
 test-revlog-group-emptyiter.t
 test-revlog-mmapindex.t
 test-revlog-packentry.t



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


D2509: py3: add b'' prefix in tests/test-revlog-v2.t

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  After this, the test works on Python 3. There is some extra return value by
  open().write() I think which needs to be handled.
  
  1. skip-blame because just b'' prefix

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-revlog-v2.t

CHANGE DETAILS

diff --git a/tests/test-revlog-v2.t b/tests/test-revlog-v2.t
--- a/tests/test-revlog-v2.t
+++ b/tests/test-revlog-v2.t
@@ -29,7 +29,7 @@
 Unknown flags to revlog are rejected
 
   >>> with open('.hg/store/00changelog.i', 'wb') as fh:
-  ... fh.write('\x00\x04\xde\xad')
+  ... fh.write(b'\x00\x04\xde\xad')
 
   $ hg log
   abort: unknown flags (0x04) in version 57005 revlog 00changelog.i!



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


D2510: py3: add b'' prefixes in tests/test-rollback.t

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This makes the test run succesfully on Python 3. There is just a b'' prefix
  extra in the output.
  
  1. skip-blame because we added just b'' prefixes

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-rollback.t

CHANGE DETAILS

diff --git a/tests/test-rollback.t b/tests/test-rollback.t
--- a/tests/test-rollback.t
+++ b/tests/test-rollback.t
@@ -228,21 +228,21 @@
   > configtable = {}
   > configitem = registrar.configitem(configtable)
   > 
-  > configitem('ui', 'ioerrors',
+  > configitem(b'ui', b'ioerrors',
   > default=list,
   > )
   > 
   > def pretxncommit(ui, repo, **kwargs):
-  > ui.warn('warn during pretxncommit\n')
+  > ui.warn(b'warn during pretxncommit\n')
   > 
   > def pretxnclose(ui, repo, **kwargs):
-  > ui.warn('warn during pretxnclose\n')
+  > ui.warn(b'warn during pretxnclose\n')
   > 
   > def txnclose(ui, repo, **kwargs):
-  > ui.warn('warn during txnclose\n')
+  > ui.warn(b'warn during txnclose\n')
   > 
   > def txnabort(ui, repo, **kwargs):
-  > ui.warn('warn during abort\n')
+  > ui.warn(b'warn during abort\n')
   > 
   > class fdproxy(object):
   > def __init__(self, ui, o):
@@ -253,25 +253,25 @@
   > return getattr(self._o, attr)
   > 
   > def write(self, msg):
-  > errors = set(self._ui.configlist('ui', 'ioerrors'))
-  > pretxncommit = msg == 'warn during pretxncommit\n'
-  > pretxnclose = msg == 'warn during pretxnclose\n'
-  > txnclose = msg == 'warn during txnclose\n'
-  > txnabort = msg == 'warn during abort\n'
-  > msgabort = msg == _('transaction abort!\n')
-  > msgrollback = msg == _('rollback completed\n')
+  > errors = set(self._ui.configlist(b'ui', b'ioerrors'))
+  > pretxncommit = msg == b'warn during pretxncommit\n'
+  > pretxnclose = msg == b'warn during pretxnclose\n'
+  > txnclose = msg == b'warn during txnclose\n'
+  > txnabort = msg == b'warn during abort\n'
+  > msgabort = msg == _(b'transaction abort!\n')
+  > msgrollback = msg == _(b'rollback completed\n')
   > 
-  > if pretxncommit and 'pretxncommit' in errors:
+  > if pretxncommit and b'pretxncommit' in errors:
   > raise IOError(errno.EPIPE, 'simulated epipe')
-  > if pretxnclose and 'pretxnclose' in errors:
+  > if pretxnclose and b'pretxnclose' in errors:
   > raise IOError(errno.EIO, 'simulated eio')
-  > if txnclose and 'txnclose' in errors:
+  > if txnclose and b'txnclose' in errors:
   > raise IOError(errno.EBADF, 'simulated badf')
-  > if txnabort and 'txnabort' in errors:
+  > if txnabort and b'txnabort' in errors:
   > raise IOError(errno.EPIPE, 'simulated epipe')
-  > if msgabort and 'msgabort' in errors:
+  > if msgabort and b'msgabort' in errors:
   > raise IOError(errno.EBADF, 'simulated ebadf')
-  > if msgrollback and 'msgrollback' in errors:
+  > if msgrollback and b'msgrollback' in errors:
   > raise IOError(errno.EIO, 'simulated eio')
   > 
   > return self._o.write(msg)
@@ -289,10 +289,10 @@
   > ui.__class__ = badui
   > 
   > def reposetup(ui, repo):
-  > ui.setconfig('hooks', 'pretxnclose.badui', pretxnclose, 'badui')
-  > ui.setconfig('hooks', 'txnclose.badui', txnclose, 'badui')
-  > ui.setconfig('hooks', 'pretxncommit.badui', pretxncommit, 'badui')
-  > ui.setconfig('hooks', 'txnabort.badui', txnabort, 'badui')
+  > ui.setconfig(b'hooks', b'pretxnclose.badui', pretxnclose, b'badui')
+  > ui.setconfig(b'hooks', b'txnclose.badui', txnclose, b'badui')
+  > ui.setconfig(b'hooks', b'pretxncommit.badui', pretxncommit, b'badui')
+  > ui.setconfig(b'hooks', b'txnabort.badui', txnabort, b'badui')
   > EOF
 
   $ cat >> $HGRCPATH << EOF



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


D2506: py3: add b'' prefixes in tests/test-revlog-ancestry.py

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  1. skip-blame because just b'' prefixes

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-revlog-ancestry.py

CHANGE DETAILS

diff --git a/tests/test-revlog-ancestry.py b/tests/test-revlog-ancestry.py
--- a/tests/test-revlog-ancestry.py
+++ b/tests/test-revlog-ancestry.py
@@ -8,15 +8,15 @@
 
 u = uimod.ui.load()
 
-repo = hg.repository(u, 'test1', create=1)
+repo = hg.repository(u, b'test1', create=1)
 os.chdir('test1')
 
 def commit(text, time):
-repo.commit(text=text, date="%d 0" % time)
+repo.commit(text=text, date=b"%d 0" % time)
 
 def addcommit(name, time):
 f = open(name, 'w')
-f.write('%s\n' % name)
+f.write(b'%s\n' % name)
 f.close()
 repo[None].add([name])
 commit(name, time)
@@ -28,27 +28,27 @@
 merge.update(repo, rev, True, False)
 
 if __name__ == '__main__':
-addcommit("A", 0)
-addcommit("B", 1)
+addcommit(b"A", 0)
+addcommit(b"B", 1)
 
 update(0)
-addcommit("C", 2)
+addcommit(b"C", 2)
 
 merge_(1)
-commit("D", 3)
+commit(b"D", 3)
 
 update(2)
-addcommit("E", 4)
-addcommit("F", 5)
+addcommit(b"E", 4)
+addcommit(b"F", 5)
 
 update(3)
-addcommit("G", 6)
+addcommit(b"G", 6)
 
 merge_(5)
-commit("H", 7)
+commit(b"H", 7)
 
 update(5)
-addcommit("I", 8)
+addcommit(b"I", 8)
 
 # Ancestors
 print('Ancestors of 5')



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


D2508: py3: add b'' prefixes in tests/test-revlog.t

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  1. skip-blame because just b'' prefixes

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-revlog.t

CHANGE DETAILS

diff --git a/tests/test-revlog.t b/tests/test-revlog.t
--- a/tests/test-revlog.t
+++ b/tests/test-revlog.t
@@ -4,25 +4,25 @@
 Flags on revlog version 0 are rejected
 
   >>> with open('.hg/store/00changelog.i', 'wb') as fh:
-  ... fh.write('\x00\x01\x00\x00')
+  ... fh.write(b'\x00\x01\x00\x00')
 
   $ hg log
   abort: unknown flags (0x01) in version 0 revlog 00changelog.i!
   [255]
 
 Unknown flags on revlog version 1 are rejected
 
   >>> with open('.hg/store/00changelog.i', 'wb') as fh:
-  ... fh.write('\x00\x04\x00\x01')
+  ... fh.write(b'\x00\x04\x00\x01')
 
   $ hg log
   abort: unknown flags (0x04) in version 1 revlog 00changelog.i!
   [255]
 
 Unknown version is rejected
 
   >>> with open('.hg/store/00changelog.i', 'wb') as fh:
-  ... fh.write('\x00\x00\x00\x02')
+  ... fh.write(b'\x00\x00\x00\x02')
 
   $ hg log
   abort: unknown version (2) in revlog 00changelog.i!
@@ -34,8 +34,8 @@
 
   $ hg init
 
-  >>> open("a.i", "w").write(
-  ... 
"""eJxjYGZgZIAAYQYGxhgom+k/FMx8YKx9ZUaKSOyqo4cnuKb8mbqHV5cBCVTMWb1Cwqkhe4Gsg9AD
+  >>> open("a.i", "wb").write(
+  ... 
b"""eJxjYGZgZIAAYQYGxhgom+k/FMx8YKx9ZUaKSOyqo4cnuKb8mbqHV5cBCVTMWb1Cwqkhe4Gsg9AD
   ... 
Joa3dYtcYYYBAQ8Qr4OqZAYRICPTSr5WKd/42rV36d+8/VmrNpv7NP1jQAXrQE4BqQUARngwVA=="""
   ... .decode("base64").decode("zlib"))
 



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


D2507: py3: make sure we open the file in bytes mode

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This makes the test pass on Python 3.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-revlog-ancestry.py

CHANGE DETAILS

diff --git a/tests/test-revlog-ancestry.py b/tests/test-revlog-ancestry.py
--- a/tests/test-revlog-ancestry.py
+++ b/tests/test-revlog-ancestry.py
@@ -15,7 +15,7 @@
 repo.commit(text=text, date=b"%d 0" % time)
 
 def addcommit(name, time):
-f = open(name, 'w')
+f = open(name, 'wb')
 f.write(b'%s\n' % name)
 f.close()
 repo[None].add([name])



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


D2498: py3: use pycompat.bytestr to convert str to bytes

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit 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/D2498

AFFECTED FILES
  mercurial/exchange.py

CHANGE DETAILS

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -2258,6 +2258,7 @@
 ui.warn(_('HTTP error fetching bundle: %s\n') %
 util.forcebytestr(e))
 except urlerr.urlerror as e:
-ui.warn(_('error fetching bundle: %s\n') % e.reason)
+ui.warn(_('error fetching bundle: %s\n') %
+pycompat.bytestr(e.reason))
 
 return False



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


D2502: py3: use '%d' for integers instead of b'%s'

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit 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/D2502

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1036,7 +1036,7 @@
 return nullrev
 if len(parents) == 1:
 return parents.pop()
-raise error.Abort(_('unable to collapse on top of %s, there is more '
+raise error.Abort(_('unable to collapse on top of %d, there is more '
'than one external parent: %s') %
  (max(destancestors),
   ', '.join("%d" % p for p in sorted(parents



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


D2496: py3: slice over bytes or use startswith() to prevent getting ascii values

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit 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/D2496

AFFECTED FILES
  mercurial/commands.py
  mercurial/fileset.py

CHANGE DETAILS

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -392,7 +392,7 @@
 elif expr.startswith(">"):
 a = util.sizetoint(expr[1:])
 return lambda x: x > a
-elif expr[0].isdigit or expr[0] == '.':
+elif expr[0:1].isdigit or expr.startswith('.'):
 a = util.sizetoint(expr)
 b = _sizetomax(expr)
 return lambda x: x >= a and x <= b
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4482,7 +4482,7 @@
 for f in ms:
 if not m(f):
 continue
-flags = ''.join(['-%s ' % o[0] for o in flaglist
+flags = ''.join(['-%s ' % o[0:1] for o in flaglist
if opts.get(o)])
 hint = _("(try: hg resolve %s%s)\n") % (
  flags,



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


D2504: py3: backout changeset 56635c506608 which wrongly added couple of b''

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I am not sure what I was thinking when I added that but while fixing rebase
  tests, I revisited the file and found that I did wrong. I am sorry for this.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/fakemergerecord.py

CHANGE DETAILS

diff --git a/tests/fakemergerecord.py b/tests/fakemergerecord.py
--- a/tests/fakemergerecord.py
+++ b/tests/fakemergerecord.py
@@ -19,8 +19,8 @@
 with repo.wlock():
 ms = merge.mergestate.read(repo)
 records = ms._makerecords()
-if opts.get(b'mandatory'):
+if opts.get('mandatory'):
 records.append((b'X', b'mandatory record'))
-if opts.get(b'advisory'):
+if opts.get('advisory'):
 records.append((b'x', b'advisory record'))
 ms._writerecords(records)



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


D2501: py3: make sure we write in mergestate in bytes mode

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit 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/D2501

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -399,7 +399,7 @@
 
 def _writerecordsv1(self, records):
 """Write current state on disk in a version 1 file"""
-f = self._repo.vfs(self.statepathv1, 'w')
+f = self._repo.vfs(self.statepathv1, 'wb')
 irecords = iter(records)
 lrecords = next(irecords)
 assert lrecords[0] == 'L'
@@ -415,7 +415,7 @@
 See the docstring for _readrecordsv2 for why we use 't'."""
 # these are the records that all version 2 clients can read
 whitelist = 'LOF'
-f = self._repo.vfs(self.statepathv2, 'w')
+f = self._repo.vfs(self.statepathv2, 'wb')
 for key, data in records:
 assert len(key) == 1
 if key not in whitelist:



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


D2503: py3: add a missing b'' in tests/bruterebase.py

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit 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/D2503

AFFECTED FILES
  tests/bruterebase.py

CHANGE DETAILS

diff --git a/tests/bruterebase.py b/tests/bruterebase.py
--- a/tests/bruterebase.py
+++ b/tests/bruterebase.py
@@ -65,7 +65,7 @@
 desc += getdesc(prev)
 descs.append(desc)
 descs.sort()
-summary = ' '.join(descs)
+summary = b' '.join(descs)
 ui.popbuffer()
 repo.vfs.tryunlink(b'rebasestate')
 



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


D2505: py3: port the markdirver extension in tests/test-resolve.t

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit 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/D2505

AFFECTED FILES
  tests/test-resolve.t

CHANGE DETAILS

diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -85,24 +85,25 @@
 
   $ cat > $TESTTMP/markdriver.py << EOF
   > '''mark and unmark files as driver-resolved'''
-  > from mercurial import merge, registrar, scmutil
+  > from mercurial import merge, registrar, scmutil, pycompat
   > cmdtable = {}
   > command = registrar.command(cmdtable)
   > @command(b'markdriver',
-  >   [('u', 'unmark', None, '')],
-  >   'FILE...')
+  >   [(b'u', b'unmark', None, b'')],
+  >   b'FILE...')
   > def markdriver(ui, repo, *pats, **opts):
   > wlock = repo.wlock()
+  > opts = pycompat.byteskwargs(opts)
   > try:
   > ms = merge.mergestate.read(repo)
   > m = scmutil.match(repo[None], pats, opts)
   > for f in ms:
   > if not m(f):
   > continue
-  > if not opts['unmark']:
-  > ms.mark(f, 'd')
+  > if not opts[b'unmark']:
+  > ms.mark(f, b'd')
   > else:
-  > ms.mark(f, 'u')
+  > ms.mark(f, b'u')
   > ms.commit()
   > finally:
   > wlock.release()



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


D2499: py3: replace str() calls with their preferred bytes equivalent

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit 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/D2499

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -919,7 +919,7 @@
 dest = scmutil.revsingle(repo, destf)
 else:
 dest = repo[_destrebase(repo, base, destspace=destspace)]
-destf = str(dest)
+destf = bytes(dest)
 
 roots = [] # selected children of branching points
 bpbase = {} # {branchingpoint: [origbase]}
@@ -951,15 +951,15 @@
 ui.status(_('nothing to rebase - "base" %s is '
 'already an ancestor of destination '
 '%s\n') %
-  ('+'.join(str(repo[r]) for r in base),
+  ('+'.join(bytes(repo[r]) for r in base),
dest))
 else:
 ui.status(_('nothing to rebase - working '
 'directory parent is already an '
 'ancestor of destination %s\n') % dest)
 else: # can it happen?
 ui.status(_('nothing to rebase from %s to %s\n') %
-  ('+'.join(str(repo[r]) for r in base), dest))
+  ('+'.join(bytes(repo[r]) for r in base), dest))
 return None
 # If rebasing the working copy parent, force in-memory merge to be off.
 #
@@ -981,7 +981,7 @@
 
 if not destf:
 dest = repo[_destrebase(repo, rebaseset, destspace=destspace)]
-destf = str(dest)
+destf = bytes(dest)
 
 allsrc = revsetlang.formatspec('%ld', rebaseset)
 alias = {'ALLSRC': allsrc}
@@ -1039,7 +1039,7 @@
 raise error.Abort(_('unable to collapse on top of %s, there is more '
'than one external parent: %s') %
  (max(destancestors),
-  ', '.join(str(p) for p in sorted(parents
+  ', '.join("%d" % p for p in sorted(parents
 
 def concludememorynode(repo, rev, p1, p2, wctx=None,
commitmsg=None, editor=None, extrafn=None,
@@ -1233,7 +1233,7 @@
 divergencebasecandidates = rebaseobsrevs - rebaseobsskipped
 
 if divergencebasecandidates and not divergenceok:
-divhashes = (str(repo[r])
+divhashes = (bytes(repo[r])
  for r in divergencebasecandidates)
 msg = _("this rebase will cause "
 "divergences from: %s")
@@ -1470,10 +1470,10 @@
 for rev in sorted(mqrebase, reverse=True):
 if rev not in skipped:
 name, isgit = mqrebase[rev]
-repo.ui.note(_('updating mq patch %s to %s:%s\n') %
+repo.ui.note(_('updating mq patch %s to %d:%s\n') %
  (name, state[rev], repo[state[rev]]))
 mq.qimport(repo, (), patchname=name, git=isgit,
-rev=[str(state[rev])])
+rev=["%d" % state[rev]])
 else:
 # Rebased and skipped
 skippedpatches.add(mqrebase[rev][0])
@@ -1554,7 +1554,7 @@
 cleanup = True
 if immutable:
 repo.ui.warn(_("warning: can't clean up public changesets %s\n")
-% ', '.join(str(repo[r]) for r in immutable),
+% ', '.join(bytes(repo[r]) for r in immutable),
 hint=_("see 'hg help phases' for details"))
 cleanup = False
 



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


D2500: py3: add b'' prefixes in tests/test-rebase-scenario-global.t

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  1. skip-blame because just b'' prefixes

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-rebase-scenario-global.t

CHANGE DETAILS

diff --git a/tests/test-rebase-scenario-global.t 
b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -954,14 +954,14 @@
   > def _rebase(orig, ui, repo, *args, **kwargs):
   > with repo.wlock():
   > with repo.lock():
-  > with repo.transaction('wrappedrebase'):
+  > with repo.transaction(b'wrappedrebase'):
   > return orig(ui, repo, *args, **kwargs)
   > def wraprebase(loaded):
   > assert loaded
-  > rebasemod = extensions.find('rebase')
-  > extensions.wrapcommand(rebasemod.cmdtable, 'rebase', _rebase)
+  > rebasemod = extensions.find(b'rebase')
+  > extensions.wrapcommand(rebasemod.cmdtable, b'rebase', _rebase)
   > def extsetup(ui):
-  > extensions.afterloaded('rebase', wraprebase)
+  > extensions.afterloaded(b'rebase', wraprebase)
   > EOF
 
   $ cat >> .hg/hgrc 

D2497: py3: convert error messages to bytes using util.forcebytestr()

2018-02-28 Thread pulkit (Pulkit Goyal)
pulkit 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/D2497

AFFECTED FILES
  mercurial/branchmap.py

CHANGE DETAILS

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -520,7 +520,7 @@
 self._rbcrevslen = revs
 except (IOError, OSError, error.Abort, error.LockError) as inst:
 repo.ui.debug("couldn't write revision branch cache%s: %s\n"
-  % (step, inst))
+  % (step, util.forcebytestr(inst)))
 finally:
 if wlock is not None:
 wlock.release()



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


mercurial@36442: 4 new changesets

2018-02-28 Thread Mercurial Commits
4 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/02cd2fb6de72
changeset:   36439:02cd2fb6de72
user:Yuya Nishihara 
date:Sun Feb 25 13:42:51 2018 +0900
summary: narrow: drop redundant templatekw/revset names from help text

https://www.mercurial-scm.org/repo/hg/rev/bb852a525633
changeset:   36440:bb852a525633
user:Yuya Nishihara 
date:Sun Feb 25 16:40:41 2018 +0900
summary: remotenames: drop redundant templatekw names from help text

https://www.mercurial-scm.org/repo/hg/rev/27cd83152d31
changeset:   36441:27cd83152d31
user:Yuya Nishihara 
date:Sun Feb 25 14:12:34 2018 +0900
summary: templatekw: simply override {graphwidth} function by mapping 
variable

https://www.mercurial-scm.org/repo/hg/rev/e46b24582fa0
changeset:   36442:e46b24582fa0
bookmark:@
tag: tip
user:Yuya Nishihara 
date:Sun Feb 25 14:14:33 2018 +0900
summary: templatekw: minimize resource dependency of {envvars} and 
{termwidth}

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


D2487: narrow: move requirement constant to core

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  My short-term goal is to move narrowrepo.narrowmatch() onto localrepo
  and this is a necessary step for that.
  
  I put the constant in changegroup.py, unlike REVLOGV2_REQUIREMENT,
  which is in localrepo.py, since we'll need to access it from the
  changegroup module eventually.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowchangegroup.py
  hgext/narrow/narrowcommands.py
  hgext/narrow/narrowrepo.py
  mercurial/changegroup.py

CHANGE DETAILS

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -32,6 +32,10 @@
 _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s"
 _CHANGEGROUPV3_DELTA_HEADER = ">20s20s20s20s20sH"
 
+# When narrowing is finalized and no longer subject to format changes,
+# we should move this to just "narrow" or similar.
+NARROW_REQUIREMENT = 'narrowhg-experimental'
+
 readexactly = util.readexactly
 
 def getchunk(stream):
diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -9,6 +9,7 @@
 
 from mercurial import (
 bundlerepo,
+changegroup,
 hg,
 localrepo,
 match as matchmod,
@@ -20,19 +21,15 @@
 narrowrevlog,
 )
 
-# When narrowing is finalized and no longer subject to format changes,
-# we should move this to just "narrow" or similar.
-REQUIREMENT = 'narrowhg-experimental'
-
 def wrappostshare(orig, sourcerepo, destrepo, **kwargs):
 orig(sourcerepo, destrepo, **kwargs)
-if REQUIREMENT in sourcerepo.requirements:
+if changegroup.NARROW_REQUIREMENT in sourcerepo.requirements:
 with destrepo.wlock():
 with destrepo.vfs('shared', 'a') as fp:
 fp.write(narrowspec.FILENAME + '\n')
 
 def unsharenarrowspec(orig, ui, repo, repopath):
-if (REQUIREMENT in repo.requirements
+if (changegroup.NARROW_REQUIREMENT in repo.requirements
 and repo.path == repopath and repo.shared()):
 srcrepo = hg.sharedreposource(repo)
 with srcrepo.vfs(narrowspec.FILENAME) as f:
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -11,6 +11,7 @@
 from mercurial.i18n import _
 from mercurial import (
 cmdutil,
+changegroup,
 commands,
 discovery,
 error,
@@ -105,7 +106,7 @@
 repo.__class__.__bases__ = (repo.__class__.__bases__[0],
 repo.unfiltered().__class__)
 if opts_narrow:
-repo.requirements.add(narrowrepo.REQUIREMENT)
+repo.requirements.add(changegroup.NARROW_REQUIREMENT)
 repo._writerequirements()
 
 return orig(repo, *args, **kwargs)
@@ -118,7 +119,7 @@
 def pullnarrowcmd(orig, ui, repo, *args, **opts):
 """Wraps pull command to allow modifying narrow spec."""
 wrappedextraprepare = util.nullcontextmanager()
-if narrowrepo.REQUIREMENT in repo.requirements:
+if changegroup.NARROW_REQUIREMENT in repo.requirements:
 
 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
 orig(pullop, kwargs)
@@ -132,7 +133,7 @@
 
 def archivenarrowcmd(orig, ui, repo, *args, **opts):
 """Wraps archive command to narrow the default includes."""
-if narrowrepo.REQUIREMENT in repo.requirements:
+if changegroup.NARROW_REQUIREMENT in repo.requirements:
 repo_includes, repo_excludes = repo.narrowpats
 includes = set(opts.get(r'include', []))
 excludes = set(opts.get(r'exclude', []))
@@ -146,7 +147,7 @@
 
 def pullbundle2extraprepare(orig, pullop, kwargs):
 repo = pullop.repo
-if narrowrepo.REQUIREMENT not in repo.requirements:
+if changegroup.NARROW_REQUIREMENT not in repo.requirements:
 return orig(pullop, kwargs)
 
 if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps:
@@ -333,7 +334,7 @@
 empty and will not match any files.
 """
 opts = pycompat.byteskwargs(opts)
-if narrowrepo.REQUIREMENT not in repo.requirements:
+if changegroup.NARROW_REQUIREMENT not in repo.requirements:
 ui.warn(_('The narrow command is only supported on respositories 
cloned'
   ' with --narrow.\n'))
 return 1
diff --git a/hgext/narrow/narrowchangegroup.py 
b/hgext/narrow/narrowchangegroup.py
--- a/hgext/narrow/narrowchangegroup.py
+++ b/hgext/narrow/narrowchangegroup.py
@@ -19,15 +19,11 @@
 util,
 )
 
-from . import (
-narrowrepo,
-)
-
 def setup():
 
 def supportedoutgoingversions(orig, repo):
 versions = orig(repo)
-if narrowrepo.REQUIREMENT in repo.requirements:
+if 

D2489: narrow: move checking for narrow requirement into _narrowmatch()

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We want to move narrowmatch() and others into core, so we need to get
  rid of the dependence on the "narrow_opts" from the closure in
  narrowrepo.wraprepo(). We can simply check if the narrow requirement
  is set. I think that seems like an improvement regardless of moving
  narrowmatch().

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowcommands.py
  hgext/narrow/narrowrepo.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -38,7 +38,7 @@
 f.write(spec)
 return orig(ui, repo, repopath)
 
-def wraprepo(repo, opts_narrow):
+def wraprepo(repo):
 """Enables narrow clone functionality on a single local repository."""
 
 cacheprop = localrepo.storecache
@@ -77,9 +77,9 @@
 
 @localrepo.repofilecache(narrowspec.FILENAME)
 def _narrowmatch(self):
+if changegroup.NARROW_REQUIREMENT not in self.requirements:
+return matchmod.always(self.root, '')
 include, exclude = self.narrowpats
-if not opts_narrow and not include and not exclude:
-return matchmod.always(self.root, '')
 return narrowspec.match(self.root, include=include, 
exclude=exclude)
 
 # TODO(martinvonz): make this property-like instead?
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -101,7 +101,7 @@
 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
 
 def pullnarrow(orig, repo, *args, **kwargs):
-narrowrepo.wraprepo(repo.unfiltered(), opts_narrow)
+narrowrepo.wraprepo(repo.unfiltered())
 if isinstance(repo, repoview.repoview):
 repo.__class__.__bases__ = (repo.__class__.__bases__[0],
 repo.unfiltered().__class__)
diff --git a/hgext/narrow/__init__.py b/hgext/narrow/__init__.py
--- a/hgext/narrow/__init__.py
+++ b/hgext/narrow/__init__.py
@@ -73,7 +73,7 @@
 return
 
 if changegroup.NARROW_REQUIREMENT in repo.requirements:
-narrowrepo.wraprepo(repo, True)
+narrowrepo.wraprepo(repo)
 narrowcopies.setup(repo)
 narrowdirstate.setup(repo)
 narrowpatch.setup(repo)



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


D2488: narrow: move changegroup.supportedoutgoingversions() override to core

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Also document why we need cg3 or higher.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowchangegroup.py
  mercurial/changegroup.py

CHANGE DETAILS

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -898,6 +898,11 @@
 # support versions 01 and 02.
 versions.discard('01')
 versions.discard('02')
+if NARROW_REQUIREMENT in repo.requirements:
+# Versions 01 and 02 don't support revlog flags, and we need to
+# support that for stripping and unbundling to work.
+versions.discard('01')
+versions.discard('02')
 return versions
 
 def localversion(repo):
diff --git a/hgext/narrow/narrowchangegroup.py 
b/hgext/narrow/narrowchangegroup.py
--- a/hgext/narrow/narrowchangegroup.py
+++ b/hgext/narrow/narrowchangegroup.py
@@ -21,16 +21,6 @@
 
 def setup():
 
-def supportedoutgoingversions(orig, repo):
-versions = orig(repo)
-if changegroup.NARROW_REQUIREMENT in repo.requirements:
-versions.discard('01')
-versions.discard('02')
-return versions
-
-extensions.wrapfunction(changegroup, 'supportedoutgoingversions',
-supportedoutgoingversions)
-
 def prune(orig, self, revlog, missing, commonrevs):
 if isinstance(revlog, manifest.manifestrevlog):
 matcher = getattr(self._repo, 'narrowmatch',



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


D2495: narrow: drop safehasattr() checks for always-present repo.narrowmatch

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I've added checks for repo.narrowmatch().always() in order to restore
  some of the fast paths for non-narrow repos.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowchangegroup.py
  hgext/narrow/narrowcopies.py
  hgext/narrow/narrowmerge.py
  hgext/narrow/narrowpatch.py
  hgext/narrow/narrowtemplates.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowtemplates.py b/hgext/narrow/narrowtemplates.py
--- a/hgext/narrow/narrowtemplates.py
+++ b/hgext/narrow/narrowtemplates.py
@@ -10,7 +10,6 @@
 from mercurial import (
 registrar,
 revlog,
-util,
 )
 
 keywords = {}
@@ -33,8 +32,8 @@
 def outsidenarrow(repo, ctx, templ, **args):
 """String. 'outsidenarrow' if the change affects no tracked files,
 else ''."""
-if util.safehasattr(repo, 'narrowmatch'):
-m = repo.narrowmatch()
+m = repo.narrowmatch()
+if not m.always():
 if not any(m(f) for f in ctx.files()):
 return 'outsidenarrow'
 return ''
diff --git a/hgext/narrow/narrowpatch.py b/hgext/narrow/narrowpatch.py
--- a/hgext/narrow/narrowpatch.py
+++ b/hgext/narrow/narrowpatch.py
@@ -10,14 +10,13 @@
 from mercurial import (
 extensions,
 patch,
-util,
 )
 
 def setup(repo):
 def _filepairs(orig, *args):
 """Only includes files within the narrow spec in the diff."""
-if util.safehasattr(repo, 'narrowmatch'):
-narrowmatch = repo.narrowmatch()
+narrowmatch = repo.narrowmatch()
+if not narrowmatch.always():
 for x in orig(*args):
 f1, f2, copyop = x
 if ((not f1 or narrowmatch(f1)) and
@@ -29,8 +28,8 @@
 
 def trydiff(orig, repo, revs, ctx1, ctx2, modified, added, removed,
 copy, getfilectx, *args, **kwargs):
-if util.safehasattr(repo, 'narrowmatch'):
-narrowmatch = repo.narrowmatch()
+narrowmatch = repo.narrowmatch()
+if not narrowmatch.always():
 modified = [f for f in modified if narrowmatch(f)]
 added = [f for f in added if narrowmatch(f)]
 removed = [f for f in removed if narrowmatch(f)]
diff --git a/hgext/narrow/narrowmerge.py b/hgext/narrow/narrowmerge.py
--- a/hgext/narrow/narrowmerge.py
+++ b/hgext/narrow/narrowmerge.py
@@ -13,21 +13,20 @@
 error,
 extensions,
 merge,
-util,
 )
 
 def setup():
 def _manifestmerge(orig, repo, wctx, p2, pa, branchmerge, *args, **kwargs):
 """Filter updates to only lay out files that match the narrow spec."""
 actions, diverge, renamedelete = orig(
 repo, wctx, p2, pa, branchmerge, *args, **kwargs)
 
-if not util.safehasattr(repo, 'narrowmatch'):
+narrowmatch = repo.narrowmatch()
+if narrowmatch.always():
 return actions, diverge, renamedelete
 
 nooptypes = set(['k']) # TODO: handle with nonconflicttypes
 nonconflicttypes = set('a am c cm f g r e'.split())
-narrowmatch = repo.narrowmatch()
 # We mutate the items in the dict during iteration, so iterate
 # over a copy.
 for f, action in list(actions.items()):
@@ -51,8 +50,8 @@
 extensions.wrapfunction(merge, 'manifestmerge', _manifestmerge)
 
 def _checkcollision(orig, repo, wmf, actions):
-if util.safehasattr(repo, 'narrowmatch'):
-narrowmatch = repo.narrowmatch()
+narrowmatch = repo.narrowmatch()
+if not narrowmatch.always():
 wmf = wmf.matches(narrowmatch)
 if actions:
 narrowactions = {}
@@ -68,10 +67,10 @@
 
 def _computenonoverlap(orig, repo, *args, **kwargs):
 u1, u2 = orig(repo, *args, **kwargs)
-if not util.safehasattr(repo, 'narrowmatch'):
+narrowmatch = repo.narrowmatch()
+if not narrowmatch.always():
 return u1, u2
 
-narrowmatch = repo.narrowmatch()
 u1 = [f for f in u1 if narrowmatch(f)]
 u2 = [f for f in u2 if narrowmatch(f)]
 return u1, u2
diff --git a/hgext/narrow/narrowcopies.py b/hgext/narrow/narrowcopies.py
--- a/hgext/narrow/narrowcopies.py
+++ b/hgext/narrow/narrowcopies.py
@@ -11,23 +11,22 @@
 from mercurial import (
 copies,
 extensions,
-util,
 )
 
 def setup(repo):
 def _computeforwardmissing(orig, a, b, match=None):
 missing = orig(a, b, match)
-if util.safehasattr(repo, 'narrowmatch'):
-narrowmatch = repo.narrowmatch()
-missing = [f for f in missing if narrowmatch(f)]
+narrowmatch = repo.narrowmatch()
+if narrowmatch.always():
+return missing
+missing = [f for f in missing if narrowmatch(f)]
 return missing
 
 def _checkcopies(orig, 

D2494: narrow: move narrowmatch-related methods to localrepo

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch makes it so localrepo.narrowmatch() and a few more are
  always available, which will let us simplify the use sites a
  bit. narrowmatch() will return an always-matcher in non-narrow repos
  (just like it did when it lived in the narrow extension).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowrepo.py
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -43,6 +43,7 @@
 merge as mergemod,
 mergeutil,
 namespaces,
+narrowspec,
 obsolete,
 pathutil,
 peer,
@@ -736,6 +737,37 @@
" working parent %s!\n") % short(node))
 return nullid
 
+@repofilecache(narrowspec.FILENAME)
+def narrowpats(self):
+"""matcher patterns for this repository's narrowspec
+
+A tuple of (includes, excludes).
+"""
+source = self
+if self.shared():
+from . import hg
+source = hg.sharedreposource(self)
+return narrowspec.load(source)
+
+@repofilecache(narrowspec.FILENAME)
+def _narrowmatch(self):
+if changegroup.NARROW_REQUIREMENT not in self.requirements:
+return matchmod.always(self.root, '')
+include, exclude = self.narrowpats
+return narrowspec.match(self.root, include=include, exclude=exclude)
+
+# TODO(martinvonz): make this property-like instead?
+def narrowmatch(self):
+return self._narrowmatch
+
+def setnarrowpats(self, newincludes, newexcludes):
+target = self
+if self.shared():
+from . import hg
+target = hg.sharedreposource(self)
+narrowspec.save(target, newincludes, newexcludes)
+self.invalidate(clearfilecache=True)
+
 def __getitem__(self, changeid):
 if changeid is None:
 return context.workingctx(self)
diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -12,7 +12,6 @@
 changegroup,
 hg,
 localrepo,
-match as matchmod,
 narrowspec,
 scmutil,
 )
@@ -67,35 +66,6 @@
 narrowrevlog.makenarrowfilelog(fl, self.narrowmatch())
 return fl
 
-@localrepo.repofilecache(narrowspec.FILENAME)
-def narrowpats(self):
-"""matcher patterns for this repository's narrowspec
-
-A tuple of (includes, excludes).
-"""
-source = self
-if self.shared():
-source = hg.sharedreposource(self)
-return narrowspec.load(source)
-
-@localrepo.repofilecache(narrowspec.FILENAME)
-def _narrowmatch(self):
-if changegroup.NARROW_REQUIREMENT not in self.requirements:
-return matchmod.always(self.root, '')
-include, exclude = self.narrowpats
-return narrowspec.match(self.root, include=include, 
exclude=exclude)
-
-# TODO(martinvonz): make this property-like instead?
-def narrowmatch(self):
-return self._narrowmatch
-
-def setnarrowpats(self, newincludes, newexcludes):
-target = self
-if self.shared():
-target = hg.sharedreposource(self)
-narrowspec.save(target, newincludes, newexcludes)
-self.invalidate(clearfilecache=True)
-
 # I'm not sure this is the right place to do this filter.
 # context._manifestmatches() would probably be better, or perhaps
 # move it to a later place, in case some of the callers do want to know



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


D2492: narrow: reduce depedence on narrowspec.save()

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I think narrowspec should be a simple, low-level module and not depend
  on the hg module. This prepares for moving that dependency out of
  narrowspec.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowcommands.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -88,7 +88,7 @@
 # everything, except what they asked to exclude.
 includepats = {'path:.'}
 
-narrowspec.save(pullop.repo, includepats, excludepats)
+pullop.repo.setnarrowpats(includepats, excludepats)
 
 # This will populate 'includepats' etc with the values from the
 # narrowspec we just saved.
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -361,11 +361,10 @@
 def _handlechangespec_2(op, inpart):
 includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines())
 excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines())
-narrowspec.save(op.repo, includepats, excludepats)
 if not changegroup.NARROW_REQUIREMENT in op.repo.requirements:
 op.repo.requirements.add(changegroup.NARROW_REQUIREMENT)
 op.repo._writerequirements()
-op.repo.invalidate(clearfilecache=True)
+op.repo.setnarrowpats(includepats, excludepats)
 
 @bundle2.parthandler(_CHANGESPECPART)
 def _handlechangespec(op, inpart):



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


D2493: narrow: remove dependency from narrowspec module to hg module

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowrepo.py
  mercurial/narrowspec.py

CHANGE DETAILS

diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -12,7 +12,6 @@
 from .i18n import _
 from . import (
 error,
-hg,
 match as matchmod,
 util,
 )
@@ -129,8 +128,6 @@
 return [i for i in includes if i.startswith('include:')]
 
 def load(repo):
-if repo.shared():
-repo = hg.sharedreposource(repo)
 try:
 spec = repo.vfs.read(FILENAME)
 except IOError as e:
@@ -146,8 +143,6 @@
 
 def save(repo, includepats, excludepats):
 spec = format(includepats, excludepats)
-if repo.shared():
-repo = hg.sharedreposource(repo)
 repo.vfs.write(FILENAME, spec)
 
 def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes):
diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -73,7 +73,10 @@
 
 A tuple of (includes, excludes).
 """
-return narrowspec.load(self)
+source = self
+if self.shared():
+source = hg.sharedreposource(self)
+return narrowspec.load(source)
 
 @localrepo.repofilecache(narrowspec.FILENAME)
 def _narrowmatch(self):
@@ -87,7 +90,10 @@
 return self._narrowmatch
 
 def setnarrowpats(self, newincludes, newexcludes):
-narrowspec.save(self, newincludes, newexcludes)
+target = self
+if self.shared():
+target = hg.sharedreposource(self)
+narrowspec.save(target, newincludes, newexcludes)
 self.invalidate(clearfilecache=True)
 
 # I'm not sure this is the right place to do this filter.



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


D2490: narrow: consider both local and remote matchers in narrowchangegroup

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The existing code that picked one or the other seemed very
  suspicious. This patch makes us intersect the local matcher with the
  matcher from the remote, which seems better. It fixes one test case
  and makes another one that used to crash no longer crash, but instead
  silently succeed with a push that's lossy, so that remains to be
  fixed.
  
  The real reason for doing this now is that I'm going to move
  narrowrepo.narrowmatch() onto localrepo and then it will always be
  defined, which would otherwise break this code.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowchangegroup.py
  tests/test-narrow-exchange.t

CHANGE DETAILS

diff --git a/tests/test-narrow-exchange.t b/tests/test-narrow-exchange.t
--- a/tests/test-narrow-exchange.t
+++ b/tests/test-narrow-exchange.t
@@ -137,13 +137,12 @@
   $ hg pull ssh://user@dummy/narrow2
   pulling from ssh://user@dummy/narrow2
   searching for changes
-  remote: abort: unable to resolve parent while packing 'data/inside2/f.i' 3 
for changeset 5 (?)
   adding changesets
-  remote: abort: unexpected error: unable to resolve parent while packing 
'data/inside2/f.i' 3 for changeset 5
-  transaction abort!
-  rollback completed
-  abort: pull failed on remote
-  [255]
+  adding manifests
+  adding file changes
+  added 1 changesets with 0 changes to 0 files
+  new changesets d78a96df731d
+  (run 'hg update' to get a working copy)
 
 Check that the resulting history is valid in the full repo
 
@@ -204,7 +203,7 @@
   $ hg push ssh://user@dummy/narrow2
   pushing to ssh://user@dummy/narrow2
   searching for changes
-  remote has heads on branch 'default' that are not known locally: d78a96df731d
-  abort: push creates new remote head 5970befb64ba!
-  (pull and merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 0 changes to 0 files
diff --git a/hgext/narrow/narrowchangegroup.py 
b/hgext/narrow/narrowchangegroup.py
--- a/hgext/narrow/narrowchangegroup.py
+++ b/hgext/narrow/narrowchangegroup.py
@@ -13,32 +13,38 @@
 error,
 extensions,
 manifest,
+match as matchmod,
 mdiff,
 node,
 revlog,
 util,
 )
 
 def setup():
 
+def _cgmatcher(cgpacker):
+localmatcher = getattr(cgpacker._repo, 'narrowmatch', lambda: None)()
+remotematcher = getattr(cgpacker, '_narrow_matcher', lambda: None)()
+if localmatcher and remotematcher:
+return matchmod.intersectmatchers(localmatcher, remotematcher)
+else:
+return localmatcher or remotematcher
+
 def prune(orig, self, revlog, missing, commonrevs):
 if isinstance(revlog, manifest.manifestrevlog):
-matcher = getattr(self._repo, 'narrowmatch',
-  getattr(self, '_narrow_matcher', None))
-if (matcher is not None and
-not matcher().visitdir(revlog._dir[:-1] or '.')):
+matcher = _cgmatcher(self)
+if (matcher and
+not matcher.visitdir(revlog._dir[:-1] or '.')):
 return []
 return orig(self, revlog, missing, commonrevs)
 
 extensions.wrapfunction(changegroup.cg1packer, 'prune', prune)
 
 def generatefiles(orig, self, changedfiles, linknodes, commonrevs,
   source):
-matcher = getattr(self._repo, 'narrowmatch',
-  getattr(self, '_narrow_matcher', None))
-if matcher is not None:
-narrowmatch = matcher()
-changedfiles = [f for f in changedfiles if narrowmatch(f)]
+matcher = _cgmatcher(self)
+if matcher:
+changedfiles = filter(matcher, changedfiles)
 if getattr(self, 'is_shallow', False):
 # See comment in generate() for why this sadness is a thing.
 mfdicts = self._mfdicts



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


D2491: narrow: always wrap repo

2018-02-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It's simpler to always wrap the repo. This prepares for moving
  narrowrepo.narrowmatch() onto localrepo by showing that it's now safe
  to always wrap the repo (and thus always define narrowmatch() etc.).
  
  Note that since narrowmatch() returns an always-matcher (rather than
  None) in non-narrow repos, this may mean a performance hit when the
  narrow extension is enabled because it adds a no-op filtering step in
  various places against the always-matcher. I'll restore some of that
  soon.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowcommands.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -30,7 +30,6 @@
 
 from . import (
 narrowbundle2,
-narrowrepo,
 )
 
 table = {}
@@ -101,10 +100,6 @@
 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
 
 def pullnarrow(orig, repo, *args, **kwargs):
-narrowrepo.wraprepo(repo.unfiltered())
-if isinstance(repo, repoview.repoview):
-repo.__class__.__bases__ = (repo.__class__.__bases__[0],
-repo.unfiltered().__class__)
 if opts_narrow:
 repo.requirements.add(changegroup.NARROW_REQUIREMENT)
 repo._writerequirements()
diff --git a/hgext/narrow/__init__.py b/hgext/narrow/__init__.py
--- a/hgext/narrow/__init__.py
+++ b/hgext/narrow/__init__.py
@@ -72,8 +72,8 @@
 if not isinstance(repo, localrepo.localrepository):
 return
 
+narrowrepo.wraprepo(repo)
 if changegroup.NARROW_REQUIREMENT in repo.requirements:
-narrowrepo.wraprepo(repo)
 narrowcopies.setup(repo)
 narrowdirstate.setup(repo)
 narrowpatch.setup(repo)



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