D7677: typing: suppress a warning that mercurial.windows.checkosfilename is missing

2019-12-15 Thread mharbison72 (Matt Harbison)
Closed by commit rHG09bcbeacedc7: typing: suppress a warning that 
mercurial.windows.checkosfilename is missing (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7677?vs=18741&id=18752

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

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2050,7 +2050,8 @@
 checkosfilename = checkwinfilename
 timer = time.clock
 else:
-checkosfilename = platform.checkosfilename
+# mercurial.windows doesn't have platform.checkosfilename
+checkosfilename = platform.checkosfilename  # pytype: disable=module-attr
 timer = time.time
 
 if safehasattr(time, "perf_counter"):



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


D7666: update: add some tests for the status quo of morestatus on update conflicts

2019-12-15 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG5709a9992c2a: update: add some tests for the status quo of 
morestatus on update conflicts (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7666?vs=18723&id=18753

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

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

AFFECTED FILES
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -1,3 +1,8 @@
+  $ cat >> $HGRCPATH < [commands]
+  > status.verbose=1
+  > EOF
+
 # Construct the following history tree:
 #
 # @  5:e1bb631146ca  b1
@@ -308,6 +313,10 @@
   use 'hg resolve' to retry unresolved file merges
   [1]
   $ rm a.orig
+  $ hg status
+  M a
+  $ hg resolve -l
+  U a
 
 Change/delete conflict is not allowed
   $ hg up -qC 3
@@ -536,10 +545,47 @@
   updated to hidden changeset 6efa171f091b
   (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
   [1]
+
+Test that statuses are reported properly before and after merge resolution.
+  $ rm a.orig
+  $ hg resolve -l
+  U a
+  $ hg status
+  M a
+  M foo
+
   $ hg revert -r . a
+
+  $ rm a.orig
+  $ hg resolve -l
+  U a
+  $ hg status
+  M foo
+  $ hg status -Tjson
+  [
+   {
+"itemtype": "file",
+"path": "foo",
+"status": "M"
+   }
+  ]
+
   $ hg resolve -m
   (no more unresolved files)
 
+  $ hg resolve -l
+  R a
+  $ hg status
+  M foo
+  $ hg status -Tjson
+  [
+   {
+"itemtype": "file",
+"path": "foo",
+"status": "M"
+   }
+  ]
+
 Test that 4 is detected as the no-argument destination from 3 and also moves
 the bookmark with it
   $ hg up --quiet 0  # we should be able to update to 3 directly



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


D7676: typing: add an assertion to util.versiontuple

2019-12-15 Thread mharbison72 (Matt Harbison)
Closed by commit rHGa21a6dad4b38: typing: add an assertion to util.versiontuple 
(authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7676?vs=18740&id=18751

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

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1173,6 +1173,8 @@
 else:
 vparts, extra = m.group(1), None
 
+assert vparts is not None  # help pytype
+
 vints = []
 for i in vparts.split(b'.'):
 try:



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


D7674: typing: add a couple of assertions to lrucachedict to help pytype

2019-12-15 Thread mharbison72 (Matt Harbison)
Closed by commit rHGb5655f337bd7: typing: add a couple of assertions to 
lrucachedict to help pytype (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7674?vs=18738&id=18750

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

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1480,6 +1480,8 @@
 if default is _notset:
 raise
 return default
+
+assert node is not None  # help pytype
 value = node.value
 self.totalcost -= node.cost
 node.markempty()
@@ -1567,6 +1569,8 @@
 while n.key is _notset:
 n = n.prev
 
+assert n is not None  # help pytype
+
 key, value = n.key, n.value
 
 # And remove it from the cache and mark it as empty.



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


D7620: merge: add commands.merge.require-rev to require an argument to hg merge

2019-12-15 Thread spectral (Kyle Lippincott)
Closed by commit rHG8caec25f5d8f: merge: add commands.merge.require-rev to 
require an argument to hg merge (authored by spectral).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7620?vs=18722&id=18742

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  mercurial/helptext/config.txt
  tests/test-merge-default.t
  tests/test-merge-tools.t

CHANGE DETAILS

diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -4,6 +4,8 @@
   $ cat >> $HGRCPATH << EOF
   > [ui]
   > merge=
+  > [commands]
+  > merge.require-rev=True
   > EOF
   $ hg init repo
   $ cd repo
@@ -1908,6 +1910,7 @@
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to 
abandon
   [1]
+(Testing that commands.merge.require-rev doesn't break --abort)
   $ hg merge --abort -q
 
 (for ui.merge, ignored unintentionally)
diff --git a/tests/test-merge-default.t b/tests/test-merge-default.t
--- a/tests/test-merge-default.t
+++ b/tests/test-merge-default.t
@@ -44,9 +44,10 @@
   (run 'hg heads .' to see heads, specify rev with -r)
   [255]
 
-Should succeed:
+Should succeed (we're specifying commands.merge.require-rev=True just to test
+that it allows merge to succeed if we specify a revision):
 
-  $ hg merge 2
+  $ hg merge 2 --config commands.merge.require-rev=True
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg id -Tjson
@@ -63,6 +64,13 @@
   ]
   $ hg commit -mm1
 
+Should fail because we didn't specify a revision (even though it would have
+succeeded without this):
+
+  $ hg merge --config commands.merge.require-rev=True
+  abort: configuration requires specifying revision to merge with
+  [255]
+
 Should succeed - 2 heads:
 
   $ hg merge -P
@@ -88,6 +96,13 @@
}
   ]
 
+Should fail because we didn't specify a revision (even though it would have
+failed without this due to being on tip, but this check comes first):
+
+  $ hg merge --config commands.merge.require-rev=True
+  abort: configuration requires specifying revision to merge with
+  [255]
+
 Should fail because at tip:
 
   $ hg merge
diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -442,6 +442,12 @@
 Show status of files in the working directory after successful commit.
 (default: False)
 
+``merge.require-rev``
+Require that the revision to merge the current commit with be specified on
+the command line. If this is enabled and a revision is not specified, the
+command aborts.
+(default: False)
+
 ``push.require-revs``
 Require revisions to push be specified using one or more mechanisms such as
 specifying them positionally on the command line, using ``-r``, ``-b``,
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -228,6 +228,9 @@
 b'commands', b'grep.all-files', default=False, experimental=True,
 )
 coreconfigitem(
+b'commands', b'merge.require-rev', default=False,
+)
+coreconfigitem(
 b'commands', b'push.require-revs', default=False,
 )
 coreconfigitem(
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4888,6 +4888,13 @@
 node = scmutil.revsingle(repo, node).node()
 
 if not node and not abort:
+if ui.configbool(b'commands', b'merge.require-rev'):
+raise error.Abort(
+_(
+b'configuration requires specifying revision to merge '
+b'with'
+)
+)
 node = repo[destutil.destmerge(repo)].node()
 
 if opts.get(b'preview'):



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


D7673: util: rename a variable to avoid confusing pytype

2019-12-15 Thread mharbison72 (Matt Harbison)
Closed by commit rHGeff050dbb703: util: rename a variable to avoid confusing 
pytype (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7673?vs=18737&id=18749

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

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1195,12 +1195,12 @@
 '''cache the result of function calls'''
 # XXX doesn't handle keywords args
 if func.__code__.co_argcount == 0:
-cache = []
+listcache = []
 
 def f():
-if len(cache) == 0:
-cache.append(func())
-return cache[0]
+if len(listcache) == 0:
+listcache.append(func())
+return listcache[0]
 
 return f
 cache = {}



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


D7672: pytype: suppress the import-error in util.py when importing re2

2019-12-15 Thread mharbison72 (Matt Harbison)
Closed by commit rHG40bd667491a7: pytype: suppress the import-error in util.py 
when importing re2 (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7672?vs=18736&id=18748

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

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2119,7 +2119,7 @@
 
 
 try:
-import re2
+import re2  # pytype: disable=import-error
 
 _re2 = None
 except ImportError:



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


D7632: graft: reuse cmdutl.resolvecommitoptions()

2019-12-15 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHG8376d5d62d36: graft: reuse cmdutl.resolvecommitoptions() 
(authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7632?vs=18667&id=18744

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

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

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
@@ -2971,14 +2971,7 @@
 # list of new nodes created by ongoing graft
 statedata[b'newnodes'] = []
 
-if opts.get(b'user') and opts.get(b'currentuser'):
-raise error.Abort(_(b'--user and --currentuser are mutually 
exclusive'))
-if opts.get(b'date') and opts.get(b'currentdate'):
-raise error.Abort(_(b'--date and --currentdate are mutually 
exclusive'))
-if not opts.get(b'user') and opts.get(b'currentuser'):
-opts[b'user'] = ui.username()
-if not opts.get(b'date') and opts.get(b'currentdate'):
-opts[b'date'] = b"%d %d" % dateutil.makedate()
+cmdutil.resolvecommitoptions(ui, opts)
 
 editor = cmdutil.getcommiteditor(
 editform=b'graft', **pycompat.strkwargs(opts)



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


D7671: debugcommands: finish moving `extendeddateformats` from util to dateutil

2019-12-15 Thread mharbison72 (Matt Harbison)
Closed by commit rHG38d6aa768310: debugcommands: finish moving 
`extendeddateformats` from util to dateutil (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7671?vs=18735&id=18747

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

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

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
@@ -653,7 +653,7 @@
 def debugdate(ui, date, range=None, **opts):
 """parse and display a date"""
 if opts["extended"]:
-d = dateutil.parsedate(date, util.extendeddateformats)
+d = dateutil.parsedate(date, dateutil.extendeddateformats)
 else:
 d = dateutil.parsedate(date)
 ui.writenoi18n(b"internal: %d %d\n" % d)



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


D7670: ui: convert exception data to bytes when printing chained exception info

2019-12-15 Thread mharbison72 (Matt Harbison)
Closed by commit rHGe63b27fb0595: ui: convert exception data to bytes when 
printing chained exception info (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7670?vs=18734&id=18746

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

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

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1857,9 +1857,9 @@
 # exclude frame where 'exc' was chained and rethrown from exctb
 self.write_err(
 b'Traceback (most recent call last):\n',
-b''.join(exctb[:-1]),
-b''.join(causetb),
-b''.join(exconly),
+encoding.strtolocal(''.join(exctb[:-1])),
+encoding.strtolocal(''.join(causetb)),
+encoding.strtolocal(''.join(exconly)),
 )
 else:
 output = traceback.format_exception(exc[0], exc[1], exc[2])



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


D7669: ui: use a context manager to handle file streams in edit()

2019-12-15 Thread mharbison72 (Matt Harbison)
Closed by commit rHGe5f69e3bb3f6: ui: use a context manager to handle file 
streams in edit() (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7669?vs=18733&id=18745

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

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

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1766,9 +1766,8 @@
 prefix=b'hg-' + extra[b'prefix'] + b'-', suffix=suffix, dir=rdir
 )
 try:
-f = os.fdopen(fd, 'wb')
-f.write(util.tonativeeol(text))
-f.close()
+with os.fdopen(fd, 'wb') as f:
+f.write(util.tonativeeol(text))
 
 environ = {b'HGUSER': user}
 if b'transplant_source' in extra:
@@ -1794,9 +1793,8 @@
 blockedtag=b'editor',
 )
 
-f = open(name, 'rb')
-t = util.fromnativeeol(f.read())
-f.close()
+with open(name, 'rb') as f:
+t = util.fromnativeeol(f.read())
 finally:
 os.unlink(name)
 



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


D7664: rebase: make rebase not crash if p1 == p2 != nullid

2019-12-15 Thread spectral (Kyle Lippincott)
Closed by commit rHGc6feee1e4d5b: rebase: make rebase not crash if p1 == p2 != 
nullid (authored by spectral).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7664?vs=18720&id=18743

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

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1791,7 +1791,7 @@
 # But our merge base candidates (D and E in above case) could still be
 # better than the default (ancestor(F, Z) == null). Therefore still
 # pick one (so choose p1 above).
-if sum(1 for b in bases if b != nullrev) > 1:
+if sum(1 for b in set(bases) if b != nullrev) > 1:
 unwanted = [None, None]  # unwanted[i]: unwanted revs if choose 
bases[i]
 for i, base in enumerate(bases):
 if base == nullrev:



To: spectral, 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


D7633: clone: extract helper for checking mutually exclusive args

2019-12-15 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> martinvonz wrote in cmdutil.py:263
> I don't think I'd be able to guess what a function by that name did either.  
> `check_at_most_one_argument` seems clearer, but maybe too long. I'll wait a 
> bit for other ideas before I change anything.

I agree that the current name can be bit misleading. 
`check_at_most_one_argument` seems clearer. Maybe `argument` -> `arg` will make 
it bit smaller ;)

REPOSITORY
  rHG Mercurial

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

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

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


D7632: graft: reuse cmdutl.resolvecommitoptions()

2019-12-15 Thread pulkit (Pulkit Goyal)
This revision is now accepted and ready to land.
pulkit added a comment.
pulkit accepted this revision.


  After this, if both `--currentuser` and `--user` are passed, `--currentuser` 
takes precedence, which is not the behavior right now. But the new behavior is 
better and consistent with other commands.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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


D7677: typing: suppress a warning that mercurial.windows.checkosfilename is missing

2019-12-15 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This function is used to check filename portability everwhere, so it isn't
  tucked into the windows.py module.  I supposed the alternative is to move it 
and
  then alias it in `util`.  I'm guessing it was done like this to save an 
import.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2050,7 +2050,8 @@
 checkosfilename = checkwinfilename
 timer = time.clock
 else:
-checkosfilename = platform.checkosfilename
+# mercurial.windows doesn't have platform.checkosfilename
+checkosfilename = platform.checkosfilename  # pytype: disable=module-attr
 timer = time.time
 
 if safehasattr(time, "perf_counter"):



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


D7676: typing: add an assertion to util.versiontuple

2019-12-15 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Fixes the following warning:
  
line 1177, in versiontuple: No attribute 'split' on None [attribute-error]
 In Optional[bytes]

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1173,6 +1173,8 @@
 else:
 vparts, extra = m.group(1), None
 
+assert vparts is not None  # help pytype
+
 vints = []
 for i in vparts.split(b'.'):
 try:



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


D7675: util: move common proxyobserver attributes to the base class

2019-12-15 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Fixes the following pytype warnings:
  
line 791, in _writedata: No attribute 'logdata' on baseproxyobserver 
[attribute-error]
line 792, in _writedata: No attribute 'logdataapis' on baseproxyobserver 
[attribute-error]
line 793, in _writedata: No attribute 'fh' on baseproxyobserver 
[attribute-error]
line 794, in _writedata: No attribute 'fh' on baseproxyobserver 
[attribute-error]
line 799, in _writedata: No attribute 'logdataapis' on baseproxyobserver 
[attribute-error]
line 800, in _writedata: No attribute 'fh' on baseproxyobserver 
[attribute-error]
line 802, in _writedata: No attribute 'fh' on baseproxyobserver 
[attribute-error]
line 803, in _writedata: No attribute 'name' on baseproxyobserver 
[attribute-error]
line 805, in _writedata: No attribute 'fh' on baseproxyobserver 
[attribute-error]
line 809, in _writedata: No attribute 'logdataapis' on baseproxyobserver 
[attribute-error]
line 810, in _writedata: No attribute 'fh' on baseproxyobserver 
[attribute-error]
line 814, in _writedata: No attribute 'fh' on baseproxyobserver 
[attribute-error]
line 815, in _writedata: No attribute 'name' on baseproxyobserver 
[attribute-error]
line 817, in _writedata: No attribute 'fh' on baseproxyobserver 
[attribute-error]

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -787,6 +787,12 @@
 
 
 class baseproxyobserver(object):
+def __init__(self, fh, name, logdata, logdataapis):
+self.fh = fh
+self.name = name
+self.logdata = logdata
+self.logdataapis = logdataapis
+
 def _writedata(self, data):
 if not self.logdata:
 if self.logdataapis:
@@ -823,10 +829,7 @@
 def __init__(
 self, fh, name, reads=True, writes=True, logdata=False, 
logdataapis=True
 ):
-self.fh = fh
-self.name = name
-self.logdata = logdata
-self.logdataapis = logdataapis
+super(fileobjectobserver, self).__init__(fh, name, logdata, 
logdataapis)
 self.reads = reads
 self.writes = writes
 
@@ -949,13 +952,10 @@
 logdata=False,
 logdataapis=True,
 ):
-self.fh = fh
-self.name = name
+super(socketobserver, self).__init__(fh, name, logdata, logdataapis)
 self.reads = reads
 self.writes = writes
 self.states = states
-self.logdata = logdata
-self.logdataapis = logdataapis
 
 def makefile(self, res, mode=None, bufsize=None):
 if not self.states:



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


D7674: typing: add a couple of assertions to lrucachedict to help pytype

2019-12-15 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Fixes the following warnings:
  
line 1488, in pop: No attribute 'markempty' on None [attribute-error]
 In Optional[Union[Any, _lrucachenode, nothing]]
line 1578, in popoldest: No attribute 'markempty' on None [attribute-error]
 In Optional[Union[Any, _lrucachenode, nothing]]

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1480,6 +1480,8 @@
 if default is _notset:
 raise
 return default
+
+assert node is not None  # help pytype
 value = node.value
 self.totalcost -= node.cost
 node.markempty()
@@ -1567,6 +1569,8 @@
 while n.key is _notset:
 n = n.prev
 
+assert n is not None  # help pytype
+
 key, value = n.key, n.value
 
 # And remove it from the cache and mark it as empty.



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


D7671: debugcommands: finish moving `extendeddateformats` from util to dateutil

2019-12-15 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Caught by pytype.

REPOSITORY
  rHG Mercurial

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

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
@@ -653,7 +653,7 @@
 def debugdate(ui, date, range=None, **opts):
 """parse and display a date"""
 if opts["extended"]:
-d = dateutil.parsedate(date, util.extendeddateformats)
+d = dateutil.parsedate(date, dateutil.extendeddateformats)
 else:
 d = dateutil.parsedate(date)
 ui.writenoi18n(b"internal: %d %d\n" % d)



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


D7673: util: rename a variable to avoid confusing pytype

2019-12-15 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Fixes the following warning:
  
line 1205, in f: No attribute 'append' on Dict[nothing, nothing] 
[attribute-error]
  In Union[Dict[nothing, nothing], list]

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1195,12 +1195,12 @@
 '''cache the result of function calls'''
 # XXX doesn't handle keywords args
 if func.__code__.co_argcount == 0:
-cache = []
+listcache = []
 
 def f():
-if len(cache) == 0:
-cache.append(func())
-return cache[0]
+if len(listcache) == 0:
+listcache.append(func())
+return listcache[0]
 
 return f
 cache = {}



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


D7672: pytype: suppress the import-error in util.py when importing re2

2019-12-15 Thread mharbison72 (Matt Harbison)
mharbison72 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/D7672

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2119,7 +2119,7 @@
 
 
 try:
-import re2
+import re2  # pytype: disable=import-error
 
 _re2 = None
 except ImportError:



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


D7670: ui: convert exception data to bytes when printing chained exception info

2019-12-15 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Caught by pytype.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1857,9 +1857,9 @@
 # exclude frame where 'exc' was chained and rethrown from exctb
 self.write_err(
 b'Traceback (most recent call last):\n',
-b''.join(exctb[:-1]),
-b''.join(causetb),
-b''.join(exconly),
+encoding.strtolocal(''.join(exctb[:-1])),
+encoding.strtolocal(''.join(causetb)),
+encoding.strtolocal(''.join(exconly)),
 )
 else:
 output = traceback.format_exception(exc[0], exc[1], exc[2])



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


D7669: ui: use a context manager to handle file streams in edit()

2019-12-15 Thread mharbison72 (Matt Harbison)
mharbison72 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/D7669

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1766,9 +1766,8 @@
 prefix=b'hg-' + extra[b'prefix'] + b'-', suffix=suffix, dir=rdir
 )
 try:
-f = os.fdopen(fd, 'wb')
-f.write(util.tonativeeol(text))
-f.close()
+with os.fdopen(fd, 'wb') as f:
+f.write(util.tonativeeol(text))
 
 environ = {b'HGUSER': user}
 if b'transplant_source' in extra:
@@ -1794,9 +1793,8 @@
 blockedtag=b'editor',
 )
 
-f = open(name, 'rb')
-t = util.fromnativeeol(f.read())
-f.close()
+with open(name, 'rb') as f:
+t = util.fromnativeeol(f.read())
 finally:
 os.unlink(name)
 



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