D5917: annotate: respect ui.relative-paths for "binary file" message

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D5917

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -410,12 +410,13 @@
 if skiprevs:
 skiprevs = scmutil.revrange(repo, skiprevs)
 
+uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
 for abs in ctx.walk(m):
 fctx = ctx[abs]
 rootfm.startitem()
 rootfm.data(path=abs)
 if not opts.get('text') and fctx.isbinary():
-rootfm.plain(_("%s: binary file\n") % m.rel(abs))
+rootfm.plain(_("%s: binary file\n") % uipathfn(abs))
 continue
 
 fm = rootfm.nested('lines', tmpl='{rev}: {line}')



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


D5915: cmdutil: migrate previously missed instances to uipathfn

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

REVISION SUMMARY
  I seem to have missed these two instances in 
https://phab.mercurial-scm.org/rHG15f63ac122ea3ee97c67e868d055c3c310725fe4 
(files:
  respect ui.relative-paths, 2019-01-29) and 
https://phab.mercurial-scm.org/rHG7068c6b0114b9933507f8f73da66aa3e45ef530e 
(revert:
  respect ui.relative-paths, 2019-02-05).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2193,7 +2193,7 @@
 ret = 0
 except error.LookupError:
 ui.status(_("skipping missing subrepository: %s\n")
-   % m.rel(subpath))
+   % uipathfn(subpath))
 
 return ret
 
@@ -2825,7 +2825,7 @@
 for f in names:
 if f.startswith(path_):
 return
-ui.warn("%s: %s\n" % (m.rel(path), msg))
+ui.warn("%s: %s\n" % (uipathfn(path), msg))
 
 for abs in ctx.walk(matchmod.badmatch(m, badfn)):
 if abs not in names:



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


D5916: scmutil: respect ui.relative-paths in default match.badfn

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

REVISION SUMMARY
  We should probably be passing in a uipathfn here instead, so the
  caller can get consistent output (between match.badfn and whatever
  else it prints). I think we should ideally remove the badfn from the
  matcher completely, but that's a different story. This patch is at
  least not making it worse.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -804,8 +804,9 @@
 if not globbed and default == 'relpath':
 pats = expandpats(pats or [])
 
+uipathfn = getuipathfn(ctx.repo(), legacyrelativevalue=True)
 def bad(f, msg):
-ctx.repo().ui.warn("%s: %s\n" % (m.rel(f), msg))
+ctx.repo().ui.warn("%s: %s\n" % (uipathfn(f), msg))
 
 if badfn is None:
 badfn = bad



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


D5914: cat: respect ui.relative-paths for "skipping missing subrepository"

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D5914

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2367,6 +2367,7 @@
 write(abs)
 err = 0
 
+uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
 for subpath in sorted(ctx.substate):
 sub = ctx.sub(subpath)
 try:
@@ -2377,7 +2378,7 @@
 err = 0
 except error.RepoLookupError:
 ui.status(_("skipping missing subrepository: %s\n") %
-  matcher.rel(subpath))
+  uipathfn(subpath))
 
 return err
 



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


D5913: addremove: use uipathfn instead of m.rel() for recorded similatity message

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

REVISION SUMMARY
  When no path arguments are given to addremove, it generally prints
  absolute paths. However, before this patch, we would always print the
  "recording removal of foo as rename to bar (78% similar)" message with
  relative paths.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1094,7 +1094,7 @@
 repo.ui.status(status, label=label)
 
 renames = _findrenames(repo, m, added + unknown, removed + deleted,
-   similarity)
+   similarity, uipathfn)
 
 if not dry_run:
 _markchanges(repo, unknown + forgotten, deleted, renames)
@@ -1123,8 +1123,12 @@
 status = _('removing %s\n') % abs
 repo.ui.status(status)
 
+# TODO: We should probably have the caller pass in uipathfn and apply it to
+# the messages above too. forcerelativevalue=True is consistent with how
+# it used to work.
+uipathfn = getuipathfn(repo, forcerelativevalue=True)
 renames = _findrenames(repo, m, added + unknown, removed + deleted,
-   similarity)
+   similarity, uipathfn)
 
 _markchanges(repo, unknown + forgotten, deleted, renames)
 
@@ -1163,7 +1167,7 @@
 
 return added, unknown, deleted, removed, forgotten
 
-def _findrenames(repo, matcher, added, removed, similarity):
+def _findrenames(repo, matcher, added, removed, similarity, uipathfn):
 '''Find renames from removed files to added ones.'''
 renames = {}
 if similarity > 0:
@@ -1173,7 +1177,7 @@
 or not matcher.exact(new)):
 repo.ui.status(_('recording removal of %s as rename to %s '
  '(%d%% similar)\n') %
-   (matcher.rel(old), matcher.rel(new),
+   (uipathfn(old), uipathfn(new),
 score * 100))
 renames[new] = old
 return renames



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


D5911: forget: pass around uipathfn and use instead of m.rel() (API)

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D5911

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -355,7 +355,7 @@
 matched by the match function
 '''
 
-def forget(self, match, prefix, dryrun, interactive):
+def forget(self, match, prefix, uipathfn, dryrun, interactive):
 return ([], [])
 
 def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos,
@@ -836,8 +836,8 @@
 return ctx.walk(match)
 
 @annotatesubrepoerror
-def forget(self, match, prefix, dryrun, interactive):
-return cmdutil.forget(self.ui, self._repo, match, prefix,
+def forget(self, match, prefix, uipathfn, dryrun, interactive):
+return cmdutil.forget(self.ui, self._repo, match, prefix, uipathfn,
   True, dryrun=dryrun, interactive=interactive)
 
 @annotatesubrepoerror
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2257,7 +2257,8 @@
 
 m = scmutil.match(repo[None], pats, opts)
 dryrun, interactive = opts.get('dry_run'), opts.get('interactive')
-rejected = cmdutil.forget(ui, repo, m, prefix="",
+uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=True)
+rejected = cmdutil.forget(ui, repo, m, prefix="", uipathfn=uipathfn,
   explicitonly=False, dryrun=dryrun,
   interactive=interactive)[0]
 return rejected and 1 or 0
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2085,7 +2085,8 @@
 for subpath in ctx.substate:
 ctx.sub(subpath).addwebdirpath(serverpath, webconf)
 
-def forget(ui, repo, match, prefix, explicitonly, dryrun, interactive):
+def forget(ui, repo, match, prefix, uipathfn, explicitonly, dryrun,
+   interactive):
 if dryrun and interactive:
 raise error.Abort(_("cannot specify both --dry-run and --interactive"))
 bad = []
@@ -2102,14 +2103,16 @@
 sub = wctx.sub(subpath)
 submatch = matchmod.subdirmatcher(subpath, match)
 subprefix = repo.wvfs.reljoin(prefix, subpath)
+subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn)
 try:
-subbad, subforgot = sub.forget(submatch, subprefix, dryrun=dryrun,
+subbad, subforgot = sub.forget(submatch, subprefix, subuipathfn,
+   dryrun=dryrun,
interactive=interactive)
 bad.extend([subpath + '/' + f for f in subbad])
 forgot.extend([subpath + '/' + f for f in subforgot])
 except error.LookupError:
 ui.status(_("skipping missing subrepository: %s\n")
-   % match.rel(subpath))
+   % uipathfn(subpath))
 
 if not explicitonly:
 for f in match.files():
@@ -2124,7 +2127,7 @@
 continue
 ui.warn(_('not removing %s: '
   'file is already untracked\n')
-% match.rel(f))
+% uipathfn(f))
 bad.append(f)
 
 if interactive:
@@ -2155,7 +2158,7 @@
 
 for f in forget:
 if ui.verbose or not match.exact(f) or interactive:
-ui.status(_('removing %s\n') % match.rel(f),
+ui.status(_('removing %s\n') % uipathfn(f),
   label='ui.addremove.removed')
 
 if not dryrun:
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -1067,11 +1067,11 @@
 repo.lfstatus = False
 
 @eh.wrapfunction(cmdutil, 'forget')
-def cmdutilforget(orig, ui, repo, match, prefix, explicitonly, dryrun,
+def cmdutilforget(orig, ui, repo, match, prefix, uipathfn, explicitonly, 
dryrun,
   interactive):
 normalmatcher = composenormalfilematcher(match, repo[None].manifest())
-bad, forgot = orig(ui, repo, normalmatcher, prefix, explicitonly, dryrun,
-   interactive)
+bad, forgot = orig(ui, repo, normalmatcher, prefix, uipathfn, explicitonly,
+   dryrun, interactive)
 m = composelargefilematcher(match, repo[None].manifest())
 
 try:
@@ -1087,12 +1087,12 @@
 fstandin = lfutil.standin(f)
 if fstandin not in repo.dirstate and not repo.wvfs.isdir(fstandin):
 ui.warn(_('not removing %s: file is already untracked\n')
-% m.rel(f))
+  

D5912: forget: use relative paths for --interactive

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

REVISION SUMMARY
  Seems more consistent.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2138,13 +2138,14 @@
   '$$ Include  remaining files'
   '$$ &? (display help)')
 for filename in forget[:]:
-r = ui.promptchoice(_('forget %s %s') % (filename, responses))
+r = ui.promptchoice(_('forget %s %s') %
+(uipathfn(filename), responses))
 if r == 4: # ?
 while r == 4:
 for c, t in ui.extractchoices(responses)[1]:
 ui.write('%s - %s\n' % (c, encoding.lower(t)))
-r = ui.promptchoice(_('forget %s %s') % (filename,
- responses))
+r = ui.promptchoice(_('forget %s %s') %
+(uipathfn(filename), responses))
 if r == 0: # yes
 continue
 elif r == 1: # no



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


D5909: debugwalk: avoid match.rel() and use repo.pathto() instead

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

REVISION SUMMARY
  I'm about to delete match.rel()

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2020,7 +2020,7 @@
 for abs in ctx.walk(m):
 fctx = ctx[abs]
 o = fctx.filelog().renamed(fctx.filenode())
-rel = m.rel(abs)
+rel = repo.pathto(abs)
 if o:
 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
 else:
@@ -2796,9 +2796,9 @@
 f = lambda fn: util.normpath(fn)
 fmt = 'f  %%-%ds  %%-%ds  %%s' % (
 max([len(abs) for abs in items]),
-max([len(m.rel(abs)) for abs in items]))
+max([len(repo.pathto(abs)) for abs in items]))
 for abs in items:
-line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
+line = fmt % (abs, f(repo.pathto(abs)), m.exact(abs) and 'exact' or '')
 ui.write("%s\n" % line.rstrip())
 
 @command('debugwhyunstable', [], _('REV'))



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


D5910: automv: respect ui.relative-paths

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D5910

AFFECTED FILES
  hgext/automv.py

CHANGE DETAILS

diff --git a/hgext/automv.py b/hgext/automv.py
--- a/hgext/automv.py
+++ b/hgext/automv.py
@@ -64,7 +64,8 @@
 if threshold > 0:
 match = scmutil.match(repo[None], pats, opts)
 added, removed = _interestingfiles(repo, match)
-renames = _findrenames(repo, match, added, removed,
+uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
+renames = _findrenames(repo, uipathfn, added, removed,
threshold / 100.0)
 
 with repo.wlock():
@@ -89,7 +90,7 @@
 
 return added, removed
 
-def _findrenames(repo, matcher, added, removed, similarity):
+def _findrenames(repo, uipathfn, added, removed, similarity):
 """Find what files in added are really moved files.
 
 Any file named in removed that is at least similarity% similar to a file
@@ -103,7 +104,7 @@
 if repo.ui.verbose:
 repo.ui.status(
 _('detected move of %s as %s (%d%% similar)\n') % (
-matcher.rel(src), matcher.rel(dst), score * 100))
+uipathfn(src), uipathfn(dst), score * 100))
 renames[dst] = src
 if renames:
 repo.ui.status(_('detected move of %d files\n') % len(renames))



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


D5908: match: delete unused abs() (API)

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D5908

AFFECTED FILES
  mercurial/match.py

CHANGE DETAILS

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -283,11 +283,6 @@
 # by recursive traversal is visited.
 traversedir = None
 
-def abs(self, f):
-'''Convert a repo path back to path that is relative to the root of the
-matcher.'''
-return f
-
 def rel(self, f):
 '''Convert repo path back to path that is relative to cwd of 
matcher.'''
 return util.pathto(self._root, self._cwd, f)
@@ -721,7 +716,6 @@
 m.bad = m1.bad
 m.explicitdir = m1.explicitdir
 m.traversedir = m1.traversedir
-m.abs = m1.abs
 m.rel = m1.rel
 return m
 if m2.always():
@@ -817,8 +811,6 @@
 >>> m1.bad = bad
 >>> m2.bad(b'x.txt', b'No such file')
 sub/x.txt: No such file
->>> m2.abs(b'c.txt')
-'sub/c.txt'
 """
 
 def __init__(self, path, matcher):
@@ -838,9 +830,6 @@
 def bad(self, f, msg):
 self._matcher.bad(self._path + "/" + f, msg)
 
-def abs(self, f):
-return self._matcher.abs(self._path + "/" + f)
-
 def rel(self, f):
 return self._matcher.rel(self._path + "/" + f)
 



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


D5907: copy: respect ui.relative-paths in copy/rename

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 13934.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5907?vs=13933=13934

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/scmutil.py
  tests/test-copy.t

CHANGE DETAILS

diff --git a/tests/test-copy.t b/tests/test-copy.t
--- a/tests/test-copy.t
+++ b/tests/test-copy.t
@@ -118,6 +118,23 @@
   [255]
   $ hg st -A
   ? foo
+respects ui.relative-paths
+  $ mkdir dir
+  $ cd dir
+  $ hg mv ../foo ../bar
+  ../foo: not copying - file is not managed
+  abort: no files to copy
+  [255]
+  $ hg mv ../foo ../bar --config ui.relative-paths=yes
+  ../foo: not copying - file is not managed
+  abort: no files to copy
+  [255]
+  $ hg mv ../foo ../bar --config ui.relative-paths=no
+  foo: not copying - file is not managed
+  abort: no files to copy
+  [255]
+  $ cd ..
+  $ rmdir dir
   $ hg add foo
 dry-run; print a warning that this is not a real copy; foo is added
   $ hg mv --dry-run foo bar
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -51,8 +51,10 @@
 )
 
 if pycompat.iswindows:
+from . import windows as platform
 from . import scmwindows as scmplatform
 else:
+from . import posix as platform
 from . import scmposix as scmplatform
 
 parsers = policy.importmod(r'parsers')
@@ -757,7 +759,7 @@
 pathto = repo.pathto
 return lambda f: pathto(f, cwd)
 else:
-return lambda f: f
+return platform.localpath
 
 def subdiruipathfn(subpath, uipathfn):
 '''Create a new uipathfn that treats the file as relative to subpath.'''
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1135,6 +1135,7 @@
 dryrun = opts.get("dry_run")
 wctx = repo[None]
 
+uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
 def walkpat(pat):
 srcs = []
 if after:
@@ -1144,7 +1145,7 @@
 m = scmutil.match(wctx, [pat], opts, globbed=True)
 for abs in wctx.walk(m):
 state = repo.dirstate[abs]
-rel = m.rel(abs)
+rel = uipathfn(abs)
 exact = m.exact(abs)
 if state in badstates:
 if exact and state == '?':



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


D5907: copy: respect ui.relative-paths in copy/rename

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 13933.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5907?vs=13932=13933

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/scmutil.py
  tests/test-copy.t

CHANGE DETAILS

diff --git a/tests/test-copy.t b/tests/test-copy.t
--- a/tests/test-copy.t
+++ b/tests/test-copy.t
@@ -118,6 +118,23 @@
   [255]
   $ hg st -A
   ? foo
+respects ui.relative-paths
+  $ mkdir dir
+  $ cd dir
+  $ hg mv ../foo ../bar
+  ../foo: not copying - file is not managed
+  abort: no files to copy
+  [255]
+  $ hg mv ../foo ../bar --config ui.relative-paths=yes
+  ../foo: not copying - file is not managed
+  abort: no files to copy
+  [255]
+  $ hg mv ../foo ../bar --config ui.relative-paths=no
+  foo: not copying - file is not managed
+  abort: no files to copy
+  [255]
+  $ cd ..
+  $ rmdir dir
   $ hg add foo
 dry-run; print a warning that this is not a real copy; foo is added
   $ hg mv --dry-run foo bar
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -51,8 +51,10 @@
 )
 
 if pycompat.iswindows:
+from . import windows as platform
 from . import scmwindows as scmplatform
 else:
+from . import posix as platform
 from . import scmposix as scmplatform
 
 parsers = policy.importmod(r'parsers')
@@ -757,7 +759,7 @@
 pathto = repo.pathto
 return lambda f: pathto(f, cwd)
 else:
-return lambda f: f
+return platform.localpath
 
 def subdiruipathfn(subpath, uipathfn):
 '''Create a new uipathfn that treats the file as relative to subpath.'''
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1135,6 +1135,7 @@
 dryrun = opts.get("dry_run")
 wctx = repo[None]
 
+uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
 def walkpat(pat):
 srcs = []
 if after:
@@ -1144,7 +1145,7 @@
 m = scmutil.match(wctx, [pat], opts, globbed=True)
 for abs in wctx.walk(m):
 state = repo.dirstate[abs]
-rel = m.rel(abs)
+rel = uipathfn(abs)
 exact = m.exact(abs)
 if state in badstates:
 if exact and state == '?':
@@ -2188,7 +2189,7 @@
 ret = 0
 except error.LookupError:
 ui.status(_("skipping missing subrepository: %s\n")
-   % m.rel(subpath))
+   % uipathfn(subpath))
 
 return ret
 
@@ -2819,7 +2820,7 @@
 for f in names:
 if f.startswith(path_):
 return
-ui.warn("%s: %s\n" % (m.rel(path), msg))
+ui.warn("%s: %s\n" % (uipathfn(path), msg))
 
 for abs in ctx.walk(matchmod.badmatch(m, badfn)):
 if abs not in names:



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


D5907: copy: respect ui.relative-paths in copy/rename

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D5907

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1135,6 +1135,7 @@
 dryrun = opts.get("dry_run")
 wctx = repo[None]
 
+uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
 def walkpat(pat):
 srcs = []
 if after:
@@ -1144,7 +1145,7 @@
 m = scmutil.match(wctx, [pat], opts, globbed=True)
 for abs in wctx.walk(m):
 state = repo.dirstate[abs]
-rel = m.rel(abs)
+rel = uipathfn(abs)
 exact = m.exact(abs)
 if state in badstates:
 if exact and state == '?':



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


D5906: match: delete unused uipath() and _uipathrelative (API)

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D5906

AFFECTED FILES
  mercurial/match.py

CHANGE DETAILS

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -176,7 +176,7 @@
 elif patterns:
 kindpats = normalize(patterns, default, root, cwd, auditor, warn)
 if _kindpatsalwaysmatch(kindpats):
-m = alwaysmatcher(root, cwd, badfn, relativeuipath=True)
+m = alwaysmatcher(root, cwd, badfn)
 else:
 m = _buildkindpatsmatcher(patternmatcher, root, cwd, kindpats,
   ctx=ctx, listsubrepos=listsubrepos,
@@ -258,12 +258,11 @@
 
 class basematcher(object):
 
-def __init__(self, root, cwd, badfn=None, relativeuipath=True):
+def __init__(self, root, cwd, badfn=None):
 self._root = root
 self._cwd = cwd
 if badfn is not None:
 self.bad = badfn
-self._relativeuipath = relativeuipath
 
 def __call__(self, fn):
 return self.matchfn(fn)
@@ -293,12 +292,6 @@
 '''Convert repo path back to path that is relative to cwd of 
matcher.'''
 return util.pathto(self._root, self._cwd, f)
 
-def uipath(self, f):
-'''Convert repo path to a display path.  If patterns or -I/-X were used
-to create this matcher, the display path will be relative to cwd.
-Otherwise it is relative to the root of the repo.'''
-return (self._relativeuipath and self.rel(f)) or self.abs(f)
-
 @propertycache
 def _files(self):
 return []
@@ -399,9 +392,8 @@
 class alwaysmatcher(basematcher):
 '''Matches everything.'''
 
-def __init__(self, root, cwd, badfn=None, relativeuipath=False):
-super(alwaysmatcher, self).__init__(root, cwd, badfn,
-relativeuipath=relativeuipath)
+def __init__(self, root, cwd, badfn=None):
+super(alwaysmatcher, self).__init__(root, cwd, badfn)
 
 def always(self):
 return True
@@ -731,11 +723,9 @@
 m.traversedir = m1.traversedir
 m.abs = m1.abs
 m.rel = m1.rel
-m._relativeuipath |= m1._relativeuipath
 return m
 if m2.always():
 m = copy.copy(m1)
-m._relativeuipath |= m2._relativeuipath
 return m
 return intersectionmatcher(m1, m2)
 
@@ -854,9 +844,6 @@
 def rel(self, f):
 return self._matcher.rel(self._path + "/" + f)
 
-def uipath(self, f):
-return self._matcher.uipath(self._path + "/" + f)
-
 def matchfn(self, f):
 # Some information is lost in the superclass's constructor, so we
 # can not accurately create the matching function for the subdirectory



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


D5902: remove: pass around uipathfn and use instead of m.rel() (API)

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 13928.
martinvonz retitled this revision from "remove: pass around uipathfn and use 
instead of m.rel()" to "remove: pass around uipathfn and use instead of m.rel() 
(API)".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5902?vs=13922=13928

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -358,7 +358,7 @@
 def forget(self, match, prefix, dryrun, interactive):
 return ([], [])
 
-def removefiles(self, matcher, prefix, after, force, subrepos,
+def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos,
 dryrun, warnings):
 """remove the matched files from the subrepository and the filesystem,
 possibly by force and/or after the file has been removed from the
@@ -841,9 +841,9 @@
   True, dryrun=dryrun, interactive=interactive)
 
 @annotatesubrepoerror
-def removefiles(self, matcher, prefix, after, force, subrepos,
+def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos,
 dryrun, warnings):
-return cmdutil.remove(self.ui, self._repo, matcher, prefix,
+return cmdutil.remove(self.ui, self._repo, matcher, prefix, uipathfn,
   after, force, subrepos, dryrun)
 
 @annotatesubrepoerror
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4716,7 +4716,8 @@
 
 m = scmutil.match(repo[None], pats, opts)
 subrepos = opts.get('subrepos')
-return cmdutil.remove(ui, repo, m, "", after, force, subrepos,
+uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=True)
+return cmdutil.remove(ui, repo, m, "", uipathfn, after, force, subrepos,
   dryrun=dryrun)
 
 @command('rename|move|mv',
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2192,7 +2192,8 @@
 
 return ret
 
-def remove(ui, repo, m, prefix, after, force, subrepos, dryrun, warnings=None):
+def remove(ui, repo, m, prefix, uipathfn, after, force, subrepos, dryrun,
+   warnings=None):
 ret = 0
 s = repo.status(match=m, clean=True)
 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
@@ -2211,16 +2212,17 @@
 for subpath in subs:
 submatch = matchmod.subdirmatcher(subpath, m)
 subprefix = repo.wvfs.reljoin(prefix, subpath)
+subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn)
 if subrepos or m.exact(subpath) or any(submatch.files()):
 progress.increment()
 sub = wctx.sub(subpath)
 try:
-if sub.removefiles(submatch, subprefix, after, force, subrepos,
-   dryrun, warnings):
+if sub.removefiles(submatch, subprefix, subuipathfn, after,
+   force, subrepos, dryrun, warnings):
 ret = 1
 except error.LookupError:
 warnings.append(_("skipping missing subrepository: %s\n")
-   % m.rel(subpath))
+   % uipathfn(subpath))
 progress.complete()
 
 # warn about failure to delete explicit files/dirs
@@ -2244,10 +2246,10 @@
 if repo.wvfs.exists(f):
 if repo.wvfs.isdir(f):
 warnings.append(_('not removing %s: no tracked files\n')
-% m.rel(f))
+% uipathfn(f))
 else:
 warnings.append(_('not removing %s: file is untracked\n')
-% m.rel(f))
+% uipathfn(f))
 # missing files will generate a warning elsewhere
 ret = 1
 progress.complete()
@@ -2263,7 +2265,7 @@
 progress.increment()
 if ui.verbose or (f in files):
 warnings.append(_('not removing %s: file still exists\n')
-% m.rel(f))
+% uipathfn(f))
 ret = 1
 progress.complete()
 else:
@@ -2274,12 +2276,12 @@
 for f in modified:
 progress.increment()
 warnings.append(_('not removing %s: file is modified (use -f'
-  ' to force removal)\n') % m.rel(f))
+  ' to force removal)\n') % uipathfn(f))
 ret = 1
 for f in added:
 progress.increment()
 warnings.append(_("not removing %s: file has been marked for add"
-  " (use 'hg forget' to undo add)\n") % m.rel(f))
+  " (use 'hg forget' to undo add)\n") 

D5894: patch: replace "prefix" and "relroot" arguments by "pathfn" (API)

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 13927.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5894?vs=13908=13927

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

AFFECTED FILES
  mercurial/context.py
  mercurial/logcmdutil.py
  mercurial/patch.py

CHANGE DETAILS

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -15,7 +15,6 @@
 import errno
 import hashlib
 import os
-import posixpath
 import re
 import shutil
 import zlib
@@ -2239,7 +2238,7 @@
 difffeatureopts = diffutil.difffeatureopts
 
 def diff(repo, node1=None, node2=None, match=None, changes=None,
- opts=None, losedatafn=None, prefix='', relroot='', copy=None,
+ opts=None, losedatafn=None, pathfn=None, copy=None,
  copysourcematch=None, hunksfilterfn=None):
 '''yields diff of changes to files between two nodes, or node and
 working directory.
@@ -2277,9 +2276,8 @@
 ctx2 = repo[node2]
 
 for fctx1, fctx2, hdr, hunks in diffhunks(
-repo, ctx1=ctx1, ctx2=ctx2,
-match=match, changes=changes, opts=opts,
-losedatafn=losedatafn, prefix=prefix, relroot=relroot, copy=copy,
+repo, ctx1=ctx1, ctx2=ctx2, match=match, changes=changes, 
opts=opts,
+losedatafn=losedatafn, pathfn=pathfn, copy=copy,
 copysourcematch=copysourcematch):
 if hunksfilterfn is not None:
 # If the file has been removed, fctx2 is None; but this should
@@ -2294,9 +2292,8 @@
 if text:
 yield text
 
-def diffhunks(repo, ctx1, ctx2, match=None, changes=None,
-  opts=None, losedatafn=None, prefix='', relroot='', copy=None,
-  copysourcematch=None):
+def diffhunks(repo, ctx1, ctx2, match=None, changes=None, opts=None,
+  losedatafn=None, pathfn=None, copy=None, copysourcematch=None):
 """Yield diff of changes to files in the form of (`header`, `hunks`) tuples
 where `header` is a list of diff headers and `hunks` is an iterable of
 (`hunkrange`, `hunklines`) tuples.
@@ -2376,7 +2373,7 @@
 
 def difffn(opts, losedata):
 return trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
-   copy, getfilectx, opts, losedata, prefix, relroot)
+   copy, getfilectx, opts, losedata, pathfn)
 if opts.upgrade and not opts.git:
 try:
 def losedata(fn):
@@ -2591,16 +2588,14 @@
 yield f1, f2, copyop
 
 def trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
-copy, getfilectx, opts, losedatafn, prefix, relroot):
+copy, getfilectx, opts, losedatafn, pathfn):
 '''given input data, generate a diff and yield it in blocks
 
 If generating a diff would lose data like flags or binary data and
 losedatafn is not None, it will be called.
 
-relroot is removed and prefix is added to every path in the diff output.
-
-If relroot is not empty, this function expects every path in modified,
-added, removed and copy to start with it.'''
+pathfn is applied to every path in the diff output.
+'''
 
 def gitindex(text):
 if not text:
@@ -2628,12 +2623,8 @@
 
 gitmode = {'l': '12', 'x': '100755', '': '100644'}
 
-if relroot != '' and (repo.ui.configbool('devel', 'all-warnings')
-  or repo.ui.configbool('devel', 'check-relroot')):
-for f in modified + added + removed + list(copy) + list(copy.values()):
-if f is not None and not f.startswith(relroot):
-raise AssertionError(
-"file %s doesn't start with relroot %s" % (f, relroot))
+if not pathfn:
+pathfn = lambda f: f
 
 for f1, f2, copyop in _filepairs(modified, added, removed, copy, opts):
 content1 = None
@@ -2670,10 +2661,8 @@
 (f1 and f2 and flag1 != flag2)):
 losedatafn(f2 or f1)
 
-path1 = f1 or f2
-path2 = f2 or f1
-path1 = posixpath.join(prefix, path1[len(relroot):])
-path2 = posixpath.join(prefix, path2[len(relroot):])
+path1 = pathfn(f1 or f2)
+path2 = pathfn(f2 or f1)
 header = []
 if opts.git:
 header.append('diff --git %s%s %s%s' %
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -9,6 +9,7 @@
 
 import itertools
 import os
+import posixpath
 
 from .i18n import _
 from .node import (
@@ -65,6 +66,8 @@
 else:
 relroot = ''
 copysourcematch = None
+def pathfn(f):
+return posixpath.join(prefix, f)
 if relroot != '':
 # XXX relative roots currently don't work if the root is within a
 # subrepo
@@ -79,14 +82,22 @@
 match = matchmod.intersectmatchers(match, relrootmatch)
 copysourcematch = relrootmatch
 
+checkroot = (repo.ui.configbool('devel', 

D5893: patch: accept second matcher that applies only to copy sources (API)

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 13926.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5893?vs=13907=13926

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

AFFECTED FILES
  mercurial/context.py
  mercurial/logcmdutil.py
  mercurial/patch.py

CHANGE DETAILS

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2240,7 +2240,7 @@
 
 def diff(repo, node1=None, node2=None, match=None, changes=None,
  opts=None, losedatafn=None, prefix='', relroot='', copy=None,
- hunksfilterfn=None):
+ copysourcematch=None, hunksfilterfn=None):
 '''yields diff of changes to files between two nodes, or node and
 working directory.
 
@@ -2264,6 +2264,9 @@
 copy, if not empty, should contain mappings {dst@y: src@x} of copy
 information.
 
+if copysourcematch is not None, then copy sources will be filtered by this
+matcher
+
 hunksfilterfn, if not None, should be a function taking a filectx and
 hunks generator that may yield filtered hunks.
 '''
@@ -2277,7 +2280,7 @@
 repo, ctx1=ctx1, ctx2=ctx2,
 match=match, changes=changes, opts=opts,
 losedatafn=losedatafn, prefix=prefix, relroot=relroot, copy=copy,
-):
+copysourcematch=copysourcematch):
 if hunksfilterfn is not None:
 # If the file has been removed, fctx2 is None; but this should
 # not occur here since we catch removed files early in
@@ -2292,7 +2295,8 @@
 yield text
 
 def diffhunks(repo, ctx1, ctx2, match=None, changes=None,
-  opts=None, losedatafn=None, prefix='', relroot='', copy=None):
+  opts=None, losedatafn=None, prefix='', relroot='', copy=None,
+  copysourcematch=None):
 """Yield diff of changes to files in the form of (`header`, `hunks`) tuples
 where `header` is a list of diff headers and `hunks` is an iterable of
 (`hunkrange`, `hunklines`) tuples.
@@ -2337,11 +2341,11 @@
 if opts.git or opts.upgrade:
 copy = copies.pathcopies(ctx1, ctx2, match=match)
 
-if relroot:
-# filter out copies where source side isn't inside the relative root
+if copysourcematch:
+# filter out copies where source side isn't inside the matcher
 # (copies.pathcopies() already filtered out the destination)
 copy = {dst: src for dst, src in copy.iteritems()
-if src.startswith(relroot)}
+if copysourcematch(src)}
 
 modifiedset = set(modified)
 addedset = set(added)
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -64,6 +64,7 @@
 relroot = pathutil.canonpath(repo.root, repo.getcwd(), root)
 else:
 relroot = ''
+copysourcematch = None
 if relroot != '':
 # XXX relative roots currently don't work if the root is within a
 # subrepo
@@ -76,15 +77,17 @@
 
 relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path')
 match = matchmod.intersectmatchers(match, relrootmatch)
+copysourcematch = relrootmatch
 
 if stat:
 diffopts = diffopts.copy(context=0, noprefix=False)
 width = 80
 if not ui.plain():
 width = ui.termwidth() - graphwidth
 
 chunks = ctx2.diff(ctx1, match, changes, opts=diffopts, prefix=prefix,
-   relroot=relroot, hunksfilterfn=hunksfilterfn)
+   relroot=relroot, copysourcematch=copysourcematch,
+   hunksfilterfn=hunksfilterfn)
 
 if fp is not None or ui.canwritewithoutlabels():
 out = fp or ui
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -295,15 +295,16 @@
 
 def diff(self, ctx2=None, match=None, changes=None, opts=None,
  losedatafn=None, prefix='', relroot='', copy=None,
- hunksfilterfn=None):
+ copysourcematch=None, hunksfilterfn=None):
 """Returns a diff generator for the given contexts and matcher"""
 if ctx2 is None:
 ctx2 = self.p1()
 if ctx2 is not None:
 ctx2 = self._repo[ctx2]
 return patch.diff(self._repo, ctx2, self, match=match, changes=changes,
   opts=opts, losedatafn=losedatafn, prefix=prefix,
   relroot=relroot, copy=copy,
+  copysourcematch=copysourcematch,
   hunksfilterfn=hunksfilterfn)
 
 def dirs(self):



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


D5886: subrepo: adjust subrepo prefix before calling subrepo.diff() (API)

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 13925.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5886?vs=13897=13925

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

AFFECTED FILES
  mercurial/logcmdutil.py
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -11,7 +11,6 @@
 import errno
 import hashlib
 import os
-import posixpath
 import re
 import stat
 import subprocess
@@ -556,10 +555,9 @@
 # in hex format
 if node2 is not None:
 node2 = node.bin(node2)
-logcmdutil.diffordiffstat(ui, self._repo, diffopts,
-  node1, node2, match,
-  prefix=posixpath.join(prefix, 
self._path),
-  listsubrepos=True, **opts)
+logcmdutil.diffordiffstat(ui, self._repo, diffopts, node1, node2,
+  match, prefix=prefix, listsubrepos=True,
+  **opts)
 except error.RepoLookupError as inst:
 self.ui.warn(_('warning: error "%s" in subrepository "%s"\n')
   % (inst, subrelpath(self)))
@@ -1779,14 +1777,12 @@
 # for Git, this also implies '-p'
 cmd.append('-U%d' % diffopts.context)
 
-gitprefix = self.wvfs.reljoin(prefix, self._path)
-
 if diffopts.noprefix:
-cmd.extend(['--src-prefix=%s/' % gitprefix,
-'--dst-prefix=%s/' % gitprefix])
+cmd.extend(['--src-prefix=%s/' % prefix,
+'--dst-prefix=%s/' % prefix])
 else:
-cmd.extend(['--src-prefix=a/%s/' % gitprefix,
-'--dst-prefix=b/%s/' % gitprefix])
+cmd.extend(['--src-prefix=a/%s/' % prefix,
+'--dst-prefix=b/%s/' % prefix])
 
 if diffopts.ignorews:
 cmd.append('--ignore-all-space')
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -117,8 +117,9 @@
 # subpath. The best we can do is to ignore it.
 tempnode2 = None
 submatch = matchmod.subdirmatcher(subpath, match)
+subprefix = repo.wvfs.reljoin(prefix, subpath)
 sub.diff(ui, diffopts, tempnode2, submatch, changes=changes,
- stat=stat, fp=fp, prefix=prefix)
+ stat=stat, fp=fp, prefix=subprefix)
 
 class changesetdiffer(object):
 """Generate diff of changeset with pre-configured filtering functions"""



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


D5903: addremove: pass around uipathfn and use instead of m.uipath()

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D5903

AFFECTED FILES
  contrib/perf.py
  hgext/largefiles/overrides.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/scmutil.py
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -290,7 +290,7 @@
 def add(self, ui, match, prefix, uipathfn, explicitonly, **opts):
 return []
 
-def addremove(self, matcher, prefix, opts):
+def addremove(self, matcher, prefix, uipathfn, opts):
 self.ui.warn("%s: %s" % (prefix, _("addremove is not supported")))
 return 1
 
@@ -521,13 +521,13 @@
explicitonly, **opts)
 
 @annotatesubrepoerror
-def addremove(self, m, prefix, opts):
+def addremove(self, m, prefix, uipathfn, opts):
 # In the same way as sub directories are processed, once in a subrepo,
 # always entry any of its subrepos.  Don't corrupt the options that 
will
 # be used to process sibling subrepos however.
 opts = copy.copy(opts)
 opts['subrepos'] = True
-return scmutil.addremove(self._repo, m, prefix, opts)
+return scmutil.addremove(self._repo, m, prefix, uipathfn, opts)
 
 @annotatesubrepoerror
 def cat(self, match, fm, fntemplate, prefix, **opts):
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -763,6 +763,14 @@
 '''Create a new uipathfn that treats the file as relative to subpath.'''
 return lambda f: uipathfn(posixpath.join(subpath, f))
 
+def anypats(pats, opts):
+'''Checks if any patterns, including --include and --exclude were given.
+
+Some commands (e.g. addremove) use this condition for deciding whether to
+print absolute or relative paths.
+'''
+return bool(pats or opts.get('include') or opts.get('exclude'))
+
 def expandpats(pats):
 '''Expand bare globs when running on windows.
 On posix we assume it already has already been done by sh.'''
@@ -1031,7 +1039,7 @@
 repair.delayedstrip(repo.ui, repo, tostrip, operation,
 backup=backup)
 
-def addremove(repo, matcher, prefix, opts=None):
+def addremove(repo, matcher, prefix, uipathfn, opts=None):
 if opts is None:
 opts = {}
 m = matcher
@@ -1052,12 +1060,13 @@
 if opts.get('subrepos') or m.exact(subpath) or any(submatch.files()):
 sub = wctx.sub(subpath)
 subprefix = repo.wvfs.reljoin(prefix, subpath)
+subuipathfn = subdiruipathfn(subpath, uipathfn)
 try:
-if sub.addremove(submatch, subprefix, opts):
+if sub.addremove(submatch, subprefix, subuipathfn, opts):
 ret = 1
 except error.LookupError:
 repo.ui.status(_("skipping missing subrepository: %s\n")
- % m.uipath(subpath))
+ % uipathfn(subpath))
 
 rejected = []
 def badfn(f, msg):
@@ -1075,10 +1084,10 @@
 for abs in sorted(toprint):
 if repo.ui.verbose or not m.exact(abs):
 if abs in unknownset:
-status = _('adding %s\n') % m.uipath(abs)
+status = _('adding %s\n') % uipathfn(abs)
 label = 'ui.addremove.added'
 else:
-status = _('removing %s\n') % m.uipath(abs)
+status = _('removing %s\n') % uipathfn(abs)
 label = 'ui.addremove.removed'
 repo.ui.status(status, label=label)
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -255,7 +255,9 @@
 if not opts.get('similarity'):
 opts['similarity'] = '100'
 matcher = scmutil.match(repo[None], pats, opts)
-return scmutil.addremove(repo, matcher, "", opts)
+relative = scmutil.anypats(pats, opts)
+uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=relative)
+return scmutil.addremove(repo, matcher, "", uipathfn, opts)
 
 @command('annotate|blame',
 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2391,7 +2391,9 @@
 dsguard = dirstateguard.dirstateguard(repo, 'commit')
 with dsguard or util.nullcontextmanager():
 if dsguard:
-if scmutil.addremove(repo, matcher, "", opts) != 0:
+relative = scmutil.anypats(pats, opts)
+uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=relative)
+if scmutil.addremove(repo, matcher, "", uipathfn, opts) != 0:
 raise error.Abort(
 _("failed 

D5901: add: pass around uipathfn and use instead of m.rel() (API)

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

REVISION SUMMARY
  For now, the uipathfn we pass around always prints relative paths just
  like before, so this should have no effect. Well, there's one little
  change: I also made the "skipping missing subrepository: %s\n" message
  relative.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/scmutil.py
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -287,7 +287,7 @@
 """
 raise NotImplementedError
 
-def add(self, ui, match, prefix, explicitonly, **opts):
+def add(self, ui, match, prefix, uipathfn, explicitonly, **opts):
 return []
 
 def addremove(self, matcher, prefix, opts):
@@ -516,8 +516,9 @@
 self._repo.vfs.write('hgrc', util.tonativeeol(''.join(lines)))
 
 @annotatesubrepoerror
-def add(self, ui, match, prefix, explicitonly, **opts):
-return cmdutil.add(ui, self._repo, match, prefix, explicitonly, **opts)
+def add(self, ui, match, prefix, uipathfn, explicitonly, **opts):
+return cmdutil.add(ui, self._repo, match, prefix, uipathfn,
+   explicitonly, **opts)
 
 @annotatesubrepoerror
 def addremove(self, m, prefix, opts):
@@ -1590,7 +1591,7 @@
 return False
 
 @annotatesubrepoerror
-def add(self, ui, match, prefix, explicitonly, **opts):
+def add(self, ui, match, prefix, uipathfn, explicitonly, **opts):
 if self._gitmissing():
 return []
 
@@ -1614,7 +1615,7 @@
 if exact:
 command.append("-f") #should be added, even if ignored
 if ui.verbose or not exact:
-ui.status(_('adding %s\n') % match.rel(f))
+ui.status(_('adding %s\n') % uipathfn(f))
 
 if f in tracked:  # hg prints 'adding' even if already tracked
 if exact:
@@ -1624,7 +1625,7 @@
 self._gitcommand(command + [f])
 
 for f in rejected:
-ui.warn(_("%s already tracked!\n") % match.rel(f))
+ui.warn(_("%s already tracked!\n") % uipathfn(f))
 
 return rejected
 
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -11,6 +11,7 @@
 import glob
 import hashlib
 import os
+import posixpath
 import re
 import subprocess
 import weakref
@@ -758,6 +759,10 @@
 else:
 return lambda f: f
 
+def subdiruipathfn(subpath, uipathfn):
+'''Create a new uipathfn that treats the file as relative to subpath.'''
+return lambda f: uipathfn(posixpath.join(subpath, f))
+
 def expandpats(pats):
 '''Expand bare globs when running on windows.
 On posix we assume it already has already been done by sh.'''
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -180,7 +180,8 @@
 """
 
 m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts))
-rejected = cmdutil.add(ui, repo, m, "", False, **opts)
+uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=True)
+rejected = cmdutil.add(ui, repo, m, "", uipathfn, False, **opts)
 return rejected and 1 or 0
 
 @command('addremove',
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2027,7 +2027,7 @@
 
 return iterate()
 
-def add(ui, repo, match, prefix, explicitonly, **opts):
+def add(ui, repo, match, prefix, uipathfn, explicitonly, **opts):
 bad = []
 
 badfn = lambda x, y: bad.append(x) or match.bad(x, y)
@@ -2051,21 +2051,24 @@
 cca(f)
 names.append(f)
 if ui.verbose or not exact:
-ui.status(_('adding %s\n') % match.rel(f),
+ui.status(_('adding %s\n') % uipathfn(f),
   label='ui.addremove.added')
 
 for subpath in sorted(wctx.substate):
 sub = wctx.sub(subpath)
 try:
 submatch = matchmod.subdirmatcher(subpath, match)
 subprefix = repo.wvfs.reljoin(prefix, subpath)
+subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn)
 if opts.get(r'subrepos'):
-bad.extend(sub.add(ui, submatch, subprefix, False, **opts))
+bad.extend(sub.add(ui, submatch, subprefix, subuipathfn, False,
+   **opts))
 else:
-bad.extend(sub.add(ui, submatch, subprefix, True, **opts))
+bad.extend(sub.add(ui, submatch, subprefix, subuipathfn, True,
+   **opts))
 except error.LookupError:
 ui.status(_("skipping missing subrepository: 

D5902: remove: pass around uipathfn and use instead of m.rel()

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

REVISION SUMMARY
  Same as previous commit, but now for remove.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -358,7 +358,7 @@
 def forget(self, match, prefix, dryrun, interactive):
 return ([], [])
 
-def removefiles(self, matcher, prefix, after, force, subrepos,
+def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos,
 dryrun, warnings):
 """remove the matched files from the subrepository and the filesystem,
 possibly by force and/or after the file has been removed from the
@@ -841,9 +841,9 @@
   True, dryrun=dryrun, interactive=interactive)
 
 @annotatesubrepoerror
-def removefiles(self, matcher, prefix, after, force, subrepos,
+def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos,
 dryrun, warnings):
-return cmdutil.remove(self.ui, self._repo, matcher, prefix,
+return cmdutil.remove(self.ui, self._repo, matcher, prefix, uipathfn,
   after, force, subrepos, dryrun)
 
 @annotatesubrepoerror
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4716,7 +4716,8 @@
 
 m = scmutil.match(repo[None], pats, opts)
 subrepos = opts.get('subrepos')
-return cmdutil.remove(ui, repo, m, "", after, force, subrepos,
+uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=True)
+return cmdutil.remove(ui, repo, m, "", uipathfn, after, force, subrepos,
   dryrun=dryrun)
 
 @command('rename|move|mv',
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2192,7 +2192,8 @@
 
 return ret
 
-def remove(ui, repo, m, prefix, after, force, subrepos, dryrun, warnings=None):
+def remove(ui, repo, m, prefix, uipathfn, after, force, subrepos, dryrun,
+   warnings=None):
 ret = 0
 s = repo.status(match=m, clean=True)
 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
@@ -2211,12 +2212,13 @@
 for subpath in subs:
 submatch = matchmod.subdirmatcher(subpath, m)
 subprefix = repo.wvfs.reljoin(prefix, subpath)
+subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn)
 if subrepos or m.exact(subpath) or any(submatch.files()):
 progress.increment()
 sub = wctx.sub(subpath)
 try:
-if sub.removefiles(submatch, subprefix, after, force, subrepos,
-   dryrun, warnings):
+if sub.removefiles(submatch, subprefix, subuipathfn, after,
+   force, subrepos, dryrun, warnings):
 ret = 1
 except error.LookupError:
 warnings.append(_("skipping missing subrepository: %s\n")
@@ -2244,10 +2246,10 @@
 if repo.wvfs.exists(f):
 if repo.wvfs.isdir(f):
 warnings.append(_('not removing %s: no tracked files\n')
-% m.rel(f))
+% uipathfn(f))
 else:
 warnings.append(_('not removing %s: file is untracked\n')
-% m.rel(f))
+% uipathfn(f))
 # missing files will generate a warning elsewhere
 ret = 1
 progress.complete()
@@ -2263,7 +2265,7 @@
 progress.increment()
 if ui.verbose or (f in files):
 warnings.append(_('not removing %s: file still exists\n')
-% m.rel(f))
+% uipathfn(f))
 ret = 1
 progress.complete()
 else:
@@ -2274,12 +2276,12 @@
 for f in modified:
 progress.increment()
 warnings.append(_('not removing %s: file is modified (use -f'
-  ' to force removal)\n') % m.rel(f))
+  ' to force removal)\n') % uipathfn(f))
 ret = 1
 for f in added:
 progress.increment()
 warnings.append(_("not removing %s: file has been marked for add"
-  " (use 'hg forget' to undo add)\n") % m.rel(f))
+  " (use 'hg forget' to undo add)\n") % uipathfn(f))
 ret = 1
 progress.complete()
 
@@ -2289,7 +2291,7 @@
 for f in list:
 if ui.verbose or not m.exact(f):
 progress.increment()
-ui.status(_('removing %s\n') % m.rel(f),
+ui.status(_('removing %s\n') % uipathfn(f),

D5904: largefiles: use uipathfn instead of match.{rel,uipath}()

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

REVISION SUMMARY
  All callers now pass in a uipathfn, so we can just use that instead of
  choosing the right match function. This also means that when we make
  add/remove respect ui.relative-paths, it will work for largefiles too.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/overrides.py

CHANGE DETAILS

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -78,7 +78,7 @@
 m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
 return m
 
-def addlargefiles(ui, repo, isaddremove, matcher, **opts):
+def addlargefiles(ui, repo, isaddremove, matcher, uipathfn, **opts):
 large = opts.get(r'large')
 lfsize = lfutil.getminsize(
 ui, lfutil.islfilesrepo(repo), opts.get(r'lfsize'))
@@ -99,17 +99,11 @@
 nfile = f in wctx
 exists = lfile or nfile
 
-# addremove in core gets fancy with the name, add doesn't
-if isaddremove:
-name = m.uipath(f)
-else:
-name = m.rel(f)
-
 # Don't warn the user when they attempt to add a normal tracked file.
 # The normal add code will do that for us.
 if exact and exists:
 if lfile:
-ui.warn(_('%s already a largefile\n') % name)
+ui.warn(_('%s already a largefile\n') % uipathfn(f))
 continue
 
 if (exact or not exists) and not lfutil.isstandin(f):
@@ -123,7 +117,7 @@
 if large or abovemin or (lfmatcher and lfmatcher(f)):
 lfnames.append(f)
 if ui.verbose or not exact:
-ui.status(_('adding %s as a largefile\n') % name)
+ui.status(_('adding %s as a largefile\n') % uipathfn(f))
 
 bad = []
 
@@ -150,7 +144,7 @@
 added = [f for f in lfnames if f not in bad]
 return added, bad
 
-def removelargefiles(ui, repo, isaddremove, matcher, dryrun, **opts):
+def removelargefiles(ui, repo, isaddremove, matcher, uipathfn, dryrun, **opts):
 after = opts.get(r'after')
 m = composelargefilematcher(matcher, repo[None].manifest())
 try:
@@ -186,12 +180,7 @@
 lfdirstate = lfutil.openlfdirstate(ui, repo)
 for f in sorted(remove):
 if ui.verbose or not m.exact(f):
-# addremove in core gets fancy with the name, remove doesn't
-if isaddremove:
-name = m.uipath(f)
-else:
-name = m.rel(f)
-ui.status(_('removing %s\n') % name)
+ui.status(_('removing %s\n') % uipathfn(f))
 
 if not dryrun:
 if not after:
@@ -240,7 +229,7 @@
 if opts.get(r'normal'):
 return orig(ui, repo, matcher, prefix, uipathfn, explicitonly, **opts)
 
-ladded, lbad = addlargefiles(ui, repo, False, matcher, **opts)
+ladded, lbad = addlargefiles(ui, repo, False, matcher, uipathfn, **opts)
 normalmatcher = composenormalfilematcher(matcher, repo[None].manifest(),
  ladded)
 bad = orig(ui, repo, normalmatcher, prefix, uipathfn, explicitonly, **opts)
@@ -254,8 +243,8 @@
 normalmatcher = composenormalfilematcher(matcher, repo[None].manifest())
 result = orig(ui, repo, normalmatcher, prefix, uipathfn, after, force,
   subrepos, dryrun)
-return removelargefiles(ui, repo, False, matcher, dryrun, after=after,
-force=force) or result
+return removelargefiles(ui, repo, False, matcher, uipathfn, dryrun,
+after=after, force=force) or result
 
 @eh.wrapfunction(subrepo.hgsubrepo, 'status')
 def overridestatusfn(orig, repo, rev2, **opts):
@@ -1250,11 +1239,11 @@
 matchfn = m.matchfn
 m.matchfn = lambda f: f in s.deleted and matchfn(f)
 
-removelargefiles(repo.ui, repo, True, m, opts.get('dry_run'),
+removelargefiles(repo.ui, repo, True, m, uipathfn, opts.get('dry_run'),
  **pycompat.strkwargs(opts))
 # Call into the normal add code, and any files that *should* be added as
 # largefiles will be
-added, bad = addlargefiles(repo.ui, repo, True, matcher,
+added, bad = addlargefiles(repo.ui, repo, True, matcher, uipathfn,
**pycompat.strkwargs(opts))
 # Now that we've handled largefiles, hand off to the original addremove
 # function to take care of the rest.  Make sure it doesn't do anything with



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


Re: [PATCH] convert: handle exec bit removal while converting to svn

2019-02-08 Thread Augie Fackler
queued, thanks

> On Feb 7, 2019, at 14:21, Nikita Slyusarev  wrote:
> 
> # HG changeset patch
> # User Nikita Slyusarev 
> # Date 1549565330 -10800
> #  Thu Feb 07 21:48:50 2019 +0300
> # Node ID afd7bd1378b43b306567245ac0e394c4432e944d
> # Parent  286eeed148932d53eab7193c8e5deda39f9131f9
> convert: handle exec bit removal while converting to svn
> 
> Subversion `putcommit` method checks original file's executablity to decide
> if executable property should be removed from svn. It is checked right after
> writing file contents.
> 
> Content writing is implemented using `vfs.write` and vfs seems to remove exec
> bit, at least in some cases. This leads to executability checks being
> ineffective. If cset contains only this ignored exec bit removal, conversion
> stops with an error, because it fails to to compose svn commit properly.
> 
> This fix moves exec bit checking so that it's performed before dumping file
> contents.
> 
> Added test to check executable bit removal.
> 
> diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
> --- a/hgext/convert/subversion.py
> +++ b/hgext/convert/subversion.py
> @@ -1206,10 +1206,18 @@
> os.unlink(filename)
> except OSError:
> pass
> +
> +if self.is_exec:
> +# We need to check executability of the file before the 
> change,
> +# because `vfs.write` is able to reset exec bit.
> +wasexec = False
> +if os.path.exists(self.wjoin(filename)):
> +wasexec = self.is_exec(self.wjoin(filename))
> +
> self.wopener.write(filename, data)
> 
> if self.is_exec:
> -if self.is_exec(self.wjoin(filename)):
> +if wasexec:
> if 'x' not in flags:
> self.delexec.append(filename)
> else:
> diff --git a/tests/test-convert-svn-sink.t b/tests/test-convert-svn-sink.t
> --- a/tests/test-convert-svn-sink.t
> +++ b/tests/test-convert-svn-sink.t
> @@ -466,3 +466,42 @@
>   msg: Add file a
>A /a
>   $ rm -rf a a-hg a-hg-wc
> +
> +#if execbit
> +
> +Executable bit removal
> +
> +  $ hg init a
> +
> +  $ echo a > a/exec
> +  $ chmod +x a/exec
> +  $ hg --cwd a ci -d '1 0' -A -m 'create executable'
> +  adding exec
> +  $ chmod -x a/exec
> +  $ hg --cwd a ci -d '2 0' -A -m 'remove executable bit'
> +
> +  $ hg convert -d svn a
> +  assuming destination a-hg
> +  initializing svn repository 'a-hg'
> +  initializing svn working copy 'a-hg-wc'
> +  scanning source...
> +  sorting...
> +  converting...
> +  1 create executable
> +  0 remove executable bit
> +  $ svnupanddisplay a-hg-wc 0
> +   2 2 test .
> +   2 2 test exec
> +  revision: 2
> +  author: test
> +  msg: remove executable bit
> +   M /exec
> +  revision: 1
> +  author: test
> +  msg: create executable
> +   A /exec
> +  $ test ! -x a-hg-wc/exec
> +
> +  $ rm -rf a a-hg a-hg-wc
> +
> +#endif
> ___
> 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


Re: [PATCH] convert: handle empty intial commits while converting to svn

2019-02-08 Thread Augie Fackler
queued, thanks

> On Feb 7, 2019, at 13:18, Nikita Slyusarev  wrote:
> 
> # HG changeset patch
> # User Nikita Slyusarev 
> # Date 1549555074 -10800
> #  Thu Feb 07 18:57:54 2019 +0300
> # Node ID bde6d4eed3104a49c9d4558907d1af4af8718ba1
> # Parent  67e622ade4155d89270ec7ce6928f5645317a5c1
> convert: handle empty intial commits while converting to svn
> 
> Svn commit generation code skips empty commits, returning the parent.
> Skipping the root commit must return None instead.
> 
> Added test to check skipping of empty commits.
> 
> diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
> --- a/hgext/convert/subversion.py
> +++ b/hgext/convert/subversion.py
> @@ -1324,8 +1324,8 @@
> try:
> rev = self.commit_re.search(output).group(1)
> except AttributeError:
> -if parents and not files:
> -return parents[0]
> +if not files:
> +return parents[0] if parents else None
> self.ui.warn(_('unexpected svn output:\n'))
> self.ui.warn(output)
> raise error.Abort(_('unable to cope with svn output'))
> diff --git a/tests/test-convert-svn-sink.t b/tests/test-convert-svn-sink.t
> --- a/tests/test-convert-svn-sink.t
> +++ b/tests/test-convert-svn-sink.t
> @@ -466,3 +466,46 @@
>   msg: Add file a
>A /a
>   $ rm -rf a a-hg a-hg-wc
> +
> +Skipping empty commits
> +
> +  $ hg init a
> +
> +  $ hg --cwd a --config ui.allowemptycommit=True ci -d '1 0' -m 'Initial 
> empty commit'
> +
> +  $ echo a > a/a
> +  $ hg --cwd a ci -d '0 0' -A -m 'Some change'
> +  adding a
> +  $ hg --cwd a --config ui.allowemptycommit=True ci -d '2 0' -m 'Empty 
> commit 1'
> +  $ hg --cwd a --config ui.allowemptycommit=True ci -d '3 0' -m 'Empty 
> commit 2'
> +  $ echo b > a/b
> +  $ hg --cwd a ci -d '0 0' -A -m 'Another change'
> +  adding b
> +
> +  $ hg convert -d svn a
> +  assuming destination a-hg
> +  initializing svn repository 'a-hg'
> +  initializing svn working copy 'a-hg-wc'
> +  scanning source...
> +  sorting...
> +  converting...
> +  4 Initial empty commit
> +  3 Some change
> +  2 Empty commit 1
> +  1 Empty commit 2
> +  0 Another change
> +
> +  $ svnupanddisplay a-hg-wc 0
> +   2 1 test a
> +   2 2 test .
> +   2 2 test b
> +  revision: 2
> +  author: test
> +  msg: Another change
> +   A /b
> +  revision: 1
> +  author: test
> +  msg: Some change
> +   A /a
> +
> +  $ rm -rf a a-hg a-hg-wc
> ___
> 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


D5900: subrepo: (mostly) use relative path in "skipping missing subrepository"

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

REVISION SUMMARY
  This is consistent with the other messages printed by these
  functions. Note that addremove is a little different and prints
  absolute (aka repo-relative) paths if no argument was given.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1040,7 +1040,6 @@
 similarity /= 100.0
 
 ret = 0
-join = lambda f: os.path.join(prefix, f)
 
 wctx = repo[None]
 for subpath in sorted(wctx.substate):
@@ -1053,7 +1052,7 @@
 ret = 1
 except error.LookupError:
 repo.ui.status(_("skipping missing subrepository: %s\n")
- % join(subpath))
+ % m.uipath(subpath))
 
 rejected = []
 def badfn(f, msg):
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2028,7 +2028,6 @@
 return iterate()
 
 def add(ui, repo, match, prefix, explicitonly, **opts):
-join = lambda f: os.path.join(prefix, f)
 bad = []
 
 badfn = lambda x, y: bad.append(x) or match.bad(x, y)
@@ -2066,7 +2065,7 @@
 bad.extend(sub.add(ui, submatch, subprefix, True, **opts))
 except error.LookupError:
 ui.status(_("skipping missing subrepository: %s\n")
-   % join(subpath))
+   % match.rel(subpath))
 
 if not opts.get(r'dry_run'):
 rejected = wctx.add(names, prefix)
@@ -2085,7 +2084,6 @@
 def forget(ui, repo, match, prefix, explicitonly, dryrun, interactive):
 if dryrun and interactive:
 raise error.Abort(_("cannot specify both --dry-run and --interactive"))
-join = lambda f: os.path.join(prefix, f)
 bad = []
 badfn = lambda x, y: bad.append(x) or match.bad(x, y)
 wctx = repo[None]
@@ -2107,7 +2105,7 @@
 forgot.extend([subpath + '/' + f for f in subforgot])
 except error.LookupError:
 ui.status(_("skipping missing subrepository: %s\n")
-   % join(subpath))
+   % match.rel(subpath))
 
 if not explicitonly:
 for f in match.files():
@@ -2187,12 +2185,11 @@
 ret = 0
 except error.LookupError:
 ui.status(_("skipping missing subrepository: %s\n")
-   % m.abs(subpath))
+   % m.rel(subpath))
 
 return ret
 
 def remove(ui, repo, m, prefix, after, force, subrepos, dryrun, warnings=None):
-join = lambda f: os.path.join(prefix, f)
 ret = 0
 s = repo.status(match=m, clean=True)
 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
@@ -2220,7 +2217,7 @@
 ret = 1
 except error.LookupError:
 warnings.append(_("skipping missing subrepository: %s\n")
-   % join(subpath))
+   % m.rel(subpath))
 progress.complete()
 
 # warn about failure to delete explicit files/dirs
@@ -2364,12 +2361,13 @@
 sub = ctx.sub(subpath)
 try:
 submatch = matchmod.subdirmatcher(subpath, matcher)
-subprefix = os.path.join(prefix, sub._path)
+subprefix = os.path.join(prefix, subpath)
 if not sub.cat(submatch, basefm, fntemplate, subprefix,
**pycompat.strkwargs(opts)):
 err = 0
 except error.RepoLookupError:
-ui.status(_("skipping missing subrepository: %s\n") % subprefix)
+ui.status(_("skipping missing subrepository: %s\n") %
+  matcher.rel(subpath))
 
 return err
 



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


D5899: subrepo: use relative path for "already tracked" message

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

REVISION SUMMARY
  From 
https://phab.mercurial-scm.org/rHG932de135041fc944af1c3df21ff251522f8236b6 
(subrepo: warn when adding already tracked files in
  gitsubrepo, 2015-02-27):
  
The file is printed with abs() to be consistent with how it is
printed in workingctx, even though that is inconsistent with how
added files are printed in verbose mode.
  
  However, a few year later, the same author wrote 
https://phab.mercurial-scm.org/rHG7008f6819002bc01bcc8626f2ff41af0949096c4
  (context: name files relative to cwd in warning messages, 2017-07-11)
  and now it's inconsistent. This fixes that inconsistency.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1624,7 +1624,7 @@
 self._gitcommand(command + [f])
 
 for f in rejected:
-ui.warn(_("%s already tracked!\n") % match.abs(f))
+ui.warn(_("%s already tracked!\n") % match.rel(f))
 
 return rejected
 



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


D5746: status: introduce higher-level ui.relative-paths

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a subscriber: mharbison72.
martinvonz added a comment.


  Btw, @mharbison72, I think now that we have this new `getuipathfn()`, we have 
a single place to update to get \-separated paths on Windows. I believe we 
should replace the `lambda f: f` by `platform.localpath`. That should give you 
local paths in output from more and more commands as we switch them over to 
using the function.

REPOSITORY
  rHG Mercurial

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

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


D5898: debugignore: respect ui.relative-paths

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

REVISION SUMMARY
  Not because I care about this, but I want to get rid of match.uipath()
  and it's easier to respect the config than not.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1086,6 +1086,7 @@
 ui.write("%s\n" % pycompat.byterepr(ignore))
 else:
 m = scmutil.match(repo[None], pats=files)
+uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
 for f in m.files():
 nf = util.normpath(f)
 ignored = None
@@ -1102,16 +1103,16 @@
 break
 if ignored:
 if ignored == nf:
-ui.write(_("%s is ignored\n") % m.uipath(f))
+ui.write(_("%s is ignored\n") % uipathfn(f))
 else:
 ui.write(_("%s is ignored because of "
"containing folder %s\n")
- % (m.uipath(f), ignored))
+ % (uipathfn(f), ignored))
 ignorefile, lineno, line = ignoredata
 ui.write(_("(ignore rule in %s, line %d: '%s')\n")
  % (ignorefile, lineno, line))
 else:
-ui.write(_("%s is not ignored\n") % m.uipath(f))
+ui.write(_("%s is not ignored\n") % uipathfn(f))
 
 @command('debugindex', cmdutil.debugrevlogopts + cmdutil.formatteropts,
  _('-c|-m|FILE'))



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


D5897: test: stabilize test-wireproto-exchangev2.t flaky output

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  This test fails for me too quite frequently, so thanks for fixing! I've added 
indygreg as reviewer since they know this area best.

REPOSITORY
  rHG Mercurial

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

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


D5897: test: stabilize test-wireproto-exchangev2.t flaky output

2019-02-08 Thread lothiraldan (Boris Feld)
lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When running the test suite with multiple processes, we often get flaky
  outputs, like here: https://ci.octobus.net/job/MercurialPy2/267/console
  
-  received frame(size=0; request=1; stream=2; streamflags=; 
type=command-response; flags=eos)
   add changeset cd2534766bec
   add changeset e96ae20f4188
   add changeset caa2a465451d
+  received frame(size=0; request=1; stream=2; streamflags=; 
type=command-response; flags=eos)
  
  Instead of simply sorting the clone and pull output, I saved the output in a
  separate file and checked the `received frame` messages on one side and then
  the rest of the output on the other side. This way we conserve the order of
  messages as it seems important.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-wireproto-exchangev2.t

CHANGE DETAILS

diff --git a/tests/test-wireproto-exchangev2.t 
b/tests/test-wireproto-exchangev2.t
--- a/tests/test-wireproto-exchangev2.t
+++ b/tests/test-wireproto-exchangev2.t
@@ -36,22 +36,18 @@
 
 Test basic clone
 
-  $ hg --debug clone -U http://localhost:$HGPORT client-simple
+Output is flaky, save it in a file and check part independently
+  $ hg --debug clone -U http://localhost:$HGPORT client-simple > clone-output
+
+  $ cat clone-output | grep -v "received frame"
   using http://localhost:$HGPORT/
   sending capabilities command
   query 1; heads
   sending 2 commands
   sending command heads: {}
   sending command known: {
 'nodes': []
   }
-  received frame(size=9; request=1; stream=2; streamflags=stream-begin; 
type=stream-settings; flags=eos)
-  received frame(size=11; request=1; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
-  received frame(size=43; request=1; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
-  received frame(size=0; request=1; stream=2; streamflags=; 
type=command-response; flags=eos)
-  received frame(size=11; request=3; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
-  received frame(size=1; request=3; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
-  received frame(size=0; request=3; stream=2; streamflags=; 
type=command-response; flags=eos)
   sending 1 commands
   sending command changesetdata: {
 'fields': set([
@@ -71,10 +67,6 @@
   }
 ]
   }
-  received frame(size=9; request=1; stream=2; streamflags=stream-begin; 
type=stream-settings; flags=eos)
-  received frame(size=11; request=1; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
-  received frame(size=941; request=1; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
-  received frame(size=0; request=1; stream=2; streamflags=; 
type=command-response; flags=eos)
   add changeset 3390ef850073
   add changeset 4432d83626e8
   add changeset cd2534766bec
@@ -97,10 +89,6 @@
 ],
 'tree': ''
   }
-  received frame(size=9; request=1; stream=2; streamflags=stream-begin; 
type=stream-settings; flags=eos)
-  received frame(size=11; request=1; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
-  received frame(size=992; request=1; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
-  received frame(size=0; request=1; stream=2; streamflags=; 
type=command-response; flags=eos)
   sending 1 commands
   sending command filesdata: {
 'fields': set([
@@ -121,13 +109,32 @@
   }
 ]
   }
+  updating the branch cache
+  new changesets 3390ef850073:caa2a465451d (3 drafts)
+  (sent 5 HTTP requests and * bytes; received * bytes in responses) (glob)
+
+  $ cat clone-output | grep "received frame"
+  received frame(size=9; request=1; stream=2; streamflags=stream-begin; 
type=stream-settings; flags=eos)
+  received frame(size=11; request=1; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
+  received frame(size=43; request=1; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
+  received frame(size=0; request=1; stream=2; streamflags=; 
type=command-response; flags=eos)
+  received frame(size=11; request=3; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
+  received frame(size=1; request=3; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
+  received frame(size=0; request=3; stream=2; streamflags=; 
type=command-response; flags=eos)
+  received frame(size=9; request=1; stream=2; streamflags=stream-begin; 
type=stream-settings; flags=eos)
+  received frame(size=11; request=1; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
+  received frame(size=941; request=1; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
+  received frame(size=0; request=1; stream=2; 

mercurial@41612: 14 new changesets

2019-02-08 Thread Mercurial Commits
14 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/106b0bec162a
changeset:   41599:106b0bec162a
user:Martin von Zweigbergk 
date:Mon Feb 04 21:10:17 2019 -0800
summary: mq: migrate to scmutil.backuppath()

https://www.mercurial-scm.org/repo/hg/rev/a8ccd821b7d2
changeset:   41600:a8ccd821b7d2
user:Martin von Zweigbergk 
date:Mon Feb 04 21:14:37 2019 -0800
summary: filemerge: migrate to scmutil.backuppath()

https://www.mercurial-scm.org/repo/hg/rev/ac8cf125d8d5
changeset:   41601:ac8cf125d8d5
user:Martin von Zweigbergk 
date:Mon Feb 04 21:19:05 2019 -0800
summary: merge: migrate to scmutil.backuppath()

https://www.mercurial-scm.org/repo/hg/rev/92bd3d86f2e0
changeset:   41602:92bd3d86f2e0
user:Martin von Zweigbergk 
date:Mon Feb 04 21:31:18 2019 -0800
summary: resolve: migrate to scmutil.backuppath()

https://www.mercurial-scm.org/repo/hg/rev/ea5ebb8f72bd
changeset:   41603:ea5ebb8f72bd
user:Martin von Zweigbergk 
date:Tue Feb 05 09:43:34 2019 -0800
summary: subrepo: migrate to scmutil.backuppath()

https://www.mercurial-scm.org/repo/hg/rev/e944cf4ce1a8
changeset:   41604:e944cf4ce1a8
user:Martin von Zweigbergk 
date:Tue Feb 05 09:44:22 2019 -0800
summary: scmutil: delete now-unused origpath() (API)

https://www.mercurial-scm.org/repo/hg/rev/7068c6b0114b
changeset:   41605:7068c6b0114b
user:Martin von Zweigbergk 
date:Tue Feb 05 10:30:05 2019 -0800
summary: revert: respect ui.relative-paths

https://www.mercurial-scm.org/repo/hg/rev/eeab8c1c926b
changeset:   41606:eeab8c1c926b
user:Martin von Zweigbergk 
date:Wed Jan 30 16:21:30 2019 -0800
summary: locate: respect ui.relative-paths

https://www.mercurial-scm.org/repo/hg/rev/698667eb7523
changeset:   41607:698667eb7523
user:Matt Harbison 
date:Wed Feb 06 22:30:49 2019 -0500
summary: lfs: disable all authentication except Basic for HTTP(S) 
connections

https://www.mercurial-scm.org/repo/hg/rev/67e622ade415
changeset:   41608:67e622ade415
user:Matt Harbison 
date:Wed Feb 06 23:41:36 2019 -0500
summary: tests: stabilize test-extdiff.t on Windows

https://www.mercurial-scm.org/repo/hg/rev/286eeed14893
changeset:   41609:286eeed14893
user:Boris Feld 
date:Thu Feb 07 17:04:15 2019 +0100
summary: fsmonitor: rename new verbose config knob

https://www.mercurial-scm.org/repo/hg/rev/d683aca738cd
changeset:   41610:d683aca738cd
user:Martin von Zweigbergk 
date:Wed Feb 06 22:32:50 2019 -0800
summary: diffordiffstat: avoid looking up contexts twice

https://www.mercurial-scm.org/repo/hg/rev/4bf166a020a7
changeset:   41611:4bf166a020a7
user:Martin von Zweigbergk 
date:Thu Feb 07 21:48:24 2019 -0800
summary: context: delete unused undelete()

https://www.mercurial-scm.org/repo/hg/rev/fbd4ce55bcbd
changeset:   41612:fbd4ce55bcbd
bookmark:@
tag: tip
user:Martin von Zweigbergk 
date:Thu Feb 07 21:16:25 2019 -0800
summary: context: replace repeated "self._repo.dirstate" by "ds" variable

-- 
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


D5792: uncommit: added interactive mode(issue6062)

2019-02-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @pulkit Apparently it seems removing `-n` flag altogether will not interfere 
with the tests and they can be completed without that flag too . I have added 
inline comments please review.

INLINE COMMENTS

> test-uncommit-interactive.t:134
> +
> +
> +  $ hg uncommit -i< test-uncommit-interactive.t:253
> +   3
> +
> +  $ hg uncommit -i

[PATCH STABLE] subrepo: add test for Windows relative-ish path with drive letter

2019-02-08 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1549540241 -32400
#  Thu Feb 07 20:50:41 2019 +0900
# Branch stable
# Node ID adf01cdceea20b5ad6dacb11dbb1d94e5055e39c
# Parent  87a6e3c953e045d92147925fc71aad7c327fdbfd
subrepo: add test for Windows relative-ish path with drive letter

Matt Harbison pointed out that Windows had some weird path syntax.
Fortunately it's rejected appropriately by pathauditor, so we're safe.
Let's test the behavior as we have a special handling for Windows drive
letters.

This patch includes a basic example. Maybe we'll need to extend the test
case further, but writing such tests on Linux isn't easy.

diff --git a/tests/test-audit-subrepo.t b/tests/test-audit-subrepo.t
--- a/tests/test-audit-subrepo.t
+++ b/tests/test-audit-subrepo.t
@@ -660,3 +660,44 @@ then pull (and update):
   $ cd ..
 
 #endif
+
+Test drive letter
+-
+
+Windows has a weird relative path that can change the drive letter, which
+should also be prohibited on Windows.
+
+prepare tampered repo:
+
+  $ hg init driveletter
+  $ cd driveletter
+  $ hg import --bypass -qm 'add subrepo "X:"' - <<'EOF'
+  > diff --git a/.hgsub b/.hgsub
+  > new file mode 100644
+  > --- /dev/null
+  > +++ b/.hgsub
+  > @@ -0,0 +1,1 @@
+  > +X: = foo
+  > diff --git a/.hgsubstate b/.hgsubstate
+  > new file mode 100644
+  > --- /dev/null
+  > +++ b/.hgsubstate
+  > @@ -0,0 +1,1 @@
+  > + X:
+  > EOF
+  $ cd ..
+
+on clone (and update):
+
+#if windows
+
+  $ hg clone -q driveletter driveletter2
+  abort: path contains illegal component: X:
+
+#else
+
+  $ hg clone -q driveletter driveletter2
+  $ ls driveletter2
+  X:
+
+#endif
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5792: uncommit: added interactive mode(issue6062)

2019-02-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 13915.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5792?vs=13738=13915

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

AFFECTED FILES
  hgext/uncommit.py
  tests/test-uncommit-interactive.t
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -34,6 +34,7 @@
   
   options ([+] can be repeated):
   
+   -i --interactive interactive mode to uncommit
   --keepallow an empty commit after uncommiting
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
diff --git a/tests/test-uncommit-interactive.t 
b/tests/test-uncommit-interactive.t
new file mode 100644
--- /dev/null
+++ b/tests/test-uncommit-interactive.t
@@ -0,0 +1,969 @@
+
+||  The test for `hg uncommit --interactive`  ||
+
+
+Repo Setup
+
+
+  $ cat >> $HGRCPATH < [ui]
+  > interactive = true
+  > [experimental]
+  > evolution.createmarkers=True
+  > evolution.allowunstable=True
+  > uncommitondirtywdir = true
+  > [extensions]
+  > uncommit =
+  > amend =
+  > drawdag=$TESTDIR/drawdag.py
+  > EOF
+  $ glog() {
+  >   hg log -G --template '{rev}:{node|short}@{branch}({separate("/", 
obsolete, phase)}) {desc|firstline}\n' "$@"
+  > }
+
+  $ hg init repo
+  $ cd repo
+
+  $ touch a
+  $ cat >> a << EOF
+  > 1
+  > 2
+  > 3
+  > 4
+  > 5
+  > EOF
+
+  $ hg add a
+  $ hg ci -m "The base commit"
+
+Make sure aborting the interactive selection does no magic
+--
+
+  $ hg status
+  $ hg uncommit -i< q
+  > EOF
+  diff --git a/a b/a
+  new file mode 100644
+  examine changes to 'a'? [Ynesfdaq?] q
+  
+  abort: user quit
+  [255]
+  $ hg status
+
+Make a commit with multiple hunks
+-
+
+  $ cat > a << EOF
+  > -2
+  > -1
+  > 0
+  > 1
+  > 2
+  > 3
+  > foo
+  > bar
+  > 4
+  > 5
+  > babar
+  > EOF
+
+  $ hg diff
+  diff -r 7733902a8d94 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,5 +1,11 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  +babar
+
+  $ hg ci -m "another one"
+
+Not selecting anything to uncommit
+==
+
+  $ hg uncommit -i< y
+  > n
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+  abort: nothing selected to uncommit
+  [255]
+  $ hg status
+
+Uncommit a chunk
+
+
+  $ hg uncommit -i< y
+  > y
+  > n
+  > n
+  > EOF
+  diff --git a/a b/a
+  3 hunks, 6 lines changed
+  examine changes to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+  discard change 1/3 to 'a'? [Ynesfdaq?] y
+  
+  @@ -1,5 +4,7 @@
+   1
+   2
+   3
+  +foo
+  +bar
+   4
+   5
+  discard change 2/3 to 'a'? [Ynesfdaq?] n
+  
+  @@ -4,2 +9,3 @@
+   4
+   5
+  +babar
+  discard change 3/3 to 'a'? [Ynesfdaq?] n
+  
+
+  $ hg log -G --hidden
+  @  changeset:   3:678a59e5ff90
+  |  tag: tip
+  |  parent:  0:7733902a8d94
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: another one
+  |
+  | x  changeset:   2:e9635f4beaf1
+  |/   parent:  0:7733902a8d94
+  |user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:pruned using uncommit
+  |summary: temporary commit for uncommiting f70fb463d5bf
+  |
+  | x  changeset:   1:f70fb463d5bf
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsolete:rewritten using uncommit as 3:678a59e5ff90
+  |summary: another one
+  |
+  o  changeset:   0:7733902a8d94
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: The base commit
+  
+The unselected part should be in the diff
+-
+
+  $ hg diff
+  diff -r 678a59e5ff90 a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,3 +1,6 @@
+  +-2
+  +-1
+  +0
+   1
+   2
+   3
+
+The commit should contain the rest of part
+--
+
+  $ hg exp
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #  Thu Jan 01 00:00:00 1970 +
+  # Node ID 678a59e5ff90754d5e94719bd82ad169be773c21
+  # Parent  7733902a8d94c789ca81d866bea1893d79442db6
+  another one
+  
+  

D5638: branchmap: encapsulate cache updating in the map itself

2019-02-08 Thread mjpieters (Martijn Pieters)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG328ca3b9e545: branchmap: encapsulate cache updating in the 
map itself (authored by mjpieters, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5638?vs=13543=13914

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

AFFECTED FILES
  contrib/perf.py
  mercurial/branchmap.py
  mercurial/localrepo.py
  mercurial/statichttprepo.py
  mercurial/streamclone.py

CHANGE DETAILS

diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -13,7 +13,6 @@
 
 from .i18n import _
 from . import (
-branchmap,
 cacheutil,
 error,
 narrowspec,
@@ -174,7 +173,7 @@
 repo._writerequirements()
 
 if rbranchmap:
-branchmap.replacecache(repo, rbranchmap)
+repo._branchcaches.replace(repo, rbranchmap)
 
 repo.invalidate()
 
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -13,6 +13,7 @@
 
 from .i18n import _
 from . import (
+branchmap,
 changelog,
 error,
 localrepo,
@@ -193,7 +194,7 @@
 self.changelog = changelog.changelog(self.svfs)
 self._tags = None
 self.nodetagscache = None
-self._branchcaches = {}
+self._branchcaches = branchmap.BranchMapCache()
 self._revbranchcache = None
 self.encodepats = None
 self.decodepats = None
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -992,7 +992,7 @@
 
 self._dirstatevalidatewarned = False
 
-self._branchcaches = {}
+self._branchcaches = branchmap.BranchMapCache()
 self._revbranchcache = None
 self._filterpats = {}
 self._datafilters = {}
@@ -1520,8 +1520,7 @@
 def branchmap(self):
 '''returns a dictionary {branch: [branchheads]} with branchheads
 ordered by increasing revision number'''
-branchmap.updatecache(self)
-return self._branchcaches[self.filtername]
+return self._branchcaches[self]
 
 @unfilteredmethod
 def revbranchcache(self):
@@ -2073,9 +2072,9 @@
 return
 
 if tr is None or tr.changes['origrepolen'] < len(self):
-# updating the unfiltered branchmap should refresh all the others,
+# accessing the 'ser ved' branchmap should refresh all the others,
 self.ui.debug('updating the branch cache\n')
-branchmap.updatecache(self.filtered('served'))
+self.filtered('served').branchmap()
 
 if full:
 rbc = self.revbranchcache()
@@ -2093,7 +2092,7 @@
 # can't use delattr on proxy
 del self.__dict__[r'_tagscache']
 
-self.unfiltered()._branchcaches.clear()
+self._branchcaches.clear()
 self.invalidatevolatilesets()
 self._sparsesignaturecache.clear()
 
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -43,75 +43,89 @@
'served': 'immutable',
'immutable': 'base'}
 
-def updatecache(repo):
-"""Update the cache for the given filtered view on a repository"""
-# This can trigger updates for the caches for subsets of the filtered
-# view, e.g. when there is no cache for this filtered view or the cache
-# is stale.
+
+class BranchMapCache(object):
+"""Cache mapping"""
+def __init__(self):
+self._per_filter = {}
 
-cl = repo.changelog
-filtername = repo.filtername
-bcache = repo._branchcaches.get(filtername)
-if bcache is None or not bcache.validfor(repo):
-# cache object missing or cache object stale? Read from disk
-bcache = branchcache.fromfile(repo)
+def __getitem__(self, repo):
+self.updatecache(repo)
+return self._per_filter[repo.filtername]
+
+def updatecache(self, repo):
+"""Update the cache for the given filtered view on a repository"""
+# This can trigger updates for the caches for subsets of the filtered
+# view, e.g. when there is no cache for this filtered view or the cache
+# is stale.
 
-revs = []
-if bcache is None:
-# no (fresh) cache available anymore, perhaps we can re-use
-# the cache for a subset, then extend that to add info on missing
-# revisions.
-subsetname = subsettable.get(filtername)
-if subsetname is not None:
-subset = repo.filtered(subsetname)
-bcache = subset.branchmap().copy()
-extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
-revs.extend(r for r in extrarevs if r <= bcache.tiprev)
-else:
-# nothing to fall back on, start empty.
-

D5889: context: replace repeated "self._repo.dirstate" by "ds" variable

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGfbd4ce55bcbd: context: replace repeated 
self._repo.dirstate by ds variable (authored by 
martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5889?vs=13903=13913

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1355,13 +1355,13 @@
 uipath = lambda f: ds.pathto(pathutil.join(prefix, f))
 rejected = []
 for f in files:
-if f not in self._repo.dirstate:
+if f not in ds:
 self._repo.ui.warn(_("%s not tracked!\n") % uipath(f))
 rejected.append(f)
-elif self._repo.dirstate[f] != 'a':
-self._repo.dirstate.remove(f)
+elif ds[f] != 'a':
+ds.remove(f)
 else:
-self._repo.dirstate.drop(f)
+ds.drop(f)
 return rejected
 
 def copy(self, source, dest):
@@ -1379,11 +1379,12 @@
% self._repo.dirstate.pathto(dest))
 else:
 with self._repo.wlock():
-if self._repo.dirstate[dest] in '?':
-self._repo.dirstate.add(dest)
-elif self._repo.dirstate[dest] in 'r':
-self._repo.dirstate.normallookup(dest)
-self._repo.dirstate.copy(source, dest)
+ds = self._repo.dirstate
+if ds[dest] in '?':
+ds.add(dest)
+elif ds[dest] in 'r':
+ds.normallookup(dest)
+ds.copy(source, dest)
 
 def match(self, pats=None, include=None, exclude=None, default='glob',
   listsubrepos=False, badfn=None):



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


D5888: context: delete unused undelete()

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4bf166a020a7: context: delete unused undelete() (authored 
by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5888?vs=13902=13912

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1364,19 +1364,6 @@
 self._repo.dirstate.drop(f)
 return rejected
 
-def undelete(self, list):
-pctxs = self.parents()
-with self._repo.wlock():
-ds = self._repo.dirstate
-for f in list:
-if self._repo.dirstate[f] != 'r':
-self._repo.ui.warn(_("%s not removed!\n") % ds.pathto(f))
-else:
-fctx = f in pctxs[0] and pctxs[0][f] or pctxs[1][f]
-t = fctx.data()
-self._repo.wwrite(f, t, fctx.flags())
-self._repo.dirstate.normal(f)
-
 def copy(self, source, dest):
 try:
 st = self._repo.wvfs.lstat(dest)



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


D5890: diffordiffstat: avoid looking up contexts twice

2019-02-08 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd683aca738cd: diffordiffstat: avoid looking up contexts 
twice (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5890?vs=13904=13911

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

AFFECTED FILES
  mercurial/logcmdutil.py

CHANGE DETAILS

diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -58,6 +58,8 @@
changes=None, stat=False, fp=None, graphwidth=0,
prefix='', root='', listsubrepos=False, hunksfilterfn=None):
 '''show diff or diffstat.'''
+ctx1 = repo[node1]
+ctx2 = repo[node2]
 if root:
 relroot = pathutil.canonpath(repo.root, repo.getcwd(), root)
 else:
@@ -78,9 +80,8 @@
 if not ui.plain():
 width = ui.termwidth() - graphwidth
 
-chunks = repo[node2].diff(repo[node1], match, changes, opts=diffopts,
-  prefix=prefix, relroot=relroot,
-  hunksfilterfn=hunksfilterfn)
+chunks = ctx2.diff(ctx1, match, changes, opts=diffopts, prefix=prefix,
+   relroot=relroot, hunksfilterfn=hunksfilterfn)
 
 if fp is not None or ui.canwritewithoutlabels():
 out = fp or ui
@@ -105,8 +106,6 @@
 ui.write(chunk, label=label)
 
 if listsubrepos:
-ctx1 = repo[node1]
-ctx2 = repo[node2]
 for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
 tempnode2 = node2
 try:



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


Re: [PATCH] py3: manually replace `None` with 'None' in ui.log() arguments

2019-02-08 Thread Yuya Nishihara
On Thu, 07 Feb 2019 17:55:47 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison 
> # Date 1549312475 18000
> #  Mon Feb 04 15:34:35 2019 -0500
> # Node ID b6bdc25edf05318a4571b4f34a741754f5052567
> # Parent  a263b7d71105414c9a1234414747533ce904ba39
> py3: manually replace `None` with 'None' in ui.log() arguments
> 
> Pushing to a real server with py3 (while fixing the digest authentication
> issues) spit out this:
> 
>   Traceback (most recent call last):
>   ...
>   File "c:\users\jenkins\mercurial\mercurial\commands.py", line 4635, in push
> opargs=opargs)
>   File "c:\users\jenkins\mercurial\hgext\lfs\wrapper.py", line 340, in push
> return orig(repo, remote, *args, **kwargs)
>   File "c:\users\jenkins\mercurial\mercurial\exchange.py", line 566, in push
> _pushbundle2(pushop)
>   File "c:\users\jenkins\mercurial\mercurial\exchange.py", line 1138, in 
> _pushbundle2
> ret = partgen(pushop, bundler)
>   File "c:\users\jenkins\mercurial\mercurial\exchange.py", line 909, in 
> _pushb2ctx
> if not _pushcheckoutgoing(pushop):
>   File "c:\users\jenkins\mercurial\mercurial\exchange.py", line 804, in 
> _pushcheckoutgoing
> discovery.checkheads(pushop)
>   File "c:\users\jenkins\mercurial\mercurial\discovery.py", line 341, in 
> checkheads
> headssum = _headssummary(pushop)
>   File "c:\users\jenkins\mercurial\mercurial\discovery.py", line 244, in 
> _headssummary
> newmap.update(repo, (ctx.rev() for ctx in missingctx))
>   File "c:\users\jenkins\mercurial\mercurial\branchmap.py", line 344, in 
> update
> repo.filtername, duration)
>   File "c:\users\jenkins\mercurial\mercurial\ui.py", line 1813, in log
> msg = msgfmt % msgargs
> TypeError: %b requires a bytes-like object, or an object that implements 
> __bytes__, not 'NoneType'
> 
> I don't think blackbox is at fault- we just need to have some loggers active.
> 
> Passing `repo.filtername or b''` at this branchmap call-site also fixed the
> issue, but there are other places where `repo.filtername` is getting logged as
> well.  This seems like the easiest fix.
> 
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -1810,7 +1810,15 @@ class ui(object):
>   if l.tracked(event)]
>  if not activeloggers:
>  return
> -msg = msgfmt % msgargs
> +
> +def _filternone(x):
> +return x is None and b'None' or x
> +
> +def _format(msgfmt, *msgargs):
> +return msgfmt % msgargs
> +
> +msg = _format(msgfmt, *[_filternone(a) for a in msgargs])

This is a bug of ui.log() caller. Maybe we should use '%r' instead.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Bug 6075] New: explicit GC on every request make repositories with thousands of largesfiles very slow to clone

2019-02-08 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6075

Bug ID: 6075
   Summary: explicit GC on every request make repositories with
thousands of largesfiles very slow to clone
   Product: Mercurial
   Version: 4.9
  Hardware: All
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: hgweb
  Assignee: bugzi...@mercurial-scm.org
  Reporter: las...@unity3d.com
CC: mercurial-devel@mercurial-scm.org

Created attachment 2032
  --> https://bz.mercurial-scm.org/attachment.cgi?id=2032=edit
demo output of lfpull from two hgwebs

in mercurial 4.5.3 this:


 finally:
# There are known cycles in localrepository that prevent
# those objects (and tons of held references) from being
# collected through normal refcounting. We mitigate those
# leaks by performing an explicit GC on every request.
# TODO remove this once leaks are fixed.
# TODO only run this on requests that create localrepository
# instances instead of every request.
gc.collect()
===

was added to "def run_wsgi(self, req, res):" in mercurial/hgweb/hgwebdir_mod.py
and is still present in latest version. This is a problem for repositories with
thousands of largesfile, as each largefile equals a request on initial clone.

at Unity We e.g. have a repository with ~17000 largefiles, and albeit that is a
pourly provisioned repostory, it takes ~15 minutes to clone from hwgeb running
on mercurial 4.5.2, and 2-4 hours on mercurial 4.5.3 and later which doenst
play well with our CI. 

I've made a docker image to debug this issue:

https://github.com/lasse-aagren/hgweb-gc-debug-docker.

If created as hgweb-demo:latest and run as:

docker run --rm -it hgweb-demo:latest /hgweb/lfpull-test.sh

it will spin up 2 hg serve instances, one on 4.5.2 and one on 4.5.3, on top a
demorepo with 1000 4k largefiles. It will then clone 3 consecutive time from
hgweb standalon on 4.5.2 and then 3 times from hgweb standalone on 4.5.3.

Result is attached, but the important points is, all 3 lfpulls from 4.5.2 takes
~60secs each. 

With 4.5.3 the first lfpull of the  1000 files takes ~60sec, the next one takes
~120 secs and the third ~180 secs. And it just get worse from there.

If I use mercurial 4.9 with the "gc.collect()" replaced by a "pass", it
performs as with version 4.5.2 and before.

Is my oberservations correct, and can something be done to mitigate it?

Please dont hesitate to ask me for further information.

Best regards,
Lasse Aagren

-- 
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


D5894: patch: replace "prefix" and "relroot" arguments by "pathfn" (API)

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

REVISION SUMMARY
  The two arguments serve a very similar purpose: "relroot" is stripped
  from the front of the path, and then "prefix" (a subrepo path) is
  added (also to the front). Passing in a function that does that is
  more generic and will make it easier to respect ui.relative-paths in
  later patches (don't worry, I'm not going to respect that option for
  regular patches, only for --stat). I'm deliberately not calling it
  "uipathfn", because it's generally for producing valid diffs
  (including when prefix is non-empty), so things like using backslash
  on Windows is not an option.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/context.py
  mercurial/logcmdutil.py
  mercurial/patch.py

CHANGE DETAILS

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -15,7 +15,6 @@
 import errno
 import hashlib
 import os
-import posixpath
 import re
 import shutil
 import zlib
@@ -2239,7 +2238,7 @@
 difffeatureopts = diffutil.difffeatureopts
 
 def diff(repo, node1=None, node2=None, match=None, changes=None,
- opts=None, losedatafn=None, prefix='', relroot='', copy=None,
+ opts=None, losedatafn=None, pathfn=None, copy=None,
  copysourcematch=None, hunksfilterfn=None):
 '''yields diff of changes to files between two nodes, or node and
 working directory.
@@ -2277,9 +2276,8 @@
 ctx2 = repo[node2]
 
 for fctx1, fctx2, hdr, hunks in diffhunks(
-repo, ctx1=ctx1, ctx2=ctx2,
-match=match, changes=changes, opts=opts,
-losedatafn=losedatafn, prefix=prefix, relroot=relroot, copy=copy,
+repo, ctx1=ctx1, ctx2=ctx2, match=match, changes=changes, 
opts=opts,
+losedatafn=losedatafn, pathfn=pathfn, copy=copy,
 copysourcematch=copysourcematch):
 if hunksfilterfn is not None:
 # If the file has been removed, fctx2 is None; but this should
@@ -2294,9 +2292,8 @@
 if text:
 yield text
 
-def diffhunks(repo, ctx1, ctx2, match=None, changes=None,
-  opts=None, losedatafn=None, prefix='', relroot='', copy=None,
-  copysourcematch=None):
+def diffhunks(repo, ctx1, ctx2, match=None, changes=None, opts=None,
+  losedatafn=None, pathfn=None, copy=None, copysourcematch=None):
 """Yield diff of changes to files in the form of (`header`, `hunks`) tuples
 where `header` is a list of diff headers and `hunks` is an iterable of
 (`hunkrange`, `hunklines`) tuples.
@@ -2376,7 +2373,7 @@
 
 def difffn(opts, losedata):
 return trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
-   copy, getfilectx, opts, losedata, prefix, relroot)
+   copy, getfilectx, opts, losedata, pathfn)
 if opts.upgrade and not opts.git:
 try:
 def losedata(fn):
@@ -2591,16 +2588,14 @@
 yield f1, f2, copyop
 
 def trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
-copy, getfilectx, opts, losedatafn, prefix, relroot):
+copy, getfilectx, opts, losedatafn, pathfn):
 '''given input data, generate a diff and yield it in blocks
 
 If generating a diff would lose data like flags or binary data and
 losedatafn is not None, it will be called.
 
-relroot is removed and prefix is added to every path in the diff output.
-
-If relroot is not empty, this function expects every path in modified,
-added, removed and copy to start with it.'''
+pathfn is applied to every path in the diff output.
+'''
 
 def gitindex(text):
 if not text:
@@ -2628,12 +2623,8 @@
 
 gitmode = {'l': '12', 'x': '100755', '': '100644'}
 
-if relroot != '' and (repo.ui.configbool('devel', 'all-warnings')
-  or repo.ui.configbool('devel', 'check-relroot')):
-for f in modified + added + removed + list(copy) + list(copy.values()):
-if f is not None and not f.startswith(relroot):
-raise AssertionError(
-"file %s doesn't start with relroot %s" % (f, relroot))
+if not pathfn:
+pathfn = lambda f: f
 
 for f1, f2, copyop in _filepairs(modified, added, removed, copy, opts):
 content1 = None
@@ -2670,10 +2661,8 @@
 (f1 and f2 and flag1 != flag2)):
 losedatafn(f2 or f1)
 
-path1 = f1 or f2
-path2 = f2 or f1
-path1 = posixpath.join(prefix, path1[len(relroot):])
-path2 = posixpath.join(prefix, path2[len(relroot):])
+path1 = pathfn(f1 or f2)
+path2 = pathfn(f2 or f1)
 header = []
 if opts.git:
 header.append('diff --git %s%s %s%s' %
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- 

D5896: diff: make --stat respect ui.relative-paths

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

REVISION SUMMARY
  It would have been easy to make all diffs respect ui.relative-paths,
  but we don't want that since it makes the diff invalid. Perhaps it
  makes sense to do that with --noprefix since the point of that is to
  make paths that are easy to copy, and the diff is already
  invalid anyway. But this patch just makes the --stat version respect
  the config option. The --stat view is not even close to a valid diff,
  so I think it makes sense to show the paths in more human-friendly
  form.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/logcmdutil.py
  tests/test-diffstat.t

CHANGE DETAILS

diff --git a/tests/test-diffstat.t b/tests/test-diffstat.t
--- a/tests/test-diffstat.t
+++ b/tests/test-diffstat.t
@@ -146,10 +146,21 @@
   $ hg diff --stat .
dir1/new |  1 +
1 files changed, 1 insertions(+), 0 deletions(-)
+  $ hg diff --stat . --config ui.relative-paths=yes
+   new |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
   $ hg diff --stat --root .
new |  1 +
1 files changed, 1 insertions(+), 0 deletions(-)
 
+  $ hg diff --stat --root . --config ui.relative-paths=yes
+   new |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
+--root trumps ui.relative-paths
+  $ hg diff --stat --root .. --config ui.relative-paths=yes
+   new |  1 +
+   ../dir2/new |  1 +
+   2 files changed, 2 insertions(+), 0 deletions(-)
   $ hg diff --stat --root ../dir1 ../dir2
   warning: ../dir2 not inside relative root .
 
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -98,6 +98,9 @@
 width = 80
 if not ui.plain():
 width = ui.termwidth() - graphwidth
+# If an explicit --root was given, don't respect ui.relative-paths
+if not relroot:
+pathfn = compose(scmutil.getuipathfn(repo), pathfn)
 
 chunks = ctx2.diff(ctx1, match, changes, opts=diffopts, pathfn=pathfn,
copysourcematch=copysourcematch,



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


D5892: patch: let caller pass in root-filtering matcher (API)

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

REVISION SUMMARY
  The --root option to `hg diff` does two things:
  
  - Shows paths relative to the given root
  - Filters paths by the given root, including copy sources
  
  The root argument is passed through down to patch.diff(). I feel like
  we can make patch.diff() more generic by not passing down the root
  argument, but instead pass:
  
  - A function for taking a repo-relative path and printing it. I want to reuse 
this for showing cwd-relative paths later. This is the actual motivation for 
this patch.
  - A matcher that's already been filtered by the root argument
  - A second matcher that filters the copy sources
  
  This is one step towards that.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/logcmdutil.py
  mercurial/patch.py

CHANGE DETAILS

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -32,7 +32,6 @@
 encoding,
 error,
 mail,
-match as matchmod,
 mdiff,
 pathutil,
 pycompat,
@@ -2320,10 +2319,6 @@
 return getfilectx
 getfilectx = lrugetfilectx()
 
-if relroot:
-relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path')
-match = matchmod.intersectmatchers(match, relrootmatch)
-
 if not changes:
 changes = ctx1.status(ctx2, match=match)
 modified, added, removed = changes[:3]
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -74,6 +74,9 @@
 ui.warn(_('warning: %s not inside relative root %s\n') % (
 match.uipath(matchroot), uirelroot))
 
+relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path')
+match = matchmod.intersectmatchers(match, relrootmatch)
+
 if stat:
 diffopts = diffopts.copy(context=0, noprefix=False)
 width = 80



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


D5895: diff: make `hg diff --root=subrepo` work

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

REVISION SUMMARY
  The root prefix is currently stripped before adding the subrepo
  prefix. It seems to me that if you run `hg diff --root=subrepo` and a
  subrepo/ path is visited (say "subrepo/foo"), then the path generated
  for the diff would initially be just "foo" and we then fail (if the
  developer warning is active) to strip the "subrepo/" from the path. It
  seems like we should first add the prefix in order to produce a path
  that's relative to the top-level repo, and then we can remove the root
  prefix from that. There are no tests for this, it seems, and I don't
  care enough to add one.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/logcmdutil.py

CHANGE DETAILS

diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -66,6 +66,8 @@
 else:
 relroot = ''
 copysourcematch = None
+def compose(f, g):
+return lambda x: f(g(x))
 def pathfn(f):
 return posixpath.join(prefix, f)
 if relroot != '':
@@ -84,11 +86,12 @@
 
 checkroot = (repo.ui.configbool('devel', 'all-warnings') or
  repo.ui.configbool('devel', 'check-relroot'))
-def pathfn(f):
+def relrootpathfn(f):
 if checkroot and not f.startswith(relroot):
 raise AssertionError(
 "file %s doesn't start with relroot %s" % (f, relroot))
-return posixpath.join(prefix, f[len(relroot):])
+return f[len(relroot):]
+pathfn = compose(relrootpathfn, pathfn)
 
 if stat:
 diffopts = diffopts.copy(context=0, noprefix=False)



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


D5891: patch: pass in context objects into diffhunks() (API)

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

REVISION SUMMARY
  It's a pretty low-level function and having the contexts in
  patch.diff() makes future patches easier.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hgweb/webutil.py
  mercurial/patch.py

CHANGE DETAILS

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2268,8 +2268,14 @@
 hunksfilterfn, if not None, should be a function taking a filectx and
 hunks generator that may yield filtered hunks.
 '''
+if not node1 and not node2:
+node1 = repo.dirstate.p1()
+
+ctx1 = repo[node1]
+ctx2 = repo[node2]
+
 for fctx1, fctx2, hdr, hunks in diffhunks(
-repo, node1=node1, node2=node2,
+repo, ctx1=ctx1, ctx2=ctx2,
 match=match, changes=changes, opts=opts,
 losedatafn=losedatafn, prefix=prefix, relroot=relroot, copy=copy,
 ):
@@ -2286,7 +2292,7 @@
 if text:
 yield text
 
-def diffhunks(repo, node1=None, node2=None, match=None, changes=None,
+def diffhunks(repo, ctx1, ctx2, match=None, changes=None,
   opts=None, losedatafn=None, prefix='', relroot='', copy=None):
 """Yield diff of changes to files in the form of (`header`, `hunks`) tuples
 where `header` is a list of diff headers and `hunks` is an iterable of
@@ -2298,9 +2304,6 @@
 if opts is None:
 opts = mdiff.defaultopts
 
-if not node1 and not node2:
-node1 = repo.dirstate.p1()
-
 def lrugetfilectx():
 cache = {}
 order = collections.deque()
@@ -2317,9 +2320,6 @@
 return getfilectx
 getfilectx = lrugetfilectx()
 
-ctx1 = repo[node1]
-ctx2 = repo[node2]
-
 if relroot:
 relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path')
 match = matchmod.intersectmatchers(match, relrootmatch)
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -570,11 +570,9 @@
 m = match.always(repo.root, repo.getcwd())
 
 diffopts = patch.diffopts(repo.ui, untrusted=True)
-node1 = basectx.node()
-node2 = ctx.node()
 parity = paritygen(stripecount)
 
-diffhunks = patch.diffhunks(repo, node1, node2, m, opts=diffopts)
+diffhunks = patch.diffhunks(repo, basectx, ctx, m, opts=diffopts)
 for blockno, (fctx1, fctx2, header, hunks) in enumerate(diffhunks, 1):
 if style != 'raw':
 header = header[1:]



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