D5554: histedit: added rewrite.update-timestamp to fold and mess

2019-01-12 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 13201.
taapas1128 edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5554?vs=13200=13201

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

AFFECTED FILES
  hgext/histedit.py
  tests/mockmakedate.py
  tests/test-histedit-edit.t
  tests/test-histedit-fold.t

CHANGE DETAILS

diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -15,6 +15,7 @@
   > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
   > [extensions]
   > histedit=
+  > mockmakedate = $TESTDIR/mockmakedate.py
   > EOF
 
 
@@ -597,3 +598,105 @@
   o  8f0162e483d0 aa
   
 
+
+-==
+Test update-timestamp config option|
+==
+  $ addwithdate ()
+  > {
+  > echo $1 > $1
+  > hg add $1
+  > hg ci -m $1 -d "$2 0"
+  > }
+
+  $ initrepo ()
+  > {
+  > hg init r
+  > cd r
+  > addwithdate a 1
+  > addwithdate b 2
+  > addwithdate c 3
+  > addwithdate d 4
+  > addwithdate e 5
+  > addwithdate f 6
+  > }
+
+  $ initrepo
+
+log before edit
+  $ hg log
+  changeset:   5:178e35e0ce73
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:06 1970 +
+  summary: f
+  
+  changeset:   4:1ddb6c90f2ee
+  user:test
+  date:Thu Jan 01 00:00:05 1970 +
+  summary: e
+  
+  changeset:   3:532247a8969b
+  user:test
+  date:Thu Jan 01 00:00:04 1970 +
+  summary: d
+  
+  changeset:   2:ff2c9fa2018b
+  user:test
+  date:Thu Jan 01 00:00:03 1970 +
+  summary: c
+  
+  changeset:   1:97d72e5f12c7
+  user:test
+  date:Thu Jan 01 00:00:02 1970 +
+  summary: b
+  
+  changeset:   0:8580ff50825a
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: a
+  
+
+  $ hg histedit 1ddb6c90f2ee --commands - 2>&1 --config 
rewrite.update-timestamp=True < pick 178e35e0ce73 f
+  > fold 1ddb6c90f2ee e
+  > EOF
+
+log after edit
+#observe time from f is updated
+  $ hg log
+  changeset:   4:f7909b1863a2
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: f
+  
+  changeset:   3:532247a8969b
+  user:test
+  date:Thu Jan 01 00:00:04 1970 +
+  summary: d
+  
+  changeset:   2:ff2c9fa2018b
+  user:test
+  date:Thu Jan 01 00:00:03 1970 +
+  summary: c
+  
+  changeset:   1:97d72e5f12c7
+  user:test
+  date:Thu Jan 01 00:00:02 1970 +
+  summary: b
+  
+  changeset:   0:8580ff50825a
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: a
+  
+post-fold manifest
+  $ hg manifest
+  a
+  b
+  c
+  d
+  e
+  f
+
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -4,6 +4,7 @@
   > [extensions]
   > histedit=
   > strip=
+  > mockmakedate = $TESTDIR/mockmakedate.py
   > EOF
 
   $ initrepo ()
@@ -481,3 +482,48 @@
   #  f, fold = use commit, but combine it with the one above
   #  r, roll = like fold, but discard this commit's description and date
   #
+
+
+
+Test update-timestamp config option in mess|
+
+  $ addwithdate ()
+  > {
+  > echo $1 > $1
+  > hg add $1
+  > hg ci -m $1 -d "$2 0"
+  > }
+
+  $ initrepo ()
+  > {
+  > hg init r
+  > cd r
+  > addwithdate a 1
+  > addwithdate b 2
+  > addwithdate c 3
+  > addwithdate d 4
+  > addwithdate e 5
+  > addwithdate f 6
+  > }
+
+  $ initrepo
+
+log before edit
+  $ hg log --limit 1
+  changeset:   5:178e35e0ce73
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:06 1970 +
+  summary: f
+  
+  $ hg histedit tip --commands - 2>&1 --config rewrite.update-timestamp=True 
<< EOF | fixbundle
+  > mess 178e35e0ce73 f
+  > EOF
+log after edit
+  $ hg log --limit 1
+  changeset:   5:98bf456d476b
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: f
+  
diff --git a/tests/mockmakedate.py b/tests/mockmakedate.py
new file mode 100644
--- /dev/null
+++ b/tests/mockmakedate.py
@@ -0,0 +1,19 @@
+from __future__ import absolute_import
+
+# mock out util.makedate() to supply testable values
+import os
+from mercurial import pycompat, util
+from mercurial.utils import dateutil
+
+def mockmakedate():
+filename = os.path.join(os.environ['TESTTMP'], 'testtime')
+try:
+with open(filename, 'rb') as timef:
+time = float(timef.read()) + 1
+except IOError:
+time = 0.0
+with open(filename, 'wb') as timef:
+timef.write(pycompat.bytestr(time))
+return (time, 0)
+
+dateutil.makedate = 

Re: [PATCH 3 of 3] progress: specify updatebar() function by constructor argument

2019-01-12 Thread Martin von Zweigbergk via Mercurial-devel
On Sat, Jan 12, 2019 at 10:48 PM Yuya Nishihara  wrote:

> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1547357805 -32400
> #  Sun Jan 13 14:36:45 2019 +0900
> # Node ID ed29a1a69f505fb8b35e8a36c220a50c99baa4cd
> # Parent  e13ab96098d053c755988b4e94e5c99b203f70e8
> progress: specify updatebar() function by constructor argument


Queued, thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 8 of 8] revset: introduce an API that avoids `formatspec` input serialization

2019-01-12 Thread Boris FELD

On 12/01/2019 06:00, Yuya Nishihara wrote:
> On Fri, 11 Jan 2019 12:29:10 +0100, Boris Feld wrote:
>> # HG changeset patch
>> # User Boris Feld 
>> # Date 1546605681 -3600
>> #  Fri Jan 04 13:41:21 2019 +0100
>> # Node ID 73926c4ab24d6c01723ed050601b134bdc89562f
>> # Parent  4a56fbdacff33c3985bbb84f2e19ddfbd48ed4fa
>> # EXP-Topic revs-efficiency
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
>> 73926c4ab24d
>> revset: introduce an API that avoids `formatspec` input serialization
> The idea looks good.
>
>> +class _inputrules(parser.basealiasrules):
>> +"""replace internal input reference by their actual value"""
>> +
>> +@classmethod
>> +def _getalias(cls, inputs, tree):
>> +if not isinstance(tree, tuple):
>> +return None
>> +if tree[0] != 'func':
>> +return None
>> +if getsymbol(tree[1]) != _internal_input:
>> +return None
>> +idx = int(getsymbol(tree[2]))
>> +newtree = ('func',
>> +   ('symbol', internal_input_func),
>> +   ('smartset', inputs[idx])
>> +)
>> +return parser.alias(idx, None, None, newtree), None
> Perhaps, this can be just ('smartset', ...) node like 'symbol'/'string'.
> There's not point to convert it to a 'func' unless it can be expressed
> as a revset string.
>
> And if we can probably ditch the specialized _inputrules. See below.

We need to combine the smartset with the existing subset. Doing it
within a function seems simpler and less impactful.

>
>> +def formatspecargs(expr, *args):
>> +"""same as formatspec, but preserve some expensive arguments"""
>> +parsed = _parseargs(expr, args)
>> +ret = []
>> +inputs = []
>> +for t, arg in parsed:
>> +if t is None:
>> +ret.append(arg)
>> +if t == 'baseset':
>> +key = '%s(%d)' % (_internal_input, len(inputs))
>> +inputs.append(smartset.baseset(arg))
>> +ret.append(key)
> Maybe we can assign integer (e.g. '$0') for each parameter here, and we can
> just use the _aliasrules.expand() to replace it. '$x' is invalid in user
> expression, so it can be used as a reserved symbol.

Don't we use '$0' for user alias?

Also, I'm not sure what's the value of using alias replacement here. Can
you detail your reasoning?

The alias logic seems pretty tied to having string (that it parses) as
replacement, that is why I used a dedicated object.

>
> raise ProgrammingError if t is not None nor 'baseset'.
>
>> +return (b''.join(ret), inputs)
> If this function returned a parsed tree, we can hide all the implementation
> details in it, and we can probably remove the inputs argument from
> revset.matchany().

But revset/matchany does not take a parsed tree, does it?

Overall. I feel like you have a design adjustment in mind, but I can't
figure out the big picture.

> ___
> 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 7 of 8] revset: detect integer list on parsing

2019-01-12 Thread Boris FELD
On 12/01/2019 05:38, Yuya Nishihara wrote:
> On Fri, 11 Jan 2019 12:29:09 +0100, Boris Feld wrote:
>> # HG changeset patch
>> # User Boris Feld 
>> # Date 1546575973 -3600
>> #  Fri Jan 04 05:26:13 2019 +0100
>> # Node ID 4a56fbdacff33c3985bbb84f2e19ddfbd48ed4fa
>> # Parent  438ea9b8a44c181d62741338c1d16b2031fdda41
>> # EXP-Topic revs-efficiency
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
>> 4a56fbdacff3
>> revset: detect integer list on parsing
>> +if islist and d == 'd' and arg:
>> +# special case, we might be able to speedup the list of int 
>> case
>> +safeinputtype = (list, tuple, set, 
>> smartset.abstractsmartset)
>> +if isinstance(arg, safeinputtype):
> Just curious. What's the unsafe type for example? I think 'arg' may be an
> iterator/generator of ints, but which can be safely converted to list/baseset.

Honestly, I'm not sure.

The code around revset is quite complex and I want to focus on having a
first thing working. The overall speedup from this change is so massive
that I rather have a very narrow version of it quickly and expand it later.

>
>> +# we don't create a baseset yet, because it come with an
>> +# extra cost. If we are going to serialize it we better
>> +# skip it.
>> +ret.append(('baseset', arg))
>> +pos += 1
>> +continue
> ___
> 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 4 of 8] revset: enforce "%d" to be interpreted as literal revision number (API)

2019-01-12 Thread Boris FELD

On 12/01/2019 05:04, Yuya Nishihara wrote:
> On Fri, 11 Jan 2019 12:29:06 +0100, Boris Feld wrote:
>> # HG changeset patch
>> # User Boris Feld 
>> # Date 1547130238 -3600
>> #  Thu Jan 10 15:23:58 2019 +0100
>> # Node ID 38733dd8559578267617514a42f253efabb6
>> # Parent  427247e84e29c144321d21a825d371458b5d3e1a
>> # EXP-Topic revs-efficiency
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
>> 38733dd85595
>> revset: enforce "%d" to be interpreted as literal revision number (API)
> New behavior looks saner. Please also flag this as (BC). It's exposed as
> revset() template function.
>
>>  %r = revset expression, parenthesized
>> -%d = int(arg), no quoting
>> +%d = rev(int(arg)), no quoting
> 'rev(n)' returns an empty set if n is out of range, whereas 'n' aborts.
> Suppose it's pretty much a coding error to pass in an invalid revision to
> repo.revs(), we'll probably want aborts.
>
> Maybe we'll need an internal '_rev()' function?
%ld silently pass on these too, so I would rather have %ld and %d
consistent here (and align on the silence %ld behavior).
>
>>  %s = string(arg), escaped and single-quoted
>>  %b = arg.branch(), escaped and single-quoted
>>  %n = hex(arg), single-quoted
> We might want to map %n to _node() as well, but that isn't required in this
> series.
Yeah, good point. I'll keep this series focused on %d/%ld but will
submit a follow up once this is in.
> ___
> 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


D5554: histedit: added rewrite.update-timestamp to fold and mess

2019-01-12 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  I have extracted mockdate function as `tests/mockdate.py` and dealt with the 
commas and spaces.
  
  >   def commiteditor(self):
  >   """The editor to be used to edit the commit message."""
  > 
  > @@ -800,6 +804,8 @@
  > 
  > 1. date if self.firstdate(): commitopts['date'] = ctx.date() +elif 
ui.configbool('rewrite','update-timestamp'): +commitopts['date'] = 
dateutil.makedate() else: commitopts['date'] = max(ctx.date(), oldctx.date())
  
  Yes this is not right time should be updated everytime update-timestamp is 
True . I have corrected it.

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH 2 of 2] help: document rewrite.backup-bundle option

2019-01-12 Thread Martin von Zweigbergk via Mercurial-devel
On Sat, Jan 12, 2019 at 2:50 AM Yuya Nishihara  wrote:

> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1547282866 -32400
> #  Sat Jan 12 17:47:46 2019 +0900
> # Node ID ead5fb5b2f2908c77aee99cde8b298e407a6efc8
> # Parent  f52ca65e212c9a56eb631c81434c4c1fe262ea68
> help: document rewrite.backup-bundle option
>

Queued, thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5554: histedit: added rewrite.update-timestamp to fold and mess

2019-01-12 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 13200.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5554?vs=13199=13200

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

AFFECTED FILES
  hgext/histedit.py
  tests/mockmakedate.py
  tests/test-histedit-edit.t
  tests/test-histedit-fold.t

CHANGE DETAILS

diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -15,6 +15,7 @@
   > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
   > [extensions]
   > histedit=
+  > mockmakedate = $TESTDIR/mockmakedate.py
   > EOF
 
 
@@ -597,3 +598,105 @@
   o  8f0162e483d0 aa
   
 
+
+-==
+Test update-timestamp config option|
+==
+  $ addwithdate ()
+  > {
+  > echo $1 > $1
+  > hg add $1
+  > hg ci -m $1 -d "$2 0"
+  > }
+
+  $ initrepo ()
+  > {
+  > hg init r
+  > cd r
+  > addwithdate a 1
+  > addwithdate b 2
+  > addwithdate c 3
+  > addwithdate d 4
+  > addwithdate e 5
+  > addwithdate f 6
+  > }
+
+  $ initrepo
+
+log before edit
+  $ hg log
+  changeset:   5:178e35e0ce73
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:06 1970 +
+  summary: f
+  
+  changeset:   4:1ddb6c90f2ee
+  user:test
+  date:Thu Jan 01 00:00:05 1970 +
+  summary: e
+  
+  changeset:   3:532247a8969b
+  user:test
+  date:Thu Jan 01 00:00:04 1970 +
+  summary: d
+  
+  changeset:   2:ff2c9fa2018b
+  user:test
+  date:Thu Jan 01 00:00:03 1970 +
+  summary: c
+  
+  changeset:   1:97d72e5f12c7
+  user:test
+  date:Thu Jan 01 00:00:02 1970 +
+  summary: b
+  
+  changeset:   0:8580ff50825a
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: a
+  
+
+  $ hg histedit 1ddb6c90f2ee --commands - 2>&1 --config 
rewrite.update-timestamp=True < pick 178e35e0ce73 f
+  > fold 1ddb6c90f2ee e
+  > EOF
+
+log after edit
+#observe time from f is updated
+  $ hg log
+  changeset:   4:f7909b1863a2
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: f
+  
+  changeset:   3:532247a8969b
+  user:test
+  date:Thu Jan 01 00:00:04 1970 +
+  summary: d
+  
+  changeset:   2:ff2c9fa2018b
+  user:test
+  date:Thu Jan 01 00:00:03 1970 +
+  summary: c
+  
+  changeset:   1:97d72e5f12c7
+  user:test
+  date:Thu Jan 01 00:00:02 1970 +
+  summary: b
+  
+  changeset:   0:8580ff50825a
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: a
+  
+post-fold manifest
+  $ hg manifest
+  a
+  b
+  c
+  d
+  e
+  f
+
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -4,6 +4,7 @@
   > [extensions]
   > histedit=
   > strip=
+  > mockmakedate = $TESTDIR/mockmakedate.py
   > EOF
 
   $ initrepo ()
@@ -481,3 +482,48 @@
   #  f, fold = use commit, but combine it with the one above
   #  r, roll = like fold, but discard this commit's description and date
   #
+
+
+
+Test update-timestamp config option in mess|
+
+  $ addwithdate ()
+  > {
+  > echo $1 > $1
+  > hg add $1
+  > hg ci -m $1 -d "$2 0"
+  > }
+
+  $ initrepo ()
+  > {
+  > hg init r
+  > cd r
+  > addwithdate a 1
+  > addwithdate b 2
+  > addwithdate c 3
+  > addwithdate d 4
+  > addwithdate e 5
+  > addwithdate f 6
+  > }
+
+  $ initrepo
+
+log before edit
+  $ hg log --limit 1
+  changeset:   5:178e35e0ce73
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:06 1970 +
+  summary: f
+  
+  $ hg histedit tip --commands - 2>&1 --config rewrite.update-timestamp=True 
<< EOF | fixbundle
+  > mess 178e35e0ce73 f
+  > EOF
+log after edit
+  $ hg log --limit 1
+  changeset:   5:98bf456d476b
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: f
+  
diff --git a/tests/mockmakedate.py b/tests/mockmakedate.py
new file mode 100644
--- /dev/null
+++ b/tests/mockmakedate.py
@@ -0,0 +1,19 @@
+from __future__ import absolute_import
+
+# mock out util.makedate() to supply testable values
+import os
+from mercurial import pycompat, util
+from mercurial.utils import dateutil
+
+def mockmakedate():
+filename = os.path.join(os.environ['TESTTMP'], 'testtime')
+try:
+with open(filename, 'rb') as timef:
+time = float(timef.read()) + 1
+except IOError:
+time = 0.0
+with open(filename, 'wb') as timef:
+timef.write(pycompat.bytestr(time))
+return (time, 0)
+
+dateutil.makedate = mockmakedate
diff --git a/hgext/histedit.py 

D5554: histedit: added rewrite.update-timestamp to fold and mess

2019-01-12 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 13199.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5554?vs=13198=13199

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

AFFECTED FILES
  hgext/histedit.py
  tests/mockmakedate.py
  tests/test-histedit-edit.t
  tests/test-histedit-fold.t

CHANGE DETAILS

diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -15,6 +15,7 @@
   > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
   > [extensions]
   > histedit=
+  > mockmakedate = $TESTDIR/mockmakedate.py
   > EOF
 
 
@@ -597,3 +598,105 @@
   o  8f0162e483d0 aa
   
 
+
+-==
+Test update-timestamp config option|
+==
+  $ addwithdate ()
+  > {
+  > echo $1 > $1
+  > hg add $1
+  > hg ci -m $1 -d "$2 0"
+  > }
+
+  $ initrepo ()
+  > {
+  > hg init r
+  > cd r
+  > addwithdate a 1
+  > addwithdate b 2
+  > addwithdate c 3
+  > addwithdate d 4
+  > addwithdate e 5
+  > addwithdate f 6
+  > }
+
+  $ initrepo
+
+log before edit
+  $ hg log
+  changeset:   5:178e35e0ce73
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:06 1970 +
+  summary: f
+  
+  changeset:   4:1ddb6c90f2ee
+  user:test
+  date:Thu Jan 01 00:00:05 1970 +
+  summary: e
+  
+  changeset:   3:532247a8969b
+  user:test
+  date:Thu Jan 01 00:00:04 1970 +
+  summary: d
+  
+  changeset:   2:ff2c9fa2018b
+  user:test
+  date:Thu Jan 01 00:00:03 1970 +
+  summary: c
+  
+  changeset:   1:97d72e5f12c7
+  user:test
+  date:Thu Jan 01 00:00:02 1970 +
+  summary: b
+  
+  changeset:   0:8580ff50825a
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: a
+  
+
+  $ hg histedit 1ddb6c90f2ee --commands - 2>&1 --config 
rewrite.update-timestamp=True < pick 178e35e0ce73 f
+  > fold 1ddb6c90f2ee e
+  > EOF
+
+log after edit
+#observe time from f is updated
+  $ hg log
+  changeset:   4:f7909b1863a2
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: f
+  
+  changeset:   3:532247a8969b
+  user:test
+  date:Thu Jan 01 00:00:04 1970 +
+  summary: d
+  
+  changeset:   2:ff2c9fa2018b
+  user:test
+  date:Thu Jan 01 00:00:03 1970 +
+  summary: c
+  
+  changeset:   1:97d72e5f12c7
+  user:test
+  date:Thu Jan 01 00:00:02 1970 +
+  summary: b
+  
+  changeset:   0:8580ff50825a
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: a
+  
+post-fold manifest
+  $ hg manifest
+  a
+  b
+  c
+  d
+  e
+  f
+
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -4,6 +4,7 @@
   > [extensions]
   > histedit=
   > strip=
+  > mockmakedate = $TESTDIR/mockmakedate.py
   > EOF
 
   $ initrepo ()
@@ -481,3 +482,48 @@
   #  f, fold = use commit, but combine it with the one above
   #  r, roll = like fold, but discard this commit's description and date
   #
+
+
+
+Test update-timestamp config option in mess|
+
+  $ addwithdate ()
+  > {
+  > echo $1 > $1
+  > hg add $1
+  > hg ci -m $1 -d "$2 0"
+  > }
+
+  $ initrepo ()
+  > {
+  > hg init r
+  > cd r
+  > addwithdate a 1
+  > addwithdate b 2
+  > addwithdate c 3
+  > addwithdate d 4
+  > addwithdate e 5
+  > addwithdate f 6
+  > }
+
+  $ initrepo
+
+log before edit
+  $ hg log --limit 1
+  changeset:   5:178e35e0ce73
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:06 1970 +
+  summary: f
+  
+  $ hg histedit tip --commands - 2>&1 --config rewrite.update-timestamp=True 
<< EOF | fixbundle
+  > mess 178e35e0ce73 f
+  > EOF
+log after edit
+  $ hg log --limit 1
+  changeset:   5:98bf456d476b
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: f
+  
diff --git a/tests/mockmakedate.py b/tests/mockmakedate.py
new file mode 100644
--- /dev/null
+++ b/tests/mockmakedate.py
@@ -0,0 +1,17 @@
+# mock out util.makedate() to supply testable values
+import os
+from mercurial import pycompat, util
+from mercurial.utils import dateutil
+
+def mockmakedate():
+filename = os.path.join(os.environ['TESTTMP'], 'testtime')
+try:
+with open(filename, 'rb') as timef:
+time = float(timef.read()) + 1
+except IOError:
+time = 0.0
+with open(filename, 'wb') as timef:
+timef.write(pycompat.bytestr(time))
+return (time, 0)
+
+dateutil.makedate = mockmakedate
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ 

D5554: histedit: added rewrite.update-timestamp to fold and mess

2019-01-12 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 13198.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5554?vs=13197=13198

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

AFFECTED FILES
  hgext/histedit.py
  tests/mockmakedate.py
  tests/test-histedit-edit.t
  tests/test-histedit-fold.t

CHANGE DETAILS

diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -15,6 +15,7 @@
   > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
   > [extensions]
   > histedit=
+  > mockmakedate = $TESTDIR/mockmakedate.py
   > EOF
 
 
@@ -597,3 +598,105 @@
   o  8f0162e483d0 aa
   
 
+
+-==
+Test update-timestamp config option|
+==
+  $ addwithdate ()
+  > {
+  > echo $1 > $1
+  > hg add $1
+  > hg ci -m $1 -d "$2 0"
+  > }
+
+  $ initrepo ()
+  > {
+  > hg init r
+  > cd r
+  > addwithdate a 1
+  > addwithdate b 2
+  > addwithdate c 3
+  > addwithdate d 4
+  > addwithdate e 5
+  > addwithdate f 6
+  > }
+
+  $ initrepo
+
+log before edit
+  $ hg log
+  changeset:   5:178e35e0ce73
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:06 1970 +
+  summary: f
+  
+  changeset:   4:1ddb6c90f2ee
+  user:test
+  date:Thu Jan 01 00:00:05 1970 +
+  summary: e
+  
+  changeset:   3:532247a8969b
+  user:test
+  date:Thu Jan 01 00:00:04 1970 +
+  summary: d
+  
+  changeset:   2:ff2c9fa2018b
+  user:test
+  date:Thu Jan 01 00:00:03 1970 +
+  summary: c
+  
+  changeset:   1:97d72e5f12c7
+  user:test
+  date:Thu Jan 01 00:00:02 1970 +
+  summary: b
+  
+  changeset:   0:8580ff50825a
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: a
+  
+
+  $ hg histedit 1ddb6c90f2ee --commands - 2>&1 --config 
rewrite.update-timestamp=True < pick 178e35e0ce73 f
+  > fold 1ddb6c90f2ee e
+  > EOF
+
+log after edit
+#observe time from f is updated
+  $ hg log
+  changeset:   4:f7909b1863a2
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: f
+  
+  changeset:   3:532247a8969b
+  user:test
+  date:Thu Jan 01 00:00:04 1970 +
+  summary: d
+  
+  changeset:   2:ff2c9fa2018b
+  user:test
+  date:Thu Jan 01 00:00:03 1970 +
+  summary: c
+  
+  changeset:   1:97d72e5f12c7
+  user:test
+  date:Thu Jan 01 00:00:02 1970 +
+  summary: b
+  
+  changeset:   0:8580ff50825a
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: a
+  
+post-fold manifest
+  $ hg manifest
+  a
+  b
+  c
+  d
+  e
+  f
+
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -4,6 +4,7 @@
   > [extensions]
   > histedit=
   > strip=
+  > mockmakedate = $TESTDIR/mockmakedate.py
   > EOF
 
   $ initrepo ()
@@ -481,3 +482,48 @@
   #  f, fold = use commit, but combine it with the one above
   #  r, roll = like fold, but discard this commit's description and date
   #
+
+
+
+Test update-timestamp config option in mess|
+
+  $ addwithdate ()
+  > {
+  > echo $1 > $1
+  > hg add $1
+  > hg ci -m $1 -d "$2 0"
+  > }
+
+  $ initrepo ()
+  > {
+  > hg init r
+  > cd r
+  > addwithdate a 1
+  > addwithdate b 2
+  > addwithdate c 3
+  > addwithdate d 4
+  > addwithdate e 5
+  > addwithdate f 6
+  > }
+
+  $ initrepo
+
+log before edit
+  $ hg log --limit 1
+  changeset:   5:178e35e0ce73
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:06 1970 +
+  summary: f
+  
+  $ hg histedit tip --commands - 2>&1 --config rewrite.update-timestamp=True 
<< EOF | fixbundle
+  > mess 178e35e0ce73 f
+  > EOF
+log after edit
+  $ hg log --limit 1
+  changeset:   5:98bf456d476b
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: f
+  
diff --git a/tests/mockmakedate.py b/tests/mockmakedate.py
new file mode 100644
--- /dev/null
+++ b/tests/mockmakedate.py
@@ -0,0 +1,17 @@
+# mock out util.makedate() to supply testable values
+import os
+from mercurial import pycompat, util
+from mercurial.utils import dateutil
+
+def mockmakedate():
+filename = os.path.join(os.environ['TESTTMP'], 'testtime')
+try:
+with open(filename, 'rb') as timef:
+time = float(timef.read()) + 1
+except IOError:
+time = 0.0
+with open(filename, 'wb') as timef:
+timef.write(pycompat.bytestr(time))
+return (time, 0)
+
+dateutil.makedate = mockmakedate
\ No newline at end of file
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- 

[PATCH] revlog: document that mmap resources are released implicitly by GC

2019-01-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1547358986 -32400
#  Sun Jan 13 14:56:26 2019 +0900
# Node ID eb6ba8bc27e0f8cc28268d6601b97f2c2a63c1c3
# Parent  81fb0d015830b5ddf89b398aa63e0b56501dc6ac
revlog: document that mmap resources are released implicitly by GC

It's okay-ish, but currently the open fd and the mapping itself are leaked
until the indexdata is deallocated. If revlog had close(), the underlying
resources should be closed there as well, but AFAIK there's no such hook
point.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -440,6 +440,8 @@ class revlog(object):
 with self._indexfp() as f:
 if (mmapindexthreshold is not None and
 self.opener.fstat(f).st_size >= mmapindexthreshold):
+# TODO: should .close() to release resources without
+# relying on Python GC
 indexdata = util.buffer(util.mmapread(f))
 else:
 indexdata = f.read()
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5554: histedit: added rewrite.update-timestamp to fold and mess

2019-01-12 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 13197.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5554?vs=13138=13197

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

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-edit.t
  tests/test-histedit-fold.t

CHANGE DETAILS

diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -15,6 +15,7 @@
   > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
   > [extensions]
   > histedit=
+  > mockmakedate = $TESTDIR/mockmakedate.py
   > EOF
 
 
@@ -597,3 +598,105 @@
   o  8f0162e483d0 aa
   
 
+
+-==
+Test update-timestamp config option|
+==
+  $ addwithdate ()
+  > {
+  > echo $1 > $1
+  > hg add $1
+  > hg ci -m $1 -d "$2 0"
+  > }
+
+  $ initrepo ()
+  > {
+  > hg init r
+  > cd r
+  > addwithdate a 1
+  > addwithdate b 2
+  > addwithdate c 3
+  > addwithdate d 4
+  > addwithdate e 5
+  > addwithdate f 6
+  > }
+
+  $ initrepo
+
+log before edit
+  $ hg log
+  changeset:   5:178e35e0ce73
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:06 1970 +
+  summary: f
+  
+  changeset:   4:1ddb6c90f2ee
+  user:test
+  date:Thu Jan 01 00:00:05 1970 +
+  summary: e
+  
+  changeset:   3:532247a8969b
+  user:test
+  date:Thu Jan 01 00:00:04 1970 +
+  summary: d
+  
+  changeset:   2:ff2c9fa2018b
+  user:test
+  date:Thu Jan 01 00:00:03 1970 +
+  summary: c
+  
+  changeset:   1:97d72e5f12c7
+  user:test
+  date:Thu Jan 01 00:00:02 1970 +
+  summary: b
+  
+  changeset:   0:8580ff50825a
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: a
+  
+
+  $ hg histedit 1ddb6c90f2ee --commands - 2>&1 --config 
rewrite.update-timestamp=True < pick 178e35e0ce73 f
+  > fold 1ddb6c90f2ee e
+  > EOF
+
+log after edit
+#observe time from f is updated
+  $ hg log
+  changeset:   4:f7909b1863a2
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: f
+  
+  changeset:   3:532247a8969b
+  user:test
+  date:Thu Jan 01 00:00:04 1970 +
+  summary: d
+  
+  changeset:   2:ff2c9fa2018b
+  user:test
+  date:Thu Jan 01 00:00:03 1970 +
+  summary: c
+  
+  changeset:   1:97d72e5f12c7
+  user:test
+  date:Thu Jan 01 00:00:02 1970 +
+  summary: b
+  
+  changeset:   0:8580ff50825a
+  user:test
+  date:Thu Jan 01 00:00:01 1970 +
+  summary: a
+  
+post-fold manifest
+  $ hg manifest
+  a
+  b
+  c
+  d
+  e
+  f
+
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -4,6 +4,7 @@
   > [extensions]
   > histedit=
   > strip=
+  > mockmakedate = $TESTDIR/mockmakedate.py
   > EOF
 
   $ initrepo ()
@@ -481,3 +482,48 @@
   #  f, fold = use commit, but combine it with the one above
   #  r, roll = like fold, but discard this commit's description and date
   #
+
+
+
+Test update-timestamp config option in mess|
+
+  $ addwithdate ()
+  > {
+  > echo $1 > $1
+  > hg add $1
+  > hg ci -m $1 -d "$2 0"
+  > }
+
+  $ initrepo ()
+  > {
+  > hg init r
+  > cd r
+  > addwithdate a 1
+  > addwithdate b 2
+  > addwithdate c 3
+  > addwithdate d 4
+  > addwithdate e 5
+  > addwithdate f 6
+  > }
+
+  $ initrepo
+
+log before edit
+  $ hg log --limit 1
+  changeset:   5:178e35e0ce73
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:06 1970 +
+  summary: f
+  
+  $ hg histedit tip --commands - 2>&1 --config rewrite.update-timestamp=True 
<< EOF | fixbundle
+  > mess 178e35e0ce73 f
+  > EOF
+log after edit
+  $ hg log --limit 1
+  changeset:   5:98bf456d476b
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: f
+  
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -210,6 +210,7 @@
 util,
 )
 from mercurial.utils import (
+dateutil,
 stringutil,
 )
 
@@ -519,9 +520,12 @@
 
 editor = self.commiteditor()
 commit = commitfuncfor(repo, rulectx)
-
+if repo.ui.configbool('rewrite', 'update-timestamp'):
+date = dateutil.makedate()
+else:
+date = rulectx.date()
 commit(text=rulectx.description(), user=rulectx.user(),
-   date=rulectx.date(), extra=rulectx.extra(), editor=editor)
+   date=date, extra=rulectx.extra(), editor=editor)
 
 def commiteditor(self):
 """The editor to be used to edit the commit 

[PATCH 2 of 2] histedit: remove trailing space from warning message

2019-01-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1547358375 -32400
#  Sun Jan 13 14:46:15 2019 +0900
# Node ID 81fb0d015830b5ddf89b398aa63e0b56501dc6ac
# Parent  9e4ccae74c4793f1e10f2b89991466247eb8e76a
histedit: remove trailing space from warning message

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1697,7 +1697,7 @@ def _histedit(ui, repo, state, *freeargs
 hastags = len(tags)
 if hastags:
 if ui.promptchoice(_('warning: tags associated with the given'
- ' changeset will be lost after histedit. \n'
+ ' changeset will be lost after histedit.\n'
  'do you want to continue (yN)? $$  $$ '),
default=1):
 raise error.Abort(_('histedit cancelled\n'))
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -496,7 +496,7 @@ warn the user on editing tagged commits
   tip1:bd7ee4f3939b
   a  0:a8a82d372bb3
   $ hg histedit
-  warning: tags associated with the given changeset will be lost after 
histedit. 
+  warning: tags associated with the given changeset will be lost after 
histedit.
   do you want to continue (yN)?  n
   abort: histedit cancelled
   
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2] histedit: fix weird indent of i18n text

2019-01-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1547358284 -32400
#  Sun Jan 13 14:44:44 2019 +0900
# Node ID 9e4ccae74c4793f1e10f2b89991466247eb8e76a
# Parent  ed29a1a69f505fb8b35e8a36c220a50c99baa4cd
histedit: fix weird indent of i18n text

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1697,8 +1697,9 @@ def _histedit(ui, repo, state, *freeargs
 hastags = len(tags)
 if hastags:
 if ui.promptchoice(_('warning: tags associated with the given'
-' changeset will be lost after histedit. \n'
-'do you want to continue (yN)? $$  $$ '), default=1):
+ ' changeset will be lost after histedit. \n'
+ 'do you want to continue (yN)? $$  $$ '),
+   default=1):
 raise error.Abort(_('histedit cancelled\n'))
 # rebuild state
 if goal == goalcontinue:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 3] progress: specify updatebar() function by constructor argument

2019-01-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1547357805 -32400
#  Sun Jan 13 14:36:45 2019 +0900
# Node ID ed29a1a69f505fb8b35e8a36c220a50c99baa4cd
# Parent  e13ab96098d053c755988b4e94e5c99b203f70e8
progress: specify updatebar() function by constructor argument

This makes it easy for ui extensions to intercept progress messages. It also
seems slightly nicer in that scmutil.progress doesn't touch ui internals.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1415,28 +1415,13 @@ def wlocksub(repo, cmd, *args, **kwargs)
 **kwargs)
 
 class progress(object):
-def __init__(self, ui, topic, unit="", total=None):
+def __init__(self, ui, updatebar, topic, unit="", total=None):
 self.ui = ui
 self.pos = 0
 self.topic = topic
 self.unit = unit
 self.total = total
 self.debug = ui.configbool('progress', 'debug')
-if getattr(ui._fmsgerr, 'structured', False):
-# channel for machine-readable output with metadata, just send
-# raw information
-# TODO: consider porting some useful information (e.g. estimated
-# time) from progbar. we might want to support update delay to
-# reduce the cost of transferring progress messages.
-def updatebar(topic, pos, item, unit, total):
-ui._fmsgerr.write(None, type=b'progress', topic=topic,
-  pos=pos, item=item, unit=unit,
-  total=total)
-elif ui._progbar is not None:
-updatebar = ui._progbar.progress
-else:
-def updatebar(topic, pos, item, unit, total):
-pass
 self._updatebar = updatebar
 
 def __enter__(self):
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1698,8 +1698,22 @@ class ui(object):
 progress.complete()
 
 def makeprogress(self, topic, unit="", total=None):
-'''exists only so low-level modules won't need to import scmutil'''
-return scmutil.progress(self, topic, unit, total)
+"""Create a progress helper for the specified topic"""
+if getattr(self._fmsgerr, 'structured', False):
+# channel for machine-readable output with metadata, just send
+# raw information
+# TODO: consider porting some useful information (e.g. estimated
+# time) from progbar. we might want to support update delay to
+# reduce the cost of transferring progress messages.
+def updatebar(topic, pos, item, unit, total):
+self._fmsgerr.write(None, type=b'progress', topic=topic,
+pos=pos, item=item, unit=unit, total=total)
+elif self._progbar is not None:
+updatebar = self._progbar.progress
+else:
+def updatebar(topic, pos, item, unit, total):
+pass
+return scmutil.progress(self, updatebar, topic, unit, total)
 
 def getlogger(self, name):
 """Returns a logger of the given name; or None if not registered"""
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 3] progress: change _updatebar() to take parameters as arguments

2019-01-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1547356895 -32400
#  Sun Jan 13 14:21:35 2019 +0900
# Node ID e13ab96098d053c755988b4e94e5c99b203f70e8
# Parent  ec7bc9f70e3982f30c2801d3af51d57c498b0851
progress: change _updatebar() to take parameters as arguments

I want to move updatebar() back to ui. See the next patch for why.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1428,16 +1428,14 @@ class progress(object):
 # TODO: consider porting some useful information (e.g. estimated
 # time) from progbar. we might want to support update delay to
 # reduce the cost of transferring progress messages.
-def updatebar(item):
-ui._fmsgerr.write(None, type=b'progress', topic=self.topic,
-  pos=self.pos, item=item, unit=self.unit,
-  total=self.total)
+def updatebar(topic, pos, item, unit, total):
+ui._fmsgerr.write(None, type=b'progress', topic=topic,
+  pos=pos, item=item, unit=unit,
+  total=total)
 elif ui._progbar is not None:
-def updatebar(item):
-ui._progbar.progress(self.topic, self.pos, item=item,
- unit=self.unit, total=self.total)
+updatebar = ui._progbar.progress
 else:
-def updatebar(item):
+def updatebar(topic, pos, item, unit, total):
 pass
 self._updatebar = updatebar
 
@@ -1452,7 +1450,7 @@ class progress(object):
 if total:
 self.total = total
 self.pos = pos
-self._updatebar(item)
+self._updatebar(self.topic, self.pos, item, self.unit, self.total)
 if self.debug:
 self._printdebug(item)
 
@@ -1463,7 +1461,7 @@ class progress(object):
 self.pos = None
 self.unit = ""
 self.total = None
-self._updatebar("")
+self._updatebar(self.topic, self.pos, "", self.unit, self.total)
 
 def _printdebug(self, item):
 if self.unit:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 3] archival: construct progress helper through ui.makeprogress()

2019-01-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1547357171 -32400
#  Sun Jan 13 14:26:11 2019 +0900
# Node ID ec7bc9f70e3982f30c2801d3af51d57c498b0851
# Parent  3f807237dc94925b7f92aeb6a822440856cc8b47
archival: construct progress helper through ui.makeprogress()

No idea why we didn't.

diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -327,8 +327,8 @@ def archive(repo, dest, node, kind, deco
 files.sort()
 scmutil.prefetchfiles(repo, [ctx.rev()],
   scmutil.matchfiles(repo, files))
-progress = scmutil.progress(repo.ui, _('archiving'), unit=_('files'),
-total=total)
+progress = repo.ui.makeprogress(_('archiving'), unit=_('files'),
+total=total)
 progress.update(0)
 for f in files:
 ff = ctx.flags(f)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5561: revlog: always enable generaldelta on version 2 revlogs

2019-01-12 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe7a2cc84dbc0: revlog: always enable generaldelta on version 
2 revlogs (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5561?vs=13157=13193

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

AFFECTED FILES
  mercurial/changelog.py
  mercurial/help/internals/revlogs.txt
  mercurial/localrepo.py
  mercurial/revlog.py
  mercurial/revlogutils/constants.py
  tests/test-revlog-v2.t

CHANGE DETAILS

diff --git a/tests/test-revlog-v2.t b/tests/test-revlog-v2.t
--- a/tests/test-revlog-v2.t
+++ b/tests/test-revlog-v2.t
@@ -22,7 +22,7 @@
   $ cd empty-repo
   $ cat .hg/requires
   dotencode
-  exp-revlogv2.0
+  exp-revlogv2.1
   fncache
   sparserevlog
   store
@@ -54,12 +54,12 @@
   date:Thu Jan 01 00:00:00 1970 +
   summary: initial
   
-Header written as expected (changelog always disables generaldelta)
+Header written as expected
 
   $ f --hexdump --bytes 4 .hg/store/00changelog.i
   .hg/store/00changelog.i:
   : 00 01 de ad ||
 
   $ f --hexdump --bytes 4 .hg/store/data/foo.i
   .hg/store/data/foo.i:
-  : 00 03 de ad ||
+  : 00 01 de ad ||
diff --git a/mercurial/revlogutils/constants.py 
b/mercurial/revlogutils/constants.py
--- a/mercurial/revlogutils/constants.py
+++ b/mercurial/revlogutils/constants.py
@@ -20,13 +20,15 @@
 # Dummy value until file format is finalized.
 # Reminder: change the bounds check in revlog.__init__ when this is changed.
 REVLOGV2 = 0xDEAD
+# Shared across v1 and v2.
 FLAG_INLINE_DATA = (1 << 16)
+# Only used by v1, implied by v2.
 FLAG_GENERALDELTA = (1 << 17)
 REVLOG_DEFAULT_FLAGS = FLAG_INLINE_DATA
 REVLOG_DEFAULT_FORMAT = REVLOGV1
 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
 REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA
-REVLOGV2_FLAGS = REVLOGV1_FLAGS
+REVLOGV2_FLAGS = FLAG_INLINE_DATA
 
 # revlog index flags
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -387,8 +387,7 @@
 opts = getattr(opener, 'options', {}) or {}
 
 if 'revlogv2' in opts:
-# version 2 revlogs always use generaldelta.
-versionflags = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA
+versionflags = REVLOGV2 | FLAG_INLINE_DATA
 elif 'revlogv1' in opts:
 versionflags = REVLOGV1 | FLAG_INLINE_DATA
 if 'generaldelta' in opts:
@@ -451,25 +450,38 @@
 raise
 
 self.version = versionflags
-self._inline = versionflags & FLAG_INLINE_DATA
-self._generaldelta = versionflags & FLAG_GENERALDELTA
+
 flags = versionflags & ~0x
 fmt = versionflags & 0x
+
 if fmt == REVLOGV0:
 if flags:
 raise error.RevlogError(_('unknown flags (%#04x) in version %d 
'
   'revlog %s') %
 (flags >> 16, fmt, self.indexfile))
+
+self._inline = False
+self._generaldelta = False
+
 elif fmt == REVLOGV1:
 if flags & ~REVLOGV1_FLAGS:
 raise error.RevlogError(_('unknown flags (%#04x) in version %d 
'
   'revlog %s') %
 (flags >> 16, fmt, self.indexfile))
+
+self._inline = versionflags & FLAG_INLINE_DATA
+self._generaldelta = versionflags & FLAG_GENERALDELTA
+
 elif fmt == REVLOGV2:
 if flags & ~REVLOGV2_FLAGS:
 raise error.RevlogError(_('unknown flags (%#04x) in version %d 
'
   'revlog %s') %
 (flags >> 16, fmt, self.indexfile))
+
+self._inline = versionflags & FLAG_INLINE_DATA
+# generaldelta implied by version 2 revlogs.
+self._generaldelta = True
+
 else:
 raise error.RevlogError(_('unknown version (%d) in revlog %s') %
 (fmt, self.indexfile))
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -363,7 +363,7 @@
 
 # Increment the sub-version when the revlog v2 format changes to lock out old
 # clients.
-REVLOGV2_REQUIREMENT = 'exp-revlogv2.0'
+REVLOGV2_REQUIREMENT = 'exp-revlogv2.1'
 
 # A repository with the sparserevlog feature will have delta chains that
 # can spread over a larger span. Sparse reading cuts these large spans into
diff --git a/mercurial/help/internals/revlogs.txt 
b/mercurial/help/internals/revlogs.txt
--- a/mercurial/help/internals/revlogs.txt
+++ b/mercurial/help/internals/revlogs.txt
@@ -66,8 +66,6 @@
 
 0
Store 

D5564: revlog: use separate variables to track version flags

2019-01-12 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG3f807237dc94: revlog: use separate variables to track 
version flags (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5564?vs=13160=13196

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -391,13 +391,13 @@
 opts = getattr(self.opener, 'options', {}) or {}
 
 if 'revlogv2' in opts:
-versionflags = REVLOGV2 | FLAG_INLINE_DATA
+newversionflags = REVLOGV2 | FLAG_INLINE_DATA
 elif 'revlogv1' in opts:
-versionflags = REVLOGV1 | FLAG_INLINE_DATA
+newversionflags = REVLOGV1 | FLAG_INLINE_DATA
 if 'generaldelta' in opts:
-versionflags |= FLAG_GENERALDELTA
+newversionflags |= FLAG_GENERALDELTA
 else:
-versionflags = REVLOG_DEFAULT_VERSION
+newversionflags = REVLOG_DEFAULT_VERSION
 
 if 'chunkcachesize' in opts:
 self._chunkcachesize = opts['chunkcachesize']
@@ -446,10 +446,14 @@
 if len(indexdata) > 0:
 versionflags = versionformat_unpack(indexdata[:4])[0]
 self._initempty = False
+else:
+versionflags = newversionflags
 except IOError as inst:
 if inst.errno != errno.ENOENT:
 raise
 
+versionflags = newversionflags
+
 self.version = versionflags
 
 flags = versionflags & ~0x



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


D5563: revlog: inline opener options logic into _loadindex()

2019-01-12 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe3cfe0702eac: revlog: inline opener options logic into 
_loadindex() (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5563?vs=13159=13195

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -384,8 +384,11 @@
 # 2-tuple of file handles being used for active writing.
 self._writinghandles = None
 
+self._loadindex()
+
+def _loadindex(self):
 mmapindexthreshold = None
-opts = getattr(opener, 'options', {}) or {}
+opts = getattr(self.opener, 'options', {}) or {}
 
 if 'revlogv2' in opts:
 versionflags = REVLOGV2 | FLAG_INLINE_DATA
@@ -431,9 +434,6 @@
 raise error.RevlogError(_('revlog chunk cache size %r is not a '
   'power of 2') % self._chunkcachesize)
 
-self._loadindex(versionflags, mmapindexthreshold)
-
-def _loadindex(self, versionflags, mmapindexthreshold):
 indexdata = ''
 self._initempty = True
 try:
@@ -2499,7 +2499,7 @@
 self.opener.rename(newrl.datafile, self.datafile)
 
 self.clearcaches()
-self._loadindex(self.version, None)
+self._loadindex()
 
 def verifyintegrity(self, state):
 """Verifies the integrity of the revlog.



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


D5562: revlog: store mmaplargeindex as an instance attribute

2019-01-12 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd0de4fdd87aa: revlog: store mmaplargeindex as an instance 
attribute (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5562?vs=13158=13194

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -352,6 +352,7 @@
 #  When True, indexfile is opened with checkambig=True at writing, to
 #  avoid file stat ambiguity.
 self._checkambig = checkambig
+self._mmaplargeindex = mmaplargeindex
 self._censorable = censorable
 # 3-tuple of (node, rev, text) for a raw revision.
 self._revisioncache = None
@@ -406,7 +407,7 @@
 self._compengine = opts['compengine']
 if 'maxdeltachainspan' in opts:
 self._maxdeltachainspan = opts['maxdeltachainspan']
-if mmaplargeindex and 'mmapindexthreshold' in opts:
+if self._mmaplargeindex and 'mmapindexthreshold' in opts:
 mmapindexthreshold = opts['mmapindexthreshold']
 self._sparserevlog = bool(opts.get('sparse-revlog', False))
 withsparseread = bool(opts.get('with-sparse-read', False))



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


D5560: revlog: rename v to versionflags

2019-01-12 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6439cefaeb64: revlog: rename v to versionflags (authored by 
indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5560?vs=13156=13192

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -388,13 +388,13 @@
 
 if 'revlogv2' in opts:
 # version 2 revlogs always use generaldelta.
-v = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA
+versionflags = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA
 elif 'revlogv1' in opts:
-v = REVLOGV1 | FLAG_INLINE_DATA
+versionflags = REVLOGV1 | FLAG_INLINE_DATA
 if 'generaldelta' in opts:
-v |= FLAG_GENERALDELTA
+versionflags |= FLAG_GENERALDELTA
 else:
-v = REVLOG_DEFAULT_VERSION
+versionflags = REVLOG_DEFAULT_VERSION
 
 if 'chunkcachesize' in opts:
 self._chunkcachesize = opts['chunkcachesize']
@@ -431,9 +431,9 @@
 raise error.RevlogError(_('revlog chunk cache size %r is not a '
   'power of 2') % self._chunkcachesize)
 
-self._loadindex(v, mmapindexthreshold)
-
-def _loadindex(self, v, mmapindexthreshold):
+self._loadindex(versionflags, mmapindexthreshold)
+
+def _loadindex(self, versionflags, mmapindexthreshold):
 indexdata = ''
 self._initempty = True
 try:
@@ -444,17 +444,17 @@
 else:
 indexdata = f.read()
 if len(indexdata) > 0:
-v = versionformat_unpack(indexdata[:4])[0]
+versionflags = versionformat_unpack(indexdata[:4])[0]
 self._initempty = False
 except IOError as inst:
 if inst.errno != errno.ENOENT:
 raise
 
-self.version = v
-self._inline = v & FLAG_INLINE_DATA
-self._generaldelta = v & FLAG_GENERALDELTA
-flags = v & ~0x
-fmt = v & 0x
+self.version = versionflags
+self._inline = versionflags & FLAG_INLINE_DATA
+self._generaldelta = versionflags & FLAG_GENERALDELTA
+flags = versionflags & ~0x
+fmt = versionflags & 0x
 if fmt == REVLOGV0:
 if flags:
 raise error.RevlogError(_('unknown flags (%#04x) in version %d 
'



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


D5559: revlog: always process opener options

2019-01-12 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGcecf3f8bccd3: revlog: always process opener options 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5559?vs=13155=13191

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -384,44 +384,45 @@
 self._writinghandles = None
 
 mmapindexthreshold = None
-v = REVLOG_DEFAULT_VERSION
-opts = getattr(opener, 'options', None)
-if opts is not None:
-if 'revlogv2' in opts:
-# version 2 revlogs always use generaldelta.
-v = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA
-elif 'revlogv1' in opts:
-if 'generaldelta' in opts:
-v |= FLAG_GENERALDELTA
-else:
-v = 0
-if 'chunkcachesize' in opts:
-self._chunkcachesize = opts['chunkcachesize']
-if 'maxchainlen' in opts:
-self._maxchainlen = opts['maxchainlen']
-if 'deltabothparents' in opts:
-self._deltabothparents = opts['deltabothparents']
-self._lazydeltabase = bool(opts.get('lazydeltabase', False))
-if 'compengine' in opts:
-self._compengine = opts['compengine']
-if 'maxdeltachainspan' in opts:
-self._maxdeltachainspan = opts['maxdeltachainspan']
-if mmaplargeindex and 'mmapindexthreshold' in opts:
-mmapindexthreshold = opts['mmapindexthreshold']
-self._sparserevlog = bool(opts.get('sparse-revlog', False))
-withsparseread = bool(opts.get('with-sparse-read', False))
-# sparse-revlog forces sparse-read
-self._withsparseread = self._sparserevlog or withsparseread
-if 'sparse-read-density-threshold' in opts:
-self._srdensitythreshold = 
opts['sparse-read-density-threshold']
-if 'sparse-read-min-gap-size' in opts:
-self._srmingapsize = opts['sparse-read-min-gap-size']
-if opts.get('enableellipsis'):
-self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor
-
-# revlog v0 doesn't have flag processors
-for flag, processor in opts.get(b'flagprocessors', {}).iteritems():
-_insertflagprocessor(flag, processor, self._flagprocessors)
+opts = getattr(opener, 'options', {}) or {}
+
+if 'revlogv2' in opts:
+# version 2 revlogs always use generaldelta.
+v = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA
+elif 'revlogv1' in opts:
+v = REVLOGV1 | FLAG_INLINE_DATA
+if 'generaldelta' in opts:
+v |= FLAG_GENERALDELTA
+else:
+v = REVLOG_DEFAULT_VERSION
+
+if 'chunkcachesize' in opts:
+self._chunkcachesize = opts['chunkcachesize']
+if 'maxchainlen' in opts:
+self._maxchainlen = opts['maxchainlen']
+if 'deltabothparents' in opts:
+self._deltabothparents = opts['deltabothparents']
+self._lazydeltabase = bool(opts.get('lazydeltabase', False))
+if 'compengine' in opts:
+self._compengine = opts['compengine']
+if 'maxdeltachainspan' in opts:
+self._maxdeltachainspan = opts['maxdeltachainspan']
+if mmaplargeindex and 'mmapindexthreshold' in opts:
+mmapindexthreshold = opts['mmapindexthreshold']
+self._sparserevlog = bool(opts.get('sparse-revlog', False))
+withsparseread = bool(opts.get('with-sparse-read', False))
+# sparse-revlog forces sparse-read
+self._withsparseread = self._sparserevlog or withsparseread
+if 'sparse-read-density-threshold' in opts:
+self._srdensitythreshold = opts['sparse-read-density-threshold']
+if 'sparse-read-min-gap-size' in opts:
+self._srmingapsize = opts['sparse-read-min-gap-size']
+if opts.get('enableellipsis'):
+self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor
+
+# revlog v0 doesn't have flag processors
+for flag, processor in opts.get(b'flagprocessors', {}).iteritems():
+_insertflagprocessor(flag, processor, self._flagprocessors)
 
 if self._chunkcachesize <= 0:
 raise error.RevlogError(_('revlog chunk cache size %r is not '



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


D5558: internals: minor rewriting of revlogs documentation

2019-01-12 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd8fe67db5234: internals: minor rewriting of revlogs 
documentation (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5558?vs=13154=13190

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

AFFECTED FILES
  mercurial/help/internals/revlogs.txt

CHANGE DETAILS

diff --git a/mercurial/help/internals/revlogs.txt 
b/mercurial/help/internals/revlogs.txt
--- a/mercurial/help/internals/revlogs.txt
+++ b/mercurial/help/internals/revlogs.txt
@@ -11,8 +11,8 @@
 links to its *parent* entries. The collective metadata is referred
 to as the *index* and the revision data is the *data*.
 
-Revision data is stored as a series of compressed deltas against previous
-revisions.
+Revision data is stored as a series of compressed deltas against
+ancestor revisions.
 
 Revlogs are written in an append-only fashion. We never need to rewrite
 a file to insert nor do we need to remove data. Rolling back in-progress
@@ -35,9 +35,6 @@
 significant half of the integer is the format/version short. The other
 short holds feature flags that dictate behavior of the revlog.
 
-Only 1 bit of the format/version short is currently used. Remaining
-bits are reserved for future use.
-
 The following values for the format/version short are defined:
 
 0
@@ -53,15 +50,24 @@
beyond 32-bit header.
 
 The feature flags short consists of bit flags. Where 0 is the least
-significant bit, the following bit offsets define flags:
+significant bit. The bit flags vary by revlog version.
+
+Version 0 revlogs have no defined flags and the presence of a flag
+is considered an error.
+
+Version 1 revlogs have the following flags at the specified bit offsets:
 
 0
Store revision data inline.
 1
Generaldelta encoding.
 
-2-15
-   Reserved for future use.
+Version 2 revlogs have the following flags at the specified bit offsets:
+
+0
+   Store revision data inline.
+1
+   Generaldelta encoding.
 
 The following header values are common:
 



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


D5559: revlog: always process opener options

2019-01-12 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   I'm not sure when ``opener.options`` would ever be explicitly
  >   set to None. It is definitely not possible to construct a repo
  >   this way because ``localrepo.resolvestorevfsoptions()`` always
  >   returns a dict and ``localrepo.makelocalrepository()`` always
  >   sets ``opener.options`` to this value.
  >   
  >   Because we always execute this code now, if options are empty
  >   we defaulted to creating version 0 revlogs. So we had to change
  >   the code slightly to fall back to the default revlog version
  >   and flags.
  >   
  >   As astute reader will note that it is not possible to create
  >   version 0 revlogs now. However, I don't think it was possible
  >   before, as this required ``opener.options`` being unset, which
  >   I don't think was possible. I suspect this means our test
  >   coverage for version 0 revlog repositories is possibly
  >   non-existent! Since I don't see a config option to disable
  >   revlog v1, I'm not even sure if we had a way to create new
  >   repos with version 0 revlogs! Who knows.
  
  Well, there was a trick to create a v0 repo, which 
https://phab.mercurial-scm.org/rHGdda11e79952959a87298e5e094bf087c1837a0a3 uses.
  
$ mkdir .hg
  
  This patch looks good as itself, but we need to resurrect some trick
  to create a v0 revlog.

REPOSITORY
  rHG Mercurial

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

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


Re: D5559: revlog: always process opener options

2019-01-12 Thread Yuya Nishihara
>   I'm not sure when ``opener.options`` would ever be explicitly
>   set to None. It is definitely not possible to construct a repo
>   this way because ``localrepo.resolvestorevfsoptions()`` always
>   returns a dict and ``localrepo.makelocalrepository()`` always
>   sets ``opener.options`` to this value.
>   
>   Because we always execute this code now, if options are empty
>   we defaulted to creating version 0 revlogs. So we had to change
>   the code slightly to fall back to the default revlog version
>   and flags.
>   
>   As astute reader will note that it is not possible to create
>   version 0 revlogs now. However, I don't think it was possible
>   before, as this required ``opener.options`` being unset, which
>   I don't think was possible. I suspect this means our test
>   coverage for version 0 revlog repositories is possibly
>   non-existent! Since I don't see a config option to disable
>   revlog v1, I'm not even sure if we had a way to create new
>   repos with version 0 revlogs! Who knows.

Well, there was a trick to create a v0 repo, which dda11e799529 uses.

```
$ mkdir .hg
```

This patch looks good as itself, but we need to resurrect some trick
to create a v0 revlog.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5564: revlog: use separate variables to track version flags

2019-01-12 Thread yuja (Yuya Nishihara)
yuja added a comment.


  Queued up to this, thanks.

REPOSITORY
  rHG Mercurial

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

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


Re: D5564: revlog: use separate variables to track version flags

2019-01-12 Thread Yuya Nishihara
Queued up to this, thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5561: revlog: always enable generaldelta on version 2 revlogs

2019-01-12 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > - if self._initempty:
  > - # changelogs don't benefit from generaldelta +if self._initempty 
and (self.version & 0x == revlog.REVLOGV1): +# changelogs don't 
benefit from generaldelta.
  
  Perhaps, `debugdeltachain()` and `debugrevlog()` has to be updated as well.
  They peek `.version` attribute.

REPOSITORY
  rHG Mercurial

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

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


Re: D5561: revlog: always enable generaldelta on version 2 revlogs

2019-01-12 Thread Yuya Nishihara
> -if self._initempty:
> -# changelogs don't benefit from generaldelta
> +if self._initempty and (self.version & 0x == revlog.REVLOGV1):
> +# changelogs don't benefit from generaldelta.

Perhaps, `debugdeltachain()` and `debugrevlog()` has to be updated as well.
They peek `.version` attribute.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 2 V2] extdiff: add --mode option

2019-01-12 Thread Yuya Nishihara
On Sat, 12 Jan 2019 09:26:25 -0800, Ludovic Chabant wrote:
> Thanks for the comments!
> 
> > Maybe need to check the .gui flag of the tool. Otherwise the console
> > would be messed up if the tool wasn't a GUI program.
> 
> Good point, although the existing extdiff code doesn't seem to be checking 
> that, no? So should I do that in a separate patch?

A separate patch seems fine. To make clear, there's no need to check if the
tool is console-based or not unless multiple diff processes are spawned
simultaneously. Currently the .gui flag is tested only by filemerge.py.

> > Well, I think it will produce 8 modes,
> > dir-or-file x revpair-or-revrage x prompt-or-not.
> > 
> > And we can even get rid of the dir-or-file mode from command flags by
> > registering two tools, one for dir-diff and the other for per-file-diff.
> > I don't know if that is a better idea, but we'll never use the per-file
> > mode if the tool had a decent support for directory diff. So it's a tool-
> > specific property at some level.
> 
> It's not super important, but I disagree about the second-to-last-point here, 
> since I actually wrote this patch with the intent of using per-file diffs 
> with tools like BeyondCompare and vim+DirDiff, which both handle dir diffs 
> pretty well. It's just that 95% of the time I want to see the diff of _all_ 
> the files in a revision, and going through a dir-diff UI just adds 
> unnecessary actions/clicks to get all those diffs to open.
> The only times I want a dir-diff where I'm going to only look at _some_ of 
> the files is when diffing a big merge.
> 
> As a result, I was indeed planning on configuring per-file-diffing by default 
> in my .hgrc for those tools, while occasionally passing a dir-diff argument 
> when appropriate. Sure, I could make 2 different tools in my .hgrc if we 
> didn't want to expose new options to the CLI, but for some reason it feels 
> wrong to force users to edit their .hgrc for that.
> 
> I see your point about modes vs flags. Like I said, I don't have very strong 
> opinions about it so I guess I'll change the second patch and use some flags 
> instead. Are we going for --per-file and --confirm then?

To all, any thoughts?

I feel uncomfortable these days as there's little response to this kind of
UI patches. I'm not a good UI designer.

> Note that the tool config in .hgrc would look a bit less elegant as a result, 
> like this:
> 
> cmd.blah=/path/to/blah
> opts.blah=--some-option -z
> per-file.blah=true
> confirm.blah=true
> 
> So instead I'm proposing a new config that specifies options for the hg 
> extdiff command itself, like this:
> 
> cmd.blah=/path/to/blah
> opts.blah=--some-option -z
> hgopts.blah=--per-file --confirm
> 
> ...but I don't know if that opens up potential abuse or something.  What do 
> you think?

The latter looks worse for me. Instead, you can use [alias] to pass in
arguments to hg commands.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5490: commit: remove ignore whitespace option on --interactive (issue6042)

2019-01-12 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   > It was intentionally added by 
https://phab.mercurial-scm.org/rHG3f1dccea9510c122cf9ab0e7a5a19ceed3600a7f 
(with no tests.)
  >   
  >   Do you want me to add tests for that?  If yes, please mention the things 
I need to take care of on
  >writing those tests.
  
  I think you can reuse the test you've written for `commit -i`.
  
  >   I've updated the revision and things are working fine. There is still 
`whitespace=True` existing
  >   on calling `patch.difffeatureopts()` in `fastannotate`, 
`diffutil.diffallopts()`,
  >   `webutil.difffeatureopts()` and ``cmdutil._performrevert()`. Is there 
anything
  >   to be done on that?
  
  Good questionn. Maybe we can't simply fix the issue6042 by turning off the
  whitespace options?
  
  `_performrevert()` would be in the same boat, but it was explicitly flagged on
  at 
https://phab.mercurial-scm.org/rHGf37a69ec3f4717fdb4f00699ca06c225f106696c. 
This implies that the `diff.ignorews` option would be used
  in practice to exclude whitespace changes while interactive commit/revert.
  So disabling any whitespace options would break someone's workflow.

REPOSITORY
  rHG Mercurial

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

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


Re: D5490: commit: remove ignore whitespace option on --interactive (issue6042)

2019-01-12 Thread Yuya Nishihara
>   > It was intentionally added by 
> https://phab.mercurial-scm.org/rHG3f1dccea9510c122cf9ab0e7a5a19ceed3600a7f 
> (with no tests.)
>   
>   Do you want me to add tests for that?  If yes, please mention the things I 
> need to take care of on
>writing those tests.

I think you can reuse the test you've written for `commit -i`.

>   I've updated the revision and things are working fine. There is still 
> `whitespace=True` existing
>   on calling `patch.difffeatureopts()` in `fastannotate`, 
> `diffutil.diffallopts()`,
>   `webutil.difffeatureopts()` and ``cmdutil._performrevert()`. Is there 
> anything
>   to be done on that?

Good questionn. Maybe we can't simply fix the issue6042 by turning off the
whitespace options?

`_performrevert()` would be in the same boat, but it was explicitly flagged on
at f37a69ec3f47. This implies that the `diff.ignorews` option would be used
in practice to exclude whitespace changes while interactive commit/revert.
So disabling any whitespace options would break someone's workflow.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5569: tests: make HGCATAPULTSERVERPIPE imply HGTESTCATAPULTSERVERPIPE

2019-01-12 Thread spectral (Kyle Lippincott)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4f0ae5c64c1b: tests: make HGCATAPULTSERVERPIPE imply 
HGTESTCATAPULTSERVERPIPE (authored by spectral, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5569?vs=13165=13189

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1409,7 +1409,8 @@
 session = str(uuid.uuid4())
 if PYTHON3:
 session = session.encode('ascii')
-hgcatapult = os.getenv('HGTESTCATAPULTSERVERPIPE')
+hgcatapult = os.getenv('HGTESTCATAPULTSERVERPIPE') or \
+os.getenv('HGCATAPULTSERVERPIPE')
 def toggletrace(cmd=None):
 if not hgcatapult or hgcatapult == os.devnull:
 return



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


D5552: tests: add test for warning on histedit with tagged commits

2019-01-12 Thread navaneeth.suresh (Navaneeth Suresh)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG172296c6db91: tests: add test for warning on histedit with 
tagged commits (authored by navaneeth.suresh, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5552?vs=13134=13188#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5552?vs=13134=13188

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

AFFECTED FILES
  tests/test-histedit-edit.t

CHANGE DETAILS

diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -481,3 +481,24 @@
   #  f, fold = use commit, but combine it with the one above
   #  r, roll = like fold, but discard this commit's description and date
   #
+
+  $ cd ..
+
+warn the user on editing tagged commits
+
+  $ hg init issue4017
+  $ cd issue4017
+  $ echo > a
+  $ hg ci -Am 'add a'
+  adding a
+  $ hg tag a
+  $ hg tags
+  tip1:bd7ee4f3939b
+  a  0:a8a82d372bb3
+  $ hg histedit
+  warning: tags associated with the given changeset will be lost after 
histedit. 
+  do you want to continue (yN)?  n
+  abort: histedit cancelled
+  
+  [255]
+  $ cd ..



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


D5570: hg-docker: fix Python 3.4 compatibility (for CentOS 7)

2019-01-12 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > +if p.returncode:
  >  +raise Exception('failed to build docker image: %s %s' % 
(p.stdout, p.stderr))
  
  Can you change the exception type? test-check-code.t complains about it.

REPOSITORY
  rHG Mercurial

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

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


Re: D5570: hg-docker: fix Python 3.4 compatibility (for CentOS 7)

2019-01-12 Thread Yuya Nishihara
> +if p.returncode:
> +raise Exception('failed to build docker image: %s %s' % (p.stdout, 
> p.stderr))

Can you change the exception type? test-check-code.t complains about it.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5490: commit: remove ignore whitespace option on --interactive (issue6042)

2019-01-12 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > - a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -237,6 +237,7 @@ def 
dorecord(ui, repo, commitfunc, cmdsuggest, backupall, filterfn, *pats, **opts): 
opts = pycompat.byteskwargs(opts) +ignorews = opts.get('ignorews', False)
  
  It isn't nice to mix command options and internal flags. Instead, maybe we can
  first change `record()` to not call `commands.commit()`, and pass in 
`whitespace`
  option to `cmdutil.dorecord()`.
  
def record(ui, repo, *pats, **opts):
opts = pycompat.byteskwargs(opts)
...
with repo.wlock(), repo.lock():
ret = cmdutil.dorecord(ui, repo, commands.commit, ..., 
whitespace=True,
   pats, opts)
...
  
  And I don't think `ignorews` is good name. It doesn't mean whitespace is
  ignored.
  
  >   def qrefresh(origfn, ui, repo, *pats, **opts):
  >   if not opts[r'interactive']:
  > 
  > @@ -89,7 +89,7 @@
  > 
  >   1. backup all changed files cmdutil.dorecord(ui, repo, committomq, None, 
True,
  > - cmdutil.recordfilter, *pats, **opts) +
cmdutil.recordfilter, *pats, ignorews=True, **opts)
  
  Perhaps, this one should be `ignorefs=False` since qrefresh has no diffwsopts.

REPOSITORY
  rHG Mercurial

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

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


Re: D5490: commit: remove ignore whitespace option on --interactive (issue6042)

2019-01-12 Thread Yuya Nishihara
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -237,6 +237,7 @@
>  def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
>  filterfn, *pats, **opts):
>  opts = pycompat.byteskwargs(opts)
> +ignorews = opts.get('ignorews', False)

It isn't nice to mix command options and internal flags. Instead, maybe we can
first change `record()` to not call `commands.commit()`, and pass in 
`whitespace`
option to `cmdutil.dorecord()`.

```
def record(ui, repo, *pats, **opts):
opts = pycompat.byteskwargs(opts)
...
with repo.wlock(), repo.lock():
ret = cmdutil.dorecord(ui, repo, commands.commit, ..., whitespace=True,
   pats, opts)
...
```

And I don't think `ignorews` is good name. It doesn't mean whitespace is
ignored.

>  def qrefresh(origfn, ui, repo, *pats, **opts):
>  if not opts[r'interactive']:
> @@ -89,7 +89,7 @@
>  
>  # backup all changed files
>  cmdutil.dorecord(ui, repo, committomq, None, True,
> -cmdutil.recordfilter, *pats, **opts)
> +cmdutil.recordfilter, *pats, ignorews=True, **opts)

Perhaps, this one should be `ignorefs=False` since qrefresh has no diffwsopts.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: D5554: histedit: added rewrite.update-timestamp to fold and mess

2019-01-12 Thread Yuya Nishihara
> +  $ cat >> testmocks.py << EOF
> +  > # mock out util.makedate() to supply testable values
> +  > import os
> +  > from mercurial import pycompat, util
> +  > from mercurial.utils import dateutil
> +  > 
> +  > def mockmakedate():
> +  > filename = os.path.join(os.environ['TESTTMP'], 'testtime')
> +  > try:
> +  > with open(filename, 'rb') as timef:
> +  > time = float(timef.read()) + 1
> +  > except IOError:
> +  > time = 0.0
> +  > with open(filename, 'wb') as timef:
> +  > timef.write(pycompat.bytestr(time))
> +  > return (time, 0)
> +  > 
> +  > dateutil.makedate = mockmakedate
> +  > EOF

Perhaps, it's time to extract the mockmakedate extension to
`tests/mockmakedate.py`.

> @@ -519,9 +520,12 @@
>  
>  editor = self.commiteditor()
>  commit = commitfuncfor(repo, rulectx)
> -
> +if repo.ui.configbool('rewrite','update-timestamp'):

Style nit: insert space after comma.

> +date = dateutil.makedate()
> +else :

and no space after `else`.

>  def commiteditor(self):
>  """The editor to be used to edit the commit message."""
> @@ -800,6 +804,8 @@
>  # date
>  if self.firstdate():
>  commitopts['date'] = ctx.date()
> +elif ui.configbool('rewrite','update-timestamp'):
> +commitopts['date'] = dateutil.makedate()
>  else:
>  commitopts['date'] = max(ctx.date(), oldctx.date())

I'm not pretty sure, but shouldn't we always update the date if update-timestamp
is on?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5554: histedit: added rewrite.update-timestamp to fold and mess

2019-01-12 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > +  $ cat >> testmocks.py << EOF
  >  +  > # mock out util.makedate() to supply testable values
  >  +  > import os
  >  +  > from mercurial import pycompat, util
  >  +  > from mercurial.utils import dateutil
  >  +  > 
  >  +  > def mockmakedate():
  >  +  > filename = os.path.join(os.environ['TESTTMP'], 'testtime')
  >  +  > try:
  >  +  > with open(filename, 'rb') as timef:
  >  +  > time = float(timef.read()) + 1
  >  +  > except IOError:
  >  +  > time = 0.0
  >  +  > with open(filename, 'wb') as timef:
  >  +  > timef.write(pycompat.bytestr(time))
  >  +  > return (time, 0)
  >  +  > 
  >  +  > dateutil.makedate = mockmakedate
  >  +  > EOF
  
  Perhaps, it's time to extract the mockmakedate extension to
  `tests/mockmakedate.py`.
  
  > @@ -519,9 +520,12 @@
  > 
  >   editor = self.commiteditor()
  >   commit = commitfuncfor(repo, rulectx)
  > 
  > - +if repo.ui.configbool('rewrite','update-timestamp'):
  
  Style nit: insert space after comma.
  
  > +date = dateutil.makedate()
  >  +else :
  
  and no space after `else`.
  
  >   def commiteditor(self):
  >   """The editor to be used to edit the commit message."""
  > 
  > @@ -800,6 +804,8 @@
  > 
  > 1. date if self.firstdate(): commitopts['date'] = ctx.date() +elif 
ui.configbool('rewrite','update-timestamp'): +commitopts['date'] = 
dateutil.makedate() else: commitopts['date'] = max(ctx.date(), oldctx.date())
  
  I'm not pretty sure, but shouldn't we always update the date if 
update-timestamp
  is on?

REPOSITORY
  rHG Mercurial

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

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


D5552: tests: add test for warning on histedit with tagged commits

2019-01-12 Thread yuja (Yuya Nishihara)
yuja added a comment.


  Queued, thanks.
  
  > +  $ echo '[extensions]' >> $HGRCPATH
  >  +  $ echo 'histedit =' >> $HGRCPATH
  
  Removed these lines. The extension is enabled at the beginning.

REPOSITORY
  rHG Mercurial

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

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


Re: D5552: tests: add test for warning on histedit with tagged commits

2019-01-12 Thread Yuya Nishihara
Queued, thanks.

> +  $ echo '[extensions]' >> $HGRCPATH
> +  $ echo 'histedit =' >> $HGRCPATH

Removed these lines. The extension is enabled at the beginning.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 2 V2] extdiff: add --mode option

2019-01-12 Thread Ludovic Chabant
Thanks for the comments!

> Maybe need to check the .gui flag of the tool. Otherwise the console
> would be messed up if the tool wasn't a GUI program.

Good point, although the existing extdiff code doesn't seem to be checking 
that, no? So should I do that in a separate patch?
 

> Well, I think it will produce 8 modes,
> dir-or-file x revpair-or-revrage x prompt-or-not.
> 
> And we can even get rid of the dir-or-file mode from command flags by
> registering two tools, one for dir-diff and the other for per-file-diff.
> I don't know if that is a better idea, but we'll never use the per-file
> mode if the tool had a decent support for directory diff. So it's a tool-
> specific property at some level.

It's not super important, but I disagree about the second-to-last-point here, 
since I actually wrote this patch with the intent of using per-file diffs with 
tools like BeyondCompare and vim+DirDiff, which both handle dir diffs pretty 
well. It's just that 95% of the time I want to see the diff of _all_ the files 
in a revision, and going through a dir-diff UI just adds unnecessary 
actions/clicks to get all those diffs to open.
The only times I want a dir-diff where I'm going to only look at _some_ of the 
files is when diffing a big merge.

As a result, I was indeed planning on configuring per-file-diffing by default 
in my .hgrc for those tools, while occasionally passing a dir-diff argument 
when appropriate. Sure, I could make 2 different tools in my .hgrc if we didn't 
want to expose new options to the CLI, but for some reason it feels wrong to 
force users to edit their .hgrc for that.

I see your point about modes vs flags. Like I said, I don't have very strong 
opinions about it so I guess I'll change the second patch and use some flags 
instead. Are we going for --per-file and --confirm then?

Note that the tool config in .hgrc would look a bit less elegant as a result, 
like this:

cmd.blah=/path/to/blah
opts.blah=--some-option -z
per-file.blah=true
confirm.blah=true

So instead I'm proposing a new config that specifies options for the hg extdiff 
command itself, like this:

cmd.blah=/path/to/blah
opts.blah=--some-option -z
hgopts.blah=--per-file --confirm

...but I don't know if that opens up potential abuse or something.  What do you 
think?

> A prompt could be shown for the directory diff. I don't think it's useful
> right now, but if we had a per-revision-diff mode, it would make some sense
> to show prompt to skip some revisions.

I would personally just ignore the prompt when showing only one revision in 
dir-diff mode, but yes, for a revision range dir-diff, it would definitely show 
a prompt between each revision.

-- 
 l u d o .
 . 8 0 17 80
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5550: rust-cpython: bindings for MissingAncestors

2019-01-12 Thread kevincox (Kevin Cox)
kevincox added inline comments.

INLINE COMMENTS

> ancestors.rs:170
> +bases_vec.push(rev.to_py_object(py).into_object());
> +}
> +Ok(PyTuple::new(py, bases_vec.as_slice()))

This could be a `.collect()` call. Something like:

  let bases_vec: Vec = bases_set.into_iter()
  .map(|rev| rev.to_py_object(py).into_object())
  .collect();

> ancestors.rs:193
> +remaining_pyint_vec.push(rev.to_py_object(py).into_object());
> +}
> +let remaining_pylist = PyList::new(py, 
> remaining_pyint_vec.as_slice());

This could also be a `collect()`.

> ancestors.rs:204
> +Err(e) => {
> +return Err(GraphError::pynew(py, e));
> +}

This match can become a `.map_error(|e| GraphError::pynew(py, e))?`

> ancestors.rs:212
> +missing_pyint_vec.push(rev.to_py_object(py).into_object());
> +}
> +Ok(PyList::new(py, missing_pyint_vec.as_slice()))

This can also be a `.collect()`

REPOSITORY
  rHG Mercurial

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

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


[PATCH 2 of 2] ui: proxy protect/restorestdio() calls to update internal flag

2019-01-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1537965712 -32400
#  Wed Sep 26 21:41:52 2018 +0900
# Node ID 8e956cead2023a3afdfb3f06a08b24290dffc244
# Parent  c5a71f1cdd3278159500360435863ee01c842cf4
ui: proxy protect/restorestdio() calls to update internal flag

It should be better to manage the redirection flag solely by the ui class.

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -200,7 +200,7 @@ def _newchgui(srcui, csystem, attachio):
 def _runsystem(self, cmd, environ, cwd, out):
 # fallback to the original system method if
 #  a. the output stream is not stdout (e.g. stderr, cStringIO),
-#  b. or stdout is redirected by protectstdio(),
+#  b. or stdout is redirected by protectfinout(),
 # because the chg client is not aware of these situations and
 # will behave differently (i.e. write to stdout).
 if (out is not self.fout
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1080,14 +1080,38 @@ class ui(object):
 return False
 return procutil.isatty(fh)
 
+def protectfinout(self):
+"""Duplicate ui streams and redirect original if they are stdio
+
+Returns (fin, fout) which point to the original ui fds, but may be
+copy of them. The returned streams can be considered "owned" in that
+print(), exec(), etc. never reach to them.
+"""
+if self._finoutredirected:
+# if already redirected, protectstdio() would just create another
+# nullfd pair, which is equivalent to returning self._fin/_fout.
+return self._fin, self._fout
+fin, fout = procutil.protectstdio(self._fin, self._fout)
+self._finoutredirected = (fin, fout) != (self._fin, self._fout)
+return fin, fout
+
+def restorefinout(self, fin, fout):
+"""Restore ui streams from possibly duplicated (fin, fout)"""
+if (fin, fout) == (self._fin, self._fout):
+return
+procutil.restorestdio(self._fin, self._fout, fin, fout)
+# protectfinout() won't create more than one duplicated streams,
+# so we can just turn the redirection flag off.
+self._finoutredirected = False
+
 @contextlib.contextmanager
 def protectedfinout(self):
 """Run code block with protected standard streams"""
-fin, fout = procutil.protectstdio(self._fin, self._fout)
+fin, fout = self.protectfinout()
 try:
 yield fin, fout
 finally:
-procutil.restorestdio(self._fin, self._fout, fin, fout)
+self.restorefinout(fin, fout)
 
 def disablepager(self):
 self._disablepager = True
diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -24,7 +24,6 @@ from . import (
 from .utils import (
 cborutil,
 interfaceutil,
-procutil,
 )
 
 stringio = util.stringio
@@ -782,9 +781,7 @@ class sshserver(object):
 def __init__(self, ui, repo, logfh=None):
 self._ui = ui
 self._repo = repo
-self._fin, self._fout = procutil.protectstdio(ui.fin, ui.fout)
-# TODO: manage the redirection flag internally by ui
-ui._finoutredirected = (self._fin, self._fout) != (ui.fin, ui.fout)
+self._fin, self._fout = ui.protectfinout()
 
 # Log write I/O to stdout and stderr if configured.
 if logfh:
@@ -795,8 +792,7 @@ class sshserver(object):
 
 def serve_forever(self):
 self.serveuntil(threading.Event())
-procutil.restorestdio(self._ui.fin, self._ui.fout,
-  self._fin, self._fout)
+self._ui.restorefinout(self._fin, self._fout)
 sys.exit(0)
 
 def serveuntil(self, ev):
diff --git a/tests/test-sshserver.py b/tests/test-sshserver.py
--- a/tests/test-sshserver.py
+++ b/tests/test-sshserver.py
@@ -47,6 +47,12 @@ class mockui(object):
 self.fout = io.BytesIO()
 self.ferr = io.BytesIO()
 
+def protectfinout(self):
+return self.fin, self.fout
+
+def restorefinout(self, fin, fout):
+pass
+
 if __name__ == '__main__':
 # Don't call into msvcrt to set BytesIO to binary mode
 procutil.setbinary = lambda fp: True
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2] ui: move protectedstdio() context manager from procutil

2019-01-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1537964953 -32400
#  Wed Sep 26 21:29:13 2018 +0900
# Node ID c5a71f1cdd3278159500360435863ee01c842cf4
# Parent  ead5fb5b2f2908c77aee99cde8b298e407a6efc8
ui: move protectedstdio() context manager from procutil

This is a follow-up series for 23a00bc90a3c, "chgserver: do not send system()
back to client if stdio redirected." The function is renamed using ui terms.

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -399,7 +399,7 @@ class pipeservice(object):
 ui = self.ui
 # redirect stdio to null device so that broken extensions or in-process
 # hooks will never cause corruption of channel protocol.
-with procutil.protectedstdio(ui.fin, ui.fout) as (fin, fout):
+with ui.protectedfinout() as (fin, fout):
 sv = server(ui, self.repo, fin, fout)
 try:
 return sv.serve()
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1080,6 +1080,15 @@ class ui(object):
 return False
 return procutil.isatty(fh)
 
+@contextlib.contextmanager
+def protectedfinout(self):
+"""Run code block with protected standard streams"""
+fin, fout = procutil.protectstdio(self._fin, self._fout)
+try:
+yield fin, fout
+finally:
+procutil.restorestdio(self._fin, self._fout, fin, fout)
+
 def disablepager(self):
 self._disablepager = True
 
diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -299,15 +299,6 @@ def restorestdio(uin, uout, fin, fout):
 os.dup2(f.fileno(), uif.fileno())
 f.close()
 
-@contextlib.contextmanager
-def protectedstdio(uin, uout):
-"""Run code block with protected standard streams"""
-fin, fout = protectstdio(uin, uout)
-try:
-yield fin, fout
-finally:
-restorestdio(uin, uout, fin, fout)
-
 def shellenviron(environ=None):
 """return environ with optional override, useful for shelling out"""
 def py2shell(val):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 2] help: document rewrite.backup-bundle option

2019-01-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1547282866 -32400
#  Sat Jan 12 17:47:46 2019 +0900
# Node ID ead5fb5b2f2908c77aee99cde8b298e407a6efc8
# Parent  f52ca65e212c9a56eb631c81434c4c1fe262ea68
help: document rewrite.backup-bundle option

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1680,7 +1680,6 @@ def _histedit(ui, repo, state, *freeargs
 fm.startitem()
 goal = _getgoal(opts)
 revs = opts.get('rev', [])
-# experimental config: rewrite.backup-bundle
 nobackup = not ui.configbool('rewrite', 'backup-bundle')
 rules = opts.get('commands', '')
 state.keep = opts.get('keep', False)
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1812,6 +1812,9 @@ Alias definitions for revsets. See :hg:`
 ``rewrite``
 ---
 
+``backup-bundle``
+Whether to save stripped changesets to a bundle file. (default: True)
+
 ``update-timestamp``
 If true, updates the date and time of the changeset to current. It is only
 applicable for hg amend in current version.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2] repair: move ui.history-editing-backup to [rewrite] section

2019-01-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1547282616 -32400
#  Sat Jan 12 17:43:36 2019 +0900
# Node ID f52ca65e212c9a56eb631c81434c4c1fe262ea68
# Parent  4f675c12d083a23049d75930bb765ed8bd27cd2c
repair: move ui.history-editing-backup to [rewrite] section

Since we have the "rewrite" section for general history-editing options, the
backup option should be there.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1680,8 +1680,8 @@ def _histedit(ui, repo, state, *freeargs
 fm.startitem()
 goal = _getgoal(opts)
 revs = opts.get('rev', [])
-# experimental config: ui.history-editing-backup
-nobackup = not ui.configbool('ui', 'history-editing-backup')
+# experimental config: rewrite.backup-bundle
+nobackup = not ui.configbool('rewrite', 'backup-bundle')
 rules = opts.get('commands', '')
 state.keep = opts.get('keep', False)
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -177,7 +177,7 @@ class rebaseruntime(object):
 if e:
 self.extrafns = [e]
 
-self.backupf = ui.configbool('ui', 'history-editing-backup')
+self.backupf = ui.configbool('rewrite', 'backup-bundle')
 self.keepf = opts.get('keep', False)
 self.keepbranchesf = opts.get('keepbranches', False)
 self.obsoletenotrebased = {}
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2588,7 +2588,7 @@ def amend(ui, repo, old, extra, pats, op
 obsmetadata = None
 if opts.get('note'):
 obsmetadata = {'note': encoding.fromlocal(opts['note'])}
-backup = ui.configbool('ui', 'history-editing-backup')
+backup = ui.configbool('rewrite', 'backup-bundle')
 scmutil.cleanupnodes(repo, mapping, 'amend', metadata=obsmetadata,
  fixphase=True, targetphase=commitphase,
  backup=backup)
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -991,6 +991,10 @@ coreconfigitem('storage', 'mmap-threshol
 default='1MB',
 alias=[('experimental', 'mmapindexthreshold')],
 )
+coreconfigitem('rewrite', 'backup-bundle',
+default=True,
+alias=[('ui', 'history-editing-backup')],
+)
 coreconfigitem('rewrite', 'update-timestamp',
 default=False,
 )
@@ -1168,9 +1172,6 @@ coreconfigitem('ui', 'formatted',
 coreconfigitem('ui', 'graphnodetemplate',
 default=None,
 )
-coreconfigitem('ui', 'history-editing-backup',
-default=True,
-)
 coreconfigitem('ui', 'interactive',
 default=None,
 )
diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -332,9 +332,9 @@ working directory should be all clean (w
   ? missing_content2_content3-untracked
   ? missing_missing_content3-untracked
 
-==
-Test history-editing-backup config option|
-==
+=
+Test backup-bundle config option|
+=
   $ hg init $TESTTMP/repo4
   $ cd $TESTTMP/repo4
   $ echo a>a
@@ -346,20 +346,20 @@ Test history-editing-backup config optio
 #if obsstore-off
   $ hg amend
   saved backup bundle to 
$TESTTMP/repo4/.hg/strip-backup/95e899acf2ce-f11cb050-amend.hg
-When history-editing-backup config option is set:
+When backup-bundle config option is set:
   $ cat << EOF >> $HGRCPATH
-  > [ui]
-  > history-editing-backup = False
+  > [rewrite]
+  > backup-bundle = False
   > EOF
   $ echo fixed > b
   $ hg amend
 
 #else
   $ hg amend
-When history-editing-backup config option is set:
+When backup-bundle config option is set:
   $ cat << EOF >> $HGRCPATH
-  > [ui]
-  > history-editing-backup = False
+  > [rewrite]
+  > backup-bundle = False
   > EOF
   $ echo fixed > b
   $ hg amend
diff --git a/tests/test-histedit-no-backup.t b/tests/test-histedit-no-backup.t
--- a/tests/test-histedit-no-backup.t
+++ b/tests/test-histedit-no-backup.t
@@ -6,9 +6,9 @@ Enable extension used by this test
   > histedit=
   > EOF
 
-==
-Test history-editing-backup config option|
-==
+=
+Test backup-bundle config option|
+=
 Repo setup:
   $ hg init foo
   $ cd foo
@@ -33,7 +33,7 @@ Repo setup:
   o  0   36b4bdd91f5b   1970-01-01 00:00 +   test
one
   
-Test when `history-editing-backup` config option is enabled:
+Test when `backup-bundle` config option is enabled:
   $ hg histedit -r '36b4bdd91f5b' --commands - << EOF
   > pick 36b4bdd91f5b 0 one
   > pick 6153eb23e623 1 two
@@ -49,11 +49,11 @@ Test when `history-editing-backup` confi
   saved backup bundle to 
$TESTTMP/foo/.hg/strip-backup/1d8f701c7b35-cf7be322-backup.hg
   saved backup bundle