D3847: fix: disallow 'hg fix --base --whole'

2018-06-26 Thread hooper (Danny Hooper)
hooper created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The two flags have conflicting meaning, so we shouldn't pretend to honor both
  (otherwise, --whole takes precedence in the current implementation).

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -178,6 +178,9 @@
   abort: no changesets specified
   (use --rev or --working-dir)
   [255]
+  $ hg fix --base 0 --whole --working-dir
+  abort: --base has no meaning in addition to --whole
+  [255]
 
 Fixing a public revision isn't allowed. It should abort early enough that
 nothing happens, even to the working directory.
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -387,6 +387,8 @@
 # The --base flag overrides the usual logic, and we give every revision
 # exactly the set of baserevs that the user specified.
 if opts.get('base'):
+if opts.get('whole'):
+raise error.Abort('--base has no meaning in addition to --whole')
 baserevs = set(scmutil.revrange(repo, opts.get('base')))
 if not baserevs:
 baserevs = {nullrev}



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


D3848: fix: add progress bar for number of file revisions processed

2018-06-26 Thread hooper (Danny Hooper)
hooper created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This ensures responsiveness when the configured tools are slow or numerous.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/fix.py

CHANGE DETAILS

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -162,7 +162,10 @@
 filedata = collections.defaultdict(dict)
 replacements = {}
 commitorder = sorted(revstofix, reverse=True)
+progress = ui.makeprogress(topic=_('fixing'), unit=_('files'),
+   total=sum(numitems.values()))
 for rev, path, newdata in results:
+progress.increment(item=path)
 if newdata is not None:
 filedata[rev][path] = newdata
 numitems[rev] -= 1
@@ -178,6 +181,7 @@
 else:
 replacerev(ui, repo, ctx, filedata[rev], replacements)
 del filedata[rev]
+progress.complete()
 
 replacements = {prec: [succ] for prec, succ in 
replacements.iteritems()}
 scmutil.cleanupnodes(repo, replacements, 'fix', fixphase=True)



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


D3845: worker: support more return types in posix worker

2018-06-26 Thread hooper (Danny Hooper)
hooper created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This allows us to return things that aren't tuple(int, str) from worker
  functions. I wanted to use marshal instead of pickle, but it seems to read 
from
  the pipe in non-blocking mode, which means it stops before it sees the 
results.
  
  The windows worker already supports arbitrary return values without
  serialization, because it uses threads instead of subprocesses.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/worker.py

CHANGE DETAILS

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -155,8 +155,8 @@
 
 def workerfunc():
 os.close(rfd)
-for i, item in func(*(staticargs + (pargs,))):
-os.write(wfd, '%d %s\n' % (i, item))
+for result in func(*(staticargs + (pargs,))):
+os.write(wfd, util.pickle.dumps(result))
 return 0
 
 ret = scmutil.callcatch(ui, workerfunc)
@@ -187,9 +187,15 @@
 os.kill(os.getpid(), -status)
 sys.exit(status)
 try:
-for line in util.iterfile(fp):
-l = line.split(' ', 1)
-yield int(l[0]), l[1][:-1]
+while True:
+try:
+yield util.pickle.load(fp)
+except EOFError:
+break
+except IOError as e:
+if e.errno == errno.EINTR:
+continue
+raise
 except: # re-raises
 killworkers()
 cleanup()



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


D3846: fix: use a worker pool to parallelize running tools

2018-06-26 Thread hooper (Danny Hooper)
hooper created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is important for usability when tools are slow or numerous.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/fix.py

CHANGE DETAILS

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -70,6 +70,7 @@
 registrar,
 scmutil,
 util,
+worker,
 )
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' 
for
@@ -138,19 +139,40 @@
 basectxs = getbasectxs(repo, opts, revstofix)
 workqueue, numitems = getworkqueue(ui, repo, pats, opts, revstofix,
basectxs)
+fixers = getfixers(ui)
+
+# There are no data dependencies between the workers fixing each file
+# revision, so we can use all available parallelism.
+def getfixes(items):
+for rev, path in items:
+ctx = repo[rev]
+olddata = ctx[path].data()
+newdata = fixfile(ui, opts, fixers, ctx, path, basectxs[rev])
+# Don't waste memory/time passing unchanged content back, but
+# produce one result per item either way.
+yield (rev, path, newdata if newdata != olddata else None)
+results = worker.worker(ui, 1.0, getfixes, tuple(), workqueue)
+
+# We have to hold on to the data for each successor revision in memory
+# until all its parents are committed. We ensure this by committing and
+# freeing memory for the revisions in some topological order. This
+# leaves a little bit of memory efficiency on the table, but also makes
+# the tests deterministic. It might also be considered a feature since
+# it makes the results more easily reproducible.
 filedata = collections.defaultdict(dict)
 replacements = {}
-fixers = getfixers(ui)
-# Some day this loop can become a worker pool, but for now it's easier
-# to fix everything serially in topological order.
-for rev, path in sorted(workqueue):
-ctx = repo[rev]
-olddata = ctx[path].data()
-newdata = fixfile(ui, opts, fixers, ctx, path, basectxs[rev])
-if newdata != olddata:
+commitorder = sorted(revstofix, reverse=True)
+for rev, path, newdata in results:
+if newdata is not None:
 filedata[rev][path] = newdata
 numitems[rev] -= 1
-if not numitems[rev]:
+# Apply the fixes for this and any other revisions that are ready
+# and sitting at the front of the queue. Using a loop here prevents
+# the queue from being blocked by the first revision to be ready 
out
+# of order.
+while commitorder and not numitems[commitorder[-1]]:
+rev = commitorder.pop()
+ctx = repo[rev]
 if rev == wdirrev:
 writeworkingdir(repo, ctx, filedata[rev], replacements)
 else:
@@ -168,11 +190,19 @@
 topological order. Each work item represents a file in the working copy or
 in some revision that should be fixed and written back to the working copy
 or into a replacement revision.
+
+Work items for the same revision are grouped together, so that a worker
+pool starting with the first N items in parallel is likely to finish the
+first revision's work before other revisions. This can allow us to write
+the result to disk and reduce memory footprint. At time of writing, the
+partition strategy in worker.py seems favorable to this. We also sort the
+items by ascending revision number to match the order in which we commit
+the fixes later.
 """
 workqueue = []
 numitems = collections.defaultdict(int)
 maxfilesize = ui.configbytes('fix', 'maxfilesize')
-for rev in revstofix:
+for rev in sorted(revstofix):
 fixctx = repo[rev]
 match = scmutil.match(fixctx, pats, opts)
 for path in pathstofix(ui, repo, pats, opts, match, basectxs[rev],



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


[PATCH 2 of 3 gca-revset V2] revset: add optimization for heads(commonancestors())

2018-06-26 Thread Sean Farley
# HG changeset patch
# User Sean Farley 
# Date 1530051981 25200
#  Tue Jun 26 15:26:21 2018 -0700
# Branch gca-revset
# Node ID 0bab83973dbaecf03167801ddc4550c4b8b581f1
# Parent  6034db436af9b15237bb87f82405eb039dfb
revset: add optimization for heads(commonancestors())

Previously, the only way to get these commits were (tested on
mozilla-central):

hg perfrevset 'heads(::a7cf55 and ::d8b15)'
! wall 4.988366 comb 4.96 user 4.78 sys 0.18 (best of 3)

After this patch:

(python)
hg perfrevset 'heads(commonancestors(a7cf55 + d8b15))'
! wall 0.002155 comb 0.00 user 0.00 sys 0.00 (best of 1107)

(C)
hg perfrevset 'heads(commonancestors(a7cf55 + d8b15))'
! wall 0.000568 comb 0.00 user 0.00 sys 0.00 (best of 4646)

diff --git a/mercurial/revset.py b/mercurial/revset.py
index 14e53e9..d5dc4eb 100644
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -7,10 +7,11 @@
 
 from __future__ import absolute_import
 
 import re
 
+from .ancestor import commonancestorsheads
 from .i18n import _
 from . import (
 dagop,
 destutil,
 encoding,
@@ -361,10 +362,30 @@ def ancestors(repo, subset, x):
 raise error.ParseError(_("negative depth"))
 stopdepth = n + 1
 return _ancestors(repo, subset, args['set'],
   startdepth=startdepth, stopdepth=stopdepth)
 
+# for internal use
+@predicate('_commonancestorheads(set)', safe=True)
+def _commonancestorheads(repo, subset, x):
+"""Returns all greatest common ancestors of the changesets.
+
+This is an internal method is for quickly calculating "heads(::x and ::y)"
+
+These greatest common ancestors are the same ones that the consesus bid
+merge will find.
+
+"""
+h = heads(repo, subset, x)
+
+try:
+ancs = repo.changelog.index.commonancestorsheads(*list(h))
+return subset & baseset(ancs)
+except (AttributeError, OverflowError): # C implementation failed
+return subset & commonancestorsheads(repo.changelog.parentrevs,
+ *list(h))
+
 @predicate('commonancestors(set)', safe=True)
 def commonancestors(repo, subset, x):
 """Returns all common ancestors of the set.
 
 This method is for calculating "::x and ::y" (i.e. all the ancestors that
diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
index 6331709..e559563 100644
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -457,10 +457,16 @@ def _optimize(x):
 return w, (op, x[1], t)
 elif op == 'func':
 f = getsymbol(x[1])
 wa, ta = _optimize(x[2])
 w = getattr(symbols.get(f), '_weight', 1)
+m = _match('commonancestors(_)', ta)
+
+# Optimize heads(commonancestors(_)) because we have a fast version
+if f == 'heads' and m:
+return w + wa, _build('_commonancestorheads(_)', m[1])
+
 return w + wa, (op, x[1], ta)
 raise ValueError('invalid operator %r' % op)
 
 def optimize(tree):
 """Optimize evaluatable tree
diff --git a/tests/test-merge-criss-cross.t b/tests/test-merge-criss-cross.t
index 4901da2..40fe08e 100644
--- a/tests/test-merge-criss-cross.t
+++ b/tests/test-merge-criss-cross.t
@@ -484,10 +484,24 @@ http://stackoverflow.com/questions/93500
   a
   c
   b
   c
 
+Test the greatest common ancestor returning multiple changesets
+
+  $ hg log -r 'heads(commonancestors(head()))'
+  changeset:   1:0f6b37dbe527
+  user:test
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: 1 first change f1
+
+  changeset:   2:d1d156401c1b
+  parent:  0:40494bf2444c
+  user:test
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: 2 first change f2
+
 Verify that the old context ancestor works with / despite preferancestor:
 
   $ hg log -r 'ancestor(head())' --config merge.preferancestor=1 -T '{rev}\n'
   1
   $ hg log -r 'ancestor(head())' --config merge.preferancestor=2 -T '{rev}\n'
diff --git a/tests/test-revset2.t b/tests/test-revset2.t
index cfd0e08..d1db5d5 100644
--- a/tests/test-revset2.t
+++ b/tests/test-revset2.t
@@ -1832,5 +1832,23 @@ Test `draft() & ::x` optimization
   (symbol '_list')
   (string 'S1\x00D2\x00P5'))
 (keyvalue
   (symbol 'depth')
   (symbol '1')
+
+test commonancestors and its optimization
+
+  $ hg debugrevspec --verify -p analyzed -p optimized 
'heads(commonancestors(head()))'
+  * analyzed:
+  (func
+(symbol 'heads')
+(func
+  (symbol 'commonancestors')
+  (func
+(symbol 'head')
+None)))
+  * optimized:
+  (func
+(symbol '_commonancestorheads')
+(func
+  (symbol 'head')
+  None))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 3 gca-revset V2] contrib: add heads(commonancestors(_)) to all-revsets

2018-06-26 Thread Sean Farley
# HG changeset patch
# User Sean Farley 
# Date 1529539666 25200
#  Wed Jun 20 17:07:46 2018 -0700
# Branch gca-revset
# Node ID 89ef7e1c9e733402c0ffdb009da359fde371750f
# Parent  0bab83973dbaecf03167801ddc4550c4b8b581f1
contrib: add heads(commonancestors(_)) to all-revsets

This is mainly to check that we don't regress our optimization path.

diff --git a/contrib/all-revsets.txt b/contrib/all-revsets.txt
index 3b2a8fe..a2f543f 100644
--- a/contrib/all-revsets.txt
+++ b/contrib/all-revsets.txt
@@ -133,5 +133,8 @@ draft() and head()
 head() and author("mpm")
 
 # testing the mutable phases set
 draft()
 secret()
+
+# test finding common ancestors
+heads(commonancestors(46879 + ae7f))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 3 gca-revset V2] revsets: add commonancestors revset

2018-06-26 Thread Sean Farley
# HG changeset patch
# User Sean Farley 
# Date 1529376114 25200
#  Mon Jun 18 19:41:54 2018 -0700
# Branch gca-revset
# Node ID 6034db436af9b15237bb87f82405eb039dfb
# Parent  2f5c622fcb739aed795c9ab51ea69c3b46436054
revsets: add commonancestors revset

This is a method to reproduce "::x and ::y" such that a set can be sent
in. For instance, it'd be convenient to have "::heads()" work like this
but that already means "::x + ::y + ..." for each element in the
"heads()" set.

Therefore, we add the "commonancestors" method to mean "::x and ::y ..."
for each head in the given set.

diff --git a/mercurial/revset.py b/mercurial/revset.py
index 3746a22..14e53e9 100644
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -361,10 +361,27 @@ def ancestors(repo, subset, x):
 raise error.ParseError(_("negative depth"))
 stopdepth = n + 1
 return _ancestors(repo, subset, args['set'],
   startdepth=startdepth, stopdepth=stopdepth)
 
+@predicate('commonancestors(set)', safe=True)
+def commonancestors(repo, subset, x):
+"""Returns all common ancestors of the set.
+
+This method is for calculating "::x and ::y" (i.e. all the ancestors that
+are common to both x and y) in an easy and optimized way. We can't quite
+use "::head()" but that revset returns "::x + ::y + ..." for each head in
+the repo (whereas we want "::x *and* ::y").
+
+"""
+# only wants the heads of the set passed in
+h = heads(repo, subset, x)
+
+commonrevs = repo.revs(" and ".join(["::%s"] * len(h), *h))
+
+return subset & commonrevs
+
 @predicate('_firstancestors', safe=True)
 def _firstancestors(repo, subset, x):
 # ``_firstancestors(set)``
 # Like ``ancestors(set)`` but follows only the first parents.
 return _ancestors(repo, subset, x, followfirst=True)
diff --git a/tests/test-revset.t b/tests/test-revset.t
index e2cde47..7872fc8 100644
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1039,10 +1039,32 @@ test ancestors
   0
   1
   2
   3
 
+test common ancestors
+
+  $ hg log -T '{rev}\n' -r 'commonancestors(7 + 9)'
+  0
+  1
+  2
+  4
+
+  $ hg log -T '{rev}\n' -r 'commonancestors(head())'
+  0
+  1
+  2
+  4
+
+  $ hg log -T '{rev}\n' -r 'commonancestors(9)'
+  0
+  1
+  2
+  4
+  8
+  9
+
 test ancestors with depth limit
 
  (depth=0 selects the node itself)
 
   $ log 'reverse(ancestors(9, depth=0))'
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 3 gca-revset] revset: add a new commonancestorheads method

2018-06-26 Thread Sean Farley

Yuya Nishihara  writes:

> On Fri, 15 Jun 2018 11:19:47 -0700, Sean Farley wrote:
>> >> # HG changeset patch
>> >> # User Sean Farley 
>> >> # Date 1527357855 -7200
>> >> #  Sat May 26 20:04:15 2018 +0200
>> >> # Branch gca-revset
>> >> # Node ID d44266127f1a86af521df2b2c088528c3f3b803a
>> >> # Parent  ab29cfd39f48432d8e7c38cdceb62980d5c22f09
>> >> revset: add a new commonancestorheads method
>
>> >> +  $ hg log -r 'commonancestorheads(head())'
>> >> +  changeset:   1:0f6b37dbe527
>> >> +  user:test
>> >> +  date:Thu Jan 01 00:00:00 1970 +
>> >> +  summary: 1 first change f1
>> >> +  
>> >> +  changeset:   2:d1d156401c1b
>> >> +  parent:  0:40494bf2444c
>> >> +  user:test
>> >> +  date:Thu Jan 01 00:00:00 1970 +
>> >> +  summary: 2 first change f2
>> >
>> > Can you add a test for variable number (0, 1, 2...) of arguments? I think
>> > that's likely to regress.
>> 
>> Ah, yeah, sure.
>> 
>> Further discussion: should introduce this new revset and deprecate the
>> older one?
>
> Deprecate which?

Nevermind, I was confused.

>> Or would it be possible to optimize the heads(::x and ::y)
>> syntax? Thoughts?
>
> For trivial case where x and y are symbols, that's possible. But we can't
> rewrite heads(::head()) to commonancestorheads(head()) since ::(x + y) means
> any ancestors of x or y. That's why I said we would need new function anyway.
>
> If we don't like the commonancestorheads() function, maybe we can add
> commonancestors(x) and rewrite heads(commonancestors(x)) to
> _commonancestorsheads(x).

Dammit, Yuya, you are a genius. I wish I was half as smart. A new
serious is incoming.


signature.asc
Description: PGP signature
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2874: remotenames: synchronise remotenames after push also

2018-06-26 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 9314.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2874?vs=8735&id=9314

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

AFFECTED FILES
  mercurial/exchange.py
  tests/test-logexchange.t

CHANGE DETAILS

diff --git a/tests/test-logexchange.t b/tests/test-logexchange.t
--- a/tests/test-logexchange.t
+++ b/tests/test-logexchange.t
@@ -339,3 +339,59 @@
  default/bar   6:87d6d6676308
  default/foo   3:62615734edd5
* foo   8:3e1487808078
+
+Testing the remotenames sychronization during `hg push`
+---
+
+  $ cd ../server/
+  $ hg bookmark foo
+  moving bookmark 'foo' forward from 62615734edd5
+
+After the push, default/foo should move to rev 8
+  $ cd ../client/
+  $ hg push
+  pushing to ssh://user@dummy/server
+  searching for changes
+  no changes found
+  [1]
+  $ hg log -Gr 'remotenames()'
+  @  changeset:   8:3e1487808078
+  :  branch:  wat
+  :  bookmark:foo
+  :  tag: tip
+  :  remote bookmark:  default/foo
+  :  hoisted name:  foo
+  :  remote branch:  $TESTTMP/server2/wat
+  :  remote branch:  default/wat
+  :  parent:  4:aa98ab95a928
+  :  user:test
+  :  date:Thu Jan 01 00:00:00 1970 +
+  :  summary: added bar
+  :
+  : o  changeset:   7:ec2426147f0e
+  : |  remote branch:  $TESTTMP/server2/default
+  : |  remote branch:  default/default
+  : |  user:test
+  : |  date:Thu Jan 01 00:00:00 1970 +
+  : |  summary: Added h
+  : |
+  : o  changeset:   6:87d6d6676308
+  :/   remote bookmark:  $TESTTMP/server2/bar
+  :remote bookmark:  default/bar
+  :hoisted name:  bar
+  :user:test
+  :date:Thu Jan 01 00:00:00 1970 +
+  :summary: Added g
+  :
+  o  changeset:   3:62615734edd5
+  |  remote bookmark:  $TESTTMP/server2/foo
+  ~  user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: Added d
+  
+  $ hg bookmarks
+ $TESTTMP/server2/bar 6:87d6d6676308
+ $TESTTMP/server2/foo 3:62615734edd5
+ default/bar   6:87d6d6676308
+ default/foo   8:3e1487808078
+   * foo   8:3e1487808078
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -531,6 +531,9 @@
 _pushobsolete(pushop)
 _pushbookmark(pushop)
 
+if repo.ui.configbool('experimental', 'remotenames'):
+logexchange.pullremotenames(repo, remote)
+
 return pushop
 
 # list of steps to perform discovery before push



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


D3639: remotenames: add paths argument to remotenames revset

2018-06-26 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 9315.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3639?vs=8849&id=9315

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

AFFECTED FILES
  hgext/remotenames.py
  tests/test-logexchange.t

CHANGE DETAILS

diff --git a/tests/test-logexchange.t b/tests/test-logexchange.t
--- a/tests/test-logexchange.t
+++ b/tests/test-logexchange.t
@@ -291,6 +291,7 @@
   ~
 
 Updating to revision using hoisted name
+---
 
 Deleting local bookmark to make sure we update to hoisted name only
 
@@ -395,3 +396,173 @@
  default/bar   6:87d6d6676308
  default/foo   8:3e1487808078
* foo   8:3e1487808078
+
+Testing the paths argument to remotenames, remotebranches and remotebookmarks 
revsets
+--
+
+  $ cd ..
+  $ hg clone ssh://user@dummy/server client2
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 9 changesets with 9 changes to 9 files (+1 heads)
+  new changesets 18d04c59bb5d:3e1487808078
+  updating to branch default
+  8 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd server2
+  $ hg up wat
+  6 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo foo > watwat
+  $ hg ci -Aqm "added watwat"
+  $ hg bookmark bar
+  abort: bookmark 'bar' already exists (use -f to force)
+  [255]
+  $ hg up ec24
+  3 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo i > i
+  $ hg ci -Aqm "added i"
+
+  $ cd ../client2
+  $ echo "[paths]" >> .hg/hgrc
+  $ echo "server2 = $TESTTMP/server2" >> .hg/hgrc
+  $ hg pull server2
+  pulling from $TESTTMP/server2
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 2 files
+  new changesets f34adec73c21:bf433e48adea
+  (run 'hg update' to get a working copy)
+
+  $ hg log -Gr 'remotenames()' -T '{rev}:{node|short} 
{desc}\n({remotebranches})  [{remotebookmarks}]\n\n'
+  o  10:bf433e48adea added i
+  |  (server2/default)  []
+  |
+  | o  9:f34adec73c21 added watwat
+  | |  (server2/wat)  []
+  | |
+  | o  8:3e1487808078 added bar
+  | :  (default/wat)  [default/foo]
+  | :
+  @ :  7:ec2426147f0e Added h
+  | :  (default/default)  []
+  | :
+  o :  6:87d6d6676308 Added g
+  :/   ()  [default/bar server2/bar]
+  :
+  o  3:62615734edd5 Added d
+  |  ()  [server2/foo]
+  ~
+
+Testing for a single path name which exists
+
+  $ hg log -r 'remotebranches(default)' -GT "{rev}:{node|short} 
{remotebranches}\n"
+  o  8:3e1487808078 default/wat
+  |
+  ~
+  @  7:ec2426147f0e default/default
+  |
+  ~
+
+  $ hg log -r 'remotebookmarks("server2")' -GT "{rev}:{node|short} 
{remotebookmarks}\n"
+  o  6:87d6d6676308 default/bar server2/bar
+  :
+  o  3:62615734edd5 server2/foo
+  |
+  ~
+
+  $ hg log -r 'remotenames(default)' -GT "{rev}:{node|short} {remotenames}\n"
+  o  8:3e1487808078 default/foo default/wat
+  |
+  ~
+  @  7:ec2426147f0e default/default
+  |
+  o  6:87d6d6676308 default/bar server2/bar
+  |
+  ~
+
+Testing for a single path name which does not exists
+
+  $ hg log -r 'remotebranches(def)' -GT "{rev}:{node|short} {remotenames}\n"
+
+  $ hg log -r 'remotebookmarks("server3")' -GT "{rev}:{node|short} 
{remotenames}\n"
+
+  $ hg log -r 'remotenames("server3")' -GT "{rev}:{node|short} {remotenames}\n"
+
+Testing for multiple paths where all of them exists
+
+  $ hg log -r 'remotenames(default, server2)' -GT "{rev}:{node|short} 
{remotenames}\n"
+  o  10:bf433e48adea server2/default
+  |
+  | o  9:f34adec73c21 server2/wat
+  | |
+  | o  8:3e1487808078 default/foo default/wat
+  | :
+  @ :  7:ec2426147f0e default/default
+  | :
+  o :  6:87d6d6676308 default/bar server2/bar
+  :/
+  o  3:62615734edd5 server2/foo
+  |
+  ~
+
+  $ hg log -r 'remotebranches(default, server2)' -GT "{rev}:{node|short} 
{remotebranches}\n"
+  o  10:bf433e48adea server2/default
+  |
+  | o  9:f34adec73c21 server2/wat
+  | |
+  | o  8:3e1487808078 default/wat
+  | |
+  | ~
+  @  7:ec2426147f0e default/default
+  |
+  ~
+
+  $ hg log -r 'remotebookmarks(default, server2)' -GT "{rev}:{node|short} 
{remotebookmarks}\n"
+  o  8:3e1487808078 default/foo
+  :
+  : o  6:87d6d6676308 default/bar server2/bar
+  :/
+  o  3:62615734edd5 server2/foo
+  |
+  ~
+
+Testing for multipe paths where some exists and some not
+
+  $ hg log -r 'remotenames(def, server2)' -GT "{rev}:{node|short} 
{remotenames}\n"
+  o  10:bf433e48adea server2/default
+  :
+  : o  9:f34adec73c21 server2/wat
+  : :
+  o :  6:87d6d6676308 default/bar server2/bar
+  :/
+  o  3:62615734edd5 server2/foo
+  |
+  ~
+
+  $ hg log -r 'remotebranches(default, server)' -GT "{rev}:{node|short} 
{remotebranches}\n"
+  o  8:3e1487808078 default/wat
+  |
+  ~
+  @  7:ec2426147f0e default/default
+  |
+  ~
+
+  $ hg log -r 'remote

D3844: remotenames: add support to accept literal/re pattern in revsets

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

REVISION SUMMARY
  This patch add supports to remotenames(), remotebookmarks() and 
remotebranches()
  revsets to accept literal/re patterns which is similar to the behavior what we
  have in bookmark() revset.
  
  New tests are added for pattern matching and not breaking of existing tests
  shows that we are fine.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotenames.py
  tests/test-logexchange.t

CHANGE DETAILS

diff --git a/tests/test-logexchange.t b/tests/test-logexchange.t
--- a/tests/test-logexchange.t
+++ b/tests/test-logexchange.t
@@ -566,3 +566,31 @@
 
   $ hg log -r 'remotebookmarks(delt, serv)' -GT "{rev}:{node|short} 
{remotebookmarks}\n"
 
+Testing pattern matching
+
+  $ hg log -r 'remotenames("re:def")' -GT "{rev}:{node|short} {remotenames}\n"
+  o  8:3e1487808078 default/foo default/wat
+  |
+  ~
+  @  7:ec2426147f0e default/default
+  |
+  o  6:87d6d6676308 default/bar server2/bar
+  |
+  ~
+
+  $ hg log -r 'remotebranches("re:ser.*2")' -GT "{rev}:{node|short} 
{remotebranches}\n"
+  o  10:bf433e48adea server2/default
+  |
+  ~
+  o  9:f34adec73c21 server2/wat
+  |
+  ~
+
+  $ hg log -r 'remotebookmarks("re:def", "re:.*2")' -GT "{rev}:{node|short} 
{remotebookmarks}\n"
+  o  8:3e1487808078 default/foo
+  :
+  : o  6:87d6d6676308 default/bar server2/bar
+  :/
+  o  3:62615734edd5 server2/foo
+  |
+  ~
diff --git a/hgext/remotenames.py b/hgext/remotenames.py
--- a/hgext/remotenames.py
+++ b/hgext/remotenames.py
@@ -42,6 +42,10 @@
 templateutil,
 )
 
+from mercurial.utils import (
+stringutil,
+)
+
 if pycompat.ispy3:
 import collections.abc
 mutablemapping = collections.abc.MutableMapping
@@ -347,54 +351,87 @@
 
 revs = set()
 cl = repo.changelog
+literals, matchers = paths
+# whether arguments were passed or not
+argspassed = bool(literals or matchers)
 for rtype in rtypes:
 if rtype in repo.names:
 ns = repo.names[rtype]
 for name in ns.listnames(repo):
-if paths:
-if name.split('/')[0] in paths:
+if argspassed:
+rname = name.split('/')[0]
+if rname in literals:
 revs.update(ns.nodes(repo, name))
+continue
+for matcher in matchers:
+if matcher(rname):
+revs.update(ns.nodes(repo, name))
+break
 else:
 revs.update(ns.nodes(repo, name))
 
 results = (cl.rev(n) for n in revs if cl.hasnode(n))
 return subset & smartset.baseset(sorted(results))
 
 def _parsepaths(x):
-"""parses the argument passed in revsets as paths and return
-them as a set or returns None if no path is specified"""
+"""parses the argument passed in revsets as paths
+
+returns (literals, matchers) where,
+literals is a set of literals passed by user
+matchers is a list of matcher objects for patterns passed by user
+"""
+
+# set of paths passed as literals
+literals = set()
+# list of matcher to match the patterns passed as paths
+matchers = []
 
 if not x:
-return None
+return literals, matchers
 
 paths = set()
 lx = revsetlang.getlist(x)
 err = _('the argument must be a string')
 for entry in lx:
 paths.add(revsetlang.getstring(entry, err))
-return paths
+for p in paths:
+kind, pattern, matcher = stringutil.stringmatcher(p)
+if kind == 'literal':
+literals.add(pattern)
+else:
+matchers.append(matcher)
+return literals, matchers
 
 @revsetpredicate('remotenames([path, ...])')
 def remotenamesrevset(repo, subset, x):
 """All changesets which have a remotename on them. If paths are specified,
-remotenames of those remote paths are only considered."""
+remotenames of those remote paths are only considered.
+
+Pattern matching is supported for `path`. See :hg:`help 
revisions.patterns`.
+"""
 
 paths = _parsepaths(x)
 return _revsetutil(repo, subset, x, ('remotebookmarks', 'remotebranches'),
paths)
 
 @revsetpredicate('remotebranches([path, ...])')
 def remotebranchesrevset(repo, subset, x):
 """All changesets which are branch heads on remotes. If paths are 
specified,
-only those remotes paths are considered"""
+only those remotes paths are considered.
+
+Pattern matching is supported for `path`. See :hg:`help 
revisions.patterns`.
+"""
 
 paths = _parsepaths(x)
 return _revsetutil(repo, subset, x, ('remotebranches',), paths)
 
 @revsetpredicate('remotebookmarks([path, ...])')
 def remotebmarksrevset(repo, subset, x):
 """All changesets which have bookmarks on remot

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

2018-06-26 Thread khanchi97 (Sushil khanchi)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG622f79e3a1cb: graft: add no-commit mode (issue5631) 
(authored by khanchi97, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D2409?vs=9301&id=9311#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2409?vs=9301&id=9311

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-completion.t
  tests/test-graft.t

CHANGE DETAILS

diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1885,3 +1885,246 @@
   new changesets detected on destination branch, can't strip
   graft aborted
   working directory is now at 6b98ff0062dd
+
+  $ cd ..
+
+
+Testing --no-commit option:|
+
+
+  $ hg init nocommit
+  $ cd nocommit
+  $ echo a > a
+  $ hg ci -qAma
+  $ echo b > b
+  $ hg ci -qAmb
+  $ hg up -q 0
+  $ echo c > c
+  $ hg ci -qAmc
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  2:d36c0562f908 c
+  |
+  | o  1:d2ae7f538514 b
+  |/
+  o  0:cb9a9f314b8b a
+  
+
+Check reporting when --no-commit used with non-applicable options:
+
+  $ hg graft 1 --no-commit -e
+  abort: cannot specify --no-commit and --edit together
+  [255]
+
+  $ hg graft 1 --no-commit --log
+  abort: cannot specify --no-commit and --log together
+  [255]
+
+  $ hg graft 1 --no-commit -D
+  abort: cannot specify --no-commit and --currentdate together
+  [255]
+
+Test --no-commit is working:
+  $ hg graft 1 --no-commit
+  grafting 1:d2ae7f538514 "b"
+
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  2:d36c0562f908 c
+  |
+  | o  1:d2ae7f538514 b
+  |/
+  o  0:cb9a9f314b8b a
+  
+
+  $ hg diff
+  diff -r d36c0562f908 b
+  --- /dev/nullThu Jan 01 00:00:00 1970 +
+  +++ b/b  Thu Jan 01 00:00:00 1970 +
+  @@ -0,0 +1,1 @@
+  +b
+
+Prepare wrdir to check --no-commit is resepected after --continue:
+
+  $ hg up -qC
+  $ echo A>a
+  $ hg ci -qm "A in file a"
+  $ hg up -q 1
+  $ echo B>a
+  $ hg ci -qm "B in file a"
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  4:2aa9ad1006ff B in file a
+  |
+  | o  3:09e253b87e17 A in file a
+  | |
+  | o  2:d36c0562f908 c
+  | |
+  o |  1:d2ae7f538514 b
+  |/
+  o  0:cb9a9f314b8b a
+  
+
+  $ hg graft 3 --no-commit
+  grafting 3:09e253b87e17 "A in file a"
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  abort: unresolved conflicts, can't continue
+  (use 'hg resolve' and 'hg graft --continue')
+  [255]
+
+Resolve conflict:
+  $ echo A>a
+  $ hg resolve --mark
+  (no more unresolved files)
+  continue: hg graft --continue
+
+  $ hg graft --continue
+  grafting 3:09e253b87e17 "A in file a"
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  4:2aa9ad1006ff B in file a
+  |
+  | o  3:09e253b87e17 A in file a
+  | |
+  | o  2:d36c0562f908 c
+  | |
+  o |  1:d2ae7f538514 b
+  |/
+  o  0:cb9a9f314b8b a
+  
+  $ hg diff
+  diff -r 2aa9ad1006ff a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,1 +1,1 @@
+  -B
+  +A
+
+  $ hg up -qC
+
+Check --no-commit is resepected when passed with --continue:
+
+  $ hg graft 3
+  grafting 3:09e253b87e17 "A in file a"
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  abort: unresolved conflicts, can't continue
+  (use 'hg resolve' and 'hg graft --continue')
+  [255]
+
+Resolve conflict:
+  $ echo A>a
+  $ hg resolve --mark
+  (no more unresolved files)
+  continue: hg graft --continue
+
+  $ hg graft --continue --no-commit
+  grafting 3:09e253b87e17 "A in file a"
+  $ hg diff
+  diff -r 2aa9ad1006ff a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,1 +1,1 @@
+  -B
+  +A
+
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  4:2aa9ad1006ff B in file a
+  |
+  | o  3:09e253b87e17 A in file a
+  | |
+  | o  2:d36c0562f908 c
+  | |
+  o |  1:d2ae7f538514 b
+  |/
+  o  0:cb9a9f314b8b a
+  
+  $ hg up -qC
+
+Test --no-commit when graft multiple revisions:
+When there is conflict:
+  $ hg graft -r "2::3" --no-commit
+  grafting 2:d36c0562f908 "c"
+  grafting 3:09e253b87e17 "A in file a"
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  abort: unresolved conflicts, can't continue
+  (use 'hg resolve' and 'hg graft --continue')
+  [255]
+
+  $ echo A>a
+  $ hg resolve --mark
+  (no more unresolved files)
+  continue: hg graft --continue
+  $ hg graft --continue
+  grafting 3:09e253b87e17 "A in file a"
+  $ hg diff
+  diff -r 2aa9ad1006ff a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,1 +1,1 @@
+  -B
+  +A
+  diff -r 2aa9ad1006ff c
+  --- /dev/nullThu Jan 01 00:00:00 1970 +
+  +++ b/c  Thu Jan 01 00:00:00 1970 +
+  @@ -0,0 +1,1 @@
+  +c
+
+  $ hg log -

D3842: cleanup: migrate from re.escape to stringutil.reescape

2018-06-26 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG67dc32d4e790: cleanup: migrate from re.escape to 
stringutil.reescape (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3842?vs=9309&id=9313

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

AFFECTED FILES
  hgext/keyword.py
  hgext/lfs/pointer.py
  mercurial/hgweb/webutil.py
  mercurial/match.py
  mercurial/sshpeer.py
  mercurial/sslutil.py
  tests/test-walk.t

CHANGE DETAILS

diff --git a/tests/test-walk.t b/tests/test-walk.t
--- a/tests/test-walk.t
+++ b/tests/test-walk.t
@@ -92,11 +92,11 @@
   f  mammals/skunk   skunk
   $ hg debugwalk -v -I '*k'
   * matcher:
-  
+  
   f  mammals/skunk  skunk
   $ hg debugwalk -v -I 'glob:*k'
   * matcher:
-  
+  
   f  mammals/skunk  skunk
   $ hg debugwalk -v -I 'relglob:*k'
   * matcher:
@@ -260,15 +260,15 @@
   f  mammals/skunk   skunk
   $ hg debugwalk -v Procyonidae
   * matcher:
-  
+  
   f  mammals/Procyonidae/cacomistle  Procyonidae/cacomistle
   f  mammals/Procyonidae/coatimundi  Procyonidae/coatimundi
   f  mammals/Procyonidae/raccoon Procyonidae/raccoon
 
   $ cd Procyonidae
   $ hg debugwalk -v .
   * matcher:
-  
+  
   f  mammals/Procyonidae/cacomistle  cacomistle
   f  mammals/Procyonidae/coatimundi  coatimundi
   f  mammals/Procyonidae/raccoon raccoon
@@ -316,7 +316,7 @@
   f  beans/turtlebeans/turtle
   $ hg debugwalk -v -I '{*,{b,m}*/*}k'
   * matcher:
-  
+  
   f  beans/blackbeans/black
   f  fenugreek  fenugreek
   f  mammals/skunk  mammals/skunk
@@ -330,25 +330,25 @@
   
   $ hg debugwalk -v -Inon-existent -Ibeans/black
   * matcher:
-  
+  
   f  beans/black  beans/black
   $ hg debugwalk -v -Ibeans beans/black
   * matcher:
   ,
+m1=,
 m2=>
   f  beans/black  beans/black  exact
   $ hg debugwalk -v -Ibeans/black beans
   * matcher:
   ,
-m2=>
+m2=>
   f  beans/black  beans/black
   $ hg debugwalk -v -Xbeans/black beans
   * matcher:
   ,
-m2=>
+m2=>
   f  beans/borlotti  beans/borlotti
   f  beans/kidneybeans/kidney
   f  beans/navy  beans/navy
@@ -358,42 +358,42 @@
   * matcher:
   ,
-m2=>
+m2=>
   f  beans/borlotti  beans/borlotti
   f  beans/kidneybeans/kidney
   f  beans/navy  beans/navy
   f  beans/pinto beans/pinto
   f  beans/turtlebeans/turtle
   $ hg debugwalk -v -Xbeans/black beans/black
   * matcher:
   ,
-m2=>
+m1=,
+m2=>
   $ hg debugwalk -v -Xbeans/black -Ibeans/black
   * matcher:
   ,
-m2=>
+m1=,
+m2=>
   $ hg debugwalk -v -Xbeans beans/black
   * matcher:
   ,
+m1=,
 m2=>
   $ hg debugwalk -v -Xbeans -Ibeans/black
   * matcher:
   ,
+m1=,
 m2=>
   $ hg debugwalk -v 'glob:mammals/../beans/b*'
   * matcher:
-  
+  
   f  beans/black beans/black
   f  beans/borlotti  beans/borlotti
   $ hg debugwalk -v '-X*/Procyonidae' mammals
   * matcher:
   ,
-m2=>
+m2=>
   f  mammals/skunk  mammals/skunk
   $ hg debugwalk -v path:mammals
   * matcher:
@@ -436,12 +436,12 @@
   $ hg debugwalk -v beans/black -X 'path:beans'
   * matcher:
   ,
+m1=,
 m2=>
   $ hg debugwalk -v -I 'path:beans/black' -X 'path:beans'
   * matcher:
   ,
+m1=,
 m2=>
 
 Test absolute paths:
@@ -485,11 +485,11 @@
   glob: $ENOENT$
   $ hg debugwalk -v glob:glob:glob
   * matcher:
-  
+  
   f  glob:glob  glob:glob  exact
   $ hg debugwalk -v path:glob:glob
   * matcher:
-  
+  
   f  glob:glob  glob:glob  exact
   $ rm glob:glob
   $ hg addremove
@@ -511,32 +511,32 @@
 
   $ hg debugwalk -v path:beans/black
   * matcher:
-  
+  
   f  beans/black  beans/black  exact
   $ hg debugwalk -v path:beans//black
   * matcher:
-  
+  
   f  beans/black  beans/black  exact
 
   $ hg debugwalk -v relglob:Procyonidae
   * matcher:
   
   $ hg debugwalk -v 'relglob:Procyonidae/**'
   * matcher:
-  
+  
   f  mammals/Procyonidae/cacomistle  mammals/Procyonidae/cacomistle
   f  mammals/Procyonidae/coatimundi  mammals/Procyonidae/coatimundi
   f  mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
   $ hg debugwalk -v 'relglob:Procyonidae/**' fennel
   * matcher:
-  
+  
   f  fennel  fennel  exact
   f  mammals/Procyonidae/cacomistle  mammals/Procyonidae/cacomistle
   f  mammals/Procyonidae/coatimundi  mammals/Procyonidae/coatimundi
   f  mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
   $ hg debugwalk -v beans 'glob:beans/*'
   * matcher:
-  
+  
   f  beans/black beans/black
   f  beans/borlotti  beans/borlotti
   f  beans/kidneybeans/kidney
@@ -598,7 +598,7 @@
   
   $ hg debugwalk -v ignored/file
   * matcher:
-  
+  
   f  ignored/file  ignored/file  exact
 
 Test listfile and listfile0
@@ -612,25 +612,25 @@
   $ $PYTHON -c "open('listfile', 
'wb').write(b'fenugreek\nnew\r\nmammals/skunk\n')"
   $ hg debugwalk -v -I 'listfile:listfile'
   * matcher:
-  
+

D3841: stringutil: add a new function to do minimal regex escaping

2018-06-26 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG96f65bdf0bf4: stringutil: add a new function to do minimal 
regex escaping (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3841?vs=9308&id=9312

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

AFFECTED FILES
  mercurial/utils/stringutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py
--- a/mercurial/utils/stringutil.py
+++ b/mercurial/utils/stringutil.py
@@ -23,6 +23,25 @@
 pycompat,
 )
 
+# regex special chars pulled from https://bugs.python.org/issue29995
+# which was part of Python 3.7.
+_respecial = pycompat.bytestr(b'()[]{}?*+-|^$\\.# \t\n\r\v\f')
+_regexescapemap = {ord(i): (b'\\' + i).decode('latin1') for i in _respecial}
+
+def reescape(pat):
+"""Drop-in replacement for re.escape."""
+# NOTE: it is intentional that this works on unicodes and not
+# bytes, as it's only possible to do the escaping with
+# unicode.translate, not bytes.translate. Sigh.
+wantuni = True
+if isinstance(pat, bytes):
+wantuni = False
+pat = pat.decode('latin1')
+pat = pat.translate(_regexescapemap)
+if wantuni:
+return pat
+return pat.encode('latin1')
+
 def pprint(o, bprefix=False):
 """Pretty print an object."""
 if isinstance(o, bytes):



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


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

2018-06-26 Thread pulkit (Pulkit Goyal)
pulkit accepted this revision.
pulkit added a comment.


  landed 

REPOSITORY
  rHG Mercurial

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

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


D3843: tests: fix up some lax escaping in test-template-basic.t

2018-06-26 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  These misfired escapes turn into hard errors in Python 3.7, and I'd
  really rather we not work around it. We should *probably* try and find
  a way to proactively warn users about invalid escape sequences.
  
  There's one more failure of this type in this file on Python 3.7, but
  I can't figure out the issue. It'll need to be corrected in a
  follow-up.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-template-basic.t

CHANGE DETAILS

diff --git a/tests/test-template-basic.t b/tests/test-template-basic.t
--- a/tests/test-template-basic.t
+++ b/tests/test-template-basic.t
@@ -835,11 +835,11 @@
   -o perso-
   $ hg log -R a -r 2 --template '{sub(r"\\x6e", "-", desc)}\n'
   no person
-  $ hg log -R a -r 2 --template '{sub("n", r"\x2d", desc)}\n'
+  $ hg log -R a -r 2 --template '{sub("n", r"\\x2d", desc)}\n'
   \x2do perso\x2d
   $ hg log -R a -r 2 --template '{sub("n", "\x2d", "no perso\x6e")}\n'
   -o perso-
-  $ hg log -R a -r 2 --template '{sub("n", r"\x2d", r"no perso\x6e")}\n'
+  $ hg log -R a -r 2 --template '{sub("n", r"\\x2d", r"no perso\x6e")}\n'
   \x2do perso\x6e
 
   $ hg log -R a -r 8 --template '{files % "{file}\n"}'



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


Re: [PATCH 3 of 7] dispatch: rework the serve --stdio safe argument checks

2018-06-26 Thread Augie Fackler


> On Jun 26, 2018, at 07:53, Yuya Nishihara  wrote:
> 
> On Mon, 25 Jun 2018 19:51:52 +0200, Paul Morelle wrote:
>> On 22/06/18 13:15, Yuya Nishihara wrote:
>>> On Thu, 21 Jun 2018 19:46:24 +0200, Paul Morelle wrote:
>> Doing this at the authorized_keys level is not an option for us. In one
>> of our target environment for this kind of debugging, any change to the
>> ssh script requires validation by admin people that can take from a
>> couple of days to a couple of weeks, making it impossible to turn
>> debugging on for a couple of commands, or easily compare various settings.
> 
> IMHO, that doesn't justify why we have to put everything in hg core.
> "hg serve" itself is an SSH script in security POV.

Agreed. It's also a strong argument for infrastructure-as-code so you can test 
configuration changes like this on a disposable VM, then apply to the real 
environment once it's right.

> 
>> The ability to control the used debug options from the client is very
>> valuable in this case. We have already gathered many useful information
>> from it!
>> 
>> I agree that ad-hoc argument parsing is less than optimal. Handling
>> three extra flags (--debug, --profile and --traceback) is not too awful,
>> but then we need to pass some associated configuration option (e.g.
>> profiling.time-track=real) which will make things even more verbose.
>> 
>> Maybe we could leverage the contents of `mercurial/configitems.py` by
>> adding a "serversafe" attribute to the configuration items? Such config
>> item could be specified on the client side (if the user is allowed to).
> 
> No, that sounds worse than the original patch. IIUC, the reason why we have
> hard-coded check for req.args is that our option parser isn't strict and is
> likely to allow command-line injection. Making the whitelist fully 
> configurable
> would be dangerous.

Yep. I'm dubious we'd ever take such a patch.

> 
 I don't think that moving the permission handling outside of Mercurial
 would be a good move : implementing similar features for HTTP would
 still require some Mercurial-side restrictions and permissions handling
 anyway. It seems more consistent to implement it on the Mercurial side
 for all protocols.
>>> I agree it should be handled at protocol level, and I think it should be
>>> a wire command/option rather than the command argument hack. IMHO, it's
>>> way safer than constructing/parsing shell command arguments carefully,
>>> and HTTP will need that anyway.
>> The life cycle of the server is quite different in ssh and http, and
>> this has different implications.
>> For the ssh client, there are multiple initializations and cachings that
>> are worth tracking, so tracking the full run is what is most appropriate
>> for our needs.
>> For http, the arguments will have to be processed at the hgweb level
>> (instead of the protocol level).
> 
> I know the situation of HTTP and SSH is slightly different, but how important
> it is to catch the early-stage thingy by extending the SSH command-line
> interface, which we have to support forever? I think wire-protocol level
> implementation will be good enough, and better in the long run.
> ___
> 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


D3842: cleanup: migrate from re.escape to stringutil.reescape

2018-06-26 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This has consistent behavior on Python 2.7, 3.6, and 3.7 and has the
  benefit of probably being a little faster. Test output changes are
  largely because / used to be pointlessly escaped.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/keyword.py
  hgext/lfs/pointer.py
  mercurial/hgweb/webutil.py
  mercurial/match.py
  mercurial/sshpeer.py
  mercurial/sslutil.py
  tests/test-walk.t

CHANGE DETAILS

diff --git a/tests/test-walk.t b/tests/test-walk.t
--- a/tests/test-walk.t
+++ b/tests/test-walk.t
@@ -92,11 +92,11 @@
   f  mammals/skunk   skunk
   $ hg debugwalk -v -I '*k'
   * matcher:
-  
+  
   f  mammals/skunk  skunk
   $ hg debugwalk -v -I 'glob:*k'
   * matcher:
-  
+  
   f  mammals/skunk  skunk
   $ hg debugwalk -v -I 'relglob:*k'
   * matcher:
@@ -260,15 +260,15 @@
   f  mammals/skunk   skunk
   $ hg debugwalk -v Procyonidae
   * matcher:
-  
+  
   f  mammals/Procyonidae/cacomistle  Procyonidae/cacomistle
   f  mammals/Procyonidae/coatimundi  Procyonidae/coatimundi
   f  mammals/Procyonidae/raccoon Procyonidae/raccoon
 
   $ cd Procyonidae
   $ hg debugwalk -v .
   * matcher:
-  
+  
   f  mammals/Procyonidae/cacomistle  cacomistle
   f  mammals/Procyonidae/coatimundi  coatimundi
   f  mammals/Procyonidae/raccoon raccoon
@@ -316,7 +316,7 @@
   f  beans/turtlebeans/turtle
   $ hg debugwalk -v -I '{*,{b,m}*/*}k'
   * matcher:
-  
+  
   f  beans/blackbeans/black
   f  fenugreek  fenugreek
   f  mammals/skunk  mammals/skunk
@@ -330,25 +330,25 @@
   
   $ hg debugwalk -v -Inon-existent -Ibeans/black
   * matcher:
-  
+  
   f  beans/black  beans/black
   $ hg debugwalk -v -Ibeans beans/black
   * matcher:
   ,
+m1=,
 m2=>
   f  beans/black  beans/black  exact
   $ hg debugwalk -v -Ibeans/black beans
   * matcher:
   ,
-m2=>
+m2=>
   f  beans/black  beans/black
   $ hg debugwalk -v -Xbeans/black beans
   * matcher:
   ,
-m2=>
+m2=>
   f  beans/borlotti  beans/borlotti
   f  beans/kidneybeans/kidney
   f  beans/navy  beans/navy
@@ -358,42 +358,42 @@
   * matcher:
   ,
-m2=>
+m2=>
   f  beans/borlotti  beans/borlotti
   f  beans/kidneybeans/kidney
   f  beans/navy  beans/navy
   f  beans/pinto beans/pinto
   f  beans/turtlebeans/turtle
   $ hg debugwalk -v -Xbeans/black beans/black
   * matcher:
   ,
-m2=>
+m1=,
+m2=>
   $ hg debugwalk -v -Xbeans/black -Ibeans/black
   * matcher:
   ,
-m2=>
+m1=,
+m2=>
   $ hg debugwalk -v -Xbeans beans/black
   * matcher:
   ,
+m1=,
 m2=>
   $ hg debugwalk -v -Xbeans -Ibeans/black
   * matcher:
   ,
+m1=,
 m2=>
   $ hg debugwalk -v 'glob:mammals/../beans/b*'
   * matcher:
-  
+  
   f  beans/black beans/black
   f  beans/borlotti  beans/borlotti
   $ hg debugwalk -v '-X*/Procyonidae' mammals
   * matcher:
   ,
-m2=>
+m2=>
   f  mammals/skunk  mammals/skunk
   $ hg debugwalk -v path:mammals
   * matcher:
@@ -436,12 +436,12 @@
   $ hg debugwalk -v beans/black -X 'path:beans'
   * matcher:
   ,
+m1=,
 m2=>
   $ hg debugwalk -v -I 'path:beans/black' -X 'path:beans'
   * matcher:
   ,
+m1=,
 m2=>
 
 Test absolute paths:
@@ -485,11 +485,11 @@
   glob: $ENOENT$
   $ hg debugwalk -v glob:glob:glob
   * matcher:
-  
+  
   f  glob:glob  glob:glob  exact
   $ hg debugwalk -v path:glob:glob
   * matcher:
-  
+  
   f  glob:glob  glob:glob  exact
   $ rm glob:glob
   $ hg addremove
@@ -511,32 +511,32 @@
 
   $ hg debugwalk -v path:beans/black
   * matcher:
-  
+  
   f  beans/black  beans/black  exact
   $ hg debugwalk -v path:beans//black
   * matcher:
-  
+  
   f  beans/black  beans/black  exact
 
   $ hg debugwalk -v relglob:Procyonidae
   * matcher:
   
   $ hg debugwalk -v 'relglob:Procyonidae/**'
   * matcher:
-  
+  
   f  mammals/Procyonidae/cacomistle  mammals/Procyonidae/cacomistle
   f  mammals/Procyonidae/coatimundi  mammals/Procyonidae/coatimundi
   f  mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
   $ hg debugwalk -v 'relglob:Procyonidae/**' fennel
   * matcher:
-  
+  
   f  fennel  fennel  exact
   f  mammals/Procyonidae/cacomistle  mammals/Procyonidae/cacomistle
   f  mammals/Procyonidae/coatimundi  mammals/Procyonidae/coatimundi
   f  mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
   $ hg debugwalk -v beans 'glob:beans/*'
   * matcher:
-  
+  
   f  beans/black beans/black
   f  beans/borlotti  beans/borlotti
   f  beans/kidneybeans/kidney
@@ -598,7 +598,7 @@
   
   $ hg debugwalk -v ignored/file
   * matcher:
-  
+  
   f  ignored/file  ignored/file  exact
 
 Test listfile and listfile0
@@ -612,25 +612,25 @@
   $ $PYTHON -c "open('listfile', 
'wb').write(b'fenugreek\nnew\r\nmammals/skunk\n')"
   $ hg debugwalk -v -I

D3841: stringutil: add a new function to do minimal regex escaping

2018-06-26 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Per https://bugs.python.org/issue29995, re.escape() used to
  over-escape regular expression strings, but in Python 3.7 that's been
  fixed, which also improved the performance of re.escape(). Since it's
  both an output change for us *and* a perfomance win, let's just
  effectively backport the new behavior to hg on all Python versions.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/utils/stringutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py
--- a/mercurial/utils/stringutil.py
+++ b/mercurial/utils/stringutil.py
@@ -23,6 +23,25 @@
 pycompat,
 )
 
+# regex special chars pulled from https://bugs.python.org/issue29995
+# which was part of Python 3.7.
+_respecial = pycompat.bytestr(b'()[]{}?*+-|^$\\.# \t\n\r\v\f')
+_regexescapemap = {ord(i): (b'\\' + i).decode('latin1') for i in _respecial}
+
+def reescape(pat):
+"""Drop-in replacement for re.escape."""
+# NOTE: it is intentional that this works on unicodes and not
+# bytes, as it's only possible to do the escaping with
+# unicode.translate, not bytes.translate. Sigh.
+wantuni = True
+if isinstance(pat, bytes):
+wantuni = False
+pat = pat.decode('latin1')
+pat = pat.translate(_regexescapemap)
+if wantuni:
+return pat
+return pat.encode('latin1')
+
 def pprint(o, bprefix=False):
 """Pretty print an object."""
 if isinstance(o, bytes):



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


D3840: cleanup: migrate from re.escape to stringutil.reescape

2018-06-26 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This has consistent behavior on Python 2.7, 3.6, and 3.7 and has the
  benefit of probably being a little faster. Test output changes are
  largely because / used to be pointlessly escaped.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/keyword.py
  hgext/lfs/pointer.py
  mercurial/hgweb/webutil.py
  mercurial/match.py
  mercurial/sshpeer.py
  mercurial/sslutil.py
  tests/test-walk.t

CHANGE DETAILS

diff --git a/tests/test-walk.t b/tests/test-walk.t
--- a/tests/test-walk.t
+++ b/tests/test-walk.t
@@ -92,11 +92,11 @@
   f  mammals/skunk   skunk
   $ hg debugwalk -v -I '*k'
   * matcher:
-  
+  
   f  mammals/skunk  skunk
   $ hg debugwalk -v -I 'glob:*k'
   * matcher:
-  
+  
   f  mammals/skunk  skunk
   $ hg debugwalk -v -I 'relglob:*k'
   * matcher:
@@ -260,15 +260,15 @@
   f  mammals/skunk   skunk
   $ hg debugwalk -v Procyonidae
   * matcher:
-  
+  
   f  mammals/Procyonidae/cacomistle  Procyonidae/cacomistle
   f  mammals/Procyonidae/coatimundi  Procyonidae/coatimundi
   f  mammals/Procyonidae/raccoon Procyonidae/raccoon
 
   $ cd Procyonidae
   $ hg debugwalk -v .
   * matcher:
-  
+  
   f  mammals/Procyonidae/cacomistle  cacomistle
   f  mammals/Procyonidae/coatimundi  coatimundi
   f  mammals/Procyonidae/raccoon raccoon
@@ -316,7 +316,7 @@
   f  beans/turtlebeans/turtle
   $ hg debugwalk -v -I '{*,{b,m}*/*}k'
   * matcher:
-  
+  
   f  beans/blackbeans/black
   f  fenugreek  fenugreek
   f  mammals/skunk  mammals/skunk
@@ -330,25 +330,25 @@
   
   $ hg debugwalk -v -Inon-existent -Ibeans/black
   * matcher:
-  
+  
   f  beans/black  beans/black
   $ hg debugwalk -v -Ibeans beans/black
   * matcher:
   ,
+m1=,
 m2=>
   f  beans/black  beans/black  exact
   $ hg debugwalk -v -Ibeans/black beans
   * matcher:
   ,
-m2=>
+m2=>
   f  beans/black  beans/black
   $ hg debugwalk -v -Xbeans/black beans
   * matcher:
   ,
-m2=>
+m2=>
   f  beans/borlotti  beans/borlotti
   f  beans/kidneybeans/kidney
   f  beans/navy  beans/navy
@@ -358,42 +358,42 @@
   * matcher:
   ,
-m2=>
+m2=>
   f  beans/borlotti  beans/borlotti
   f  beans/kidneybeans/kidney
   f  beans/navy  beans/navy
   f  beans/pinto beans/pinto
   f  beans/turtlebeans/turtle
   $ hg debugwalk -v -Xbeans/black beans/black
   * matcher:
   ,
-m2=>
+m1=,
+m2=>
   $ hg debugwalk -v -Xbeans/black -Ibeans/black
   * matcher:
   ,
-m2=>
+m1=,
+m2=>
   $ hg debugwalk -v -Xbeans beans/black
   * matcher:
   ,
+m1=,
 m2=>
   $ hg debugwalk -v -Xbeans -Ibeans/black
   * matcher:
   ,
+m1=,
 m2=>
   $ hg debugwalk -v 'glob:mammals/../beans/b*'
   * matcher:
-  
+  
   f  beans/black beans/black
   f  beans/borlotti  beans/borlotti
   $ hg debugwalk -v '-X*/Procyonidae' mammals
   * matcher:
   ,
-m2=>
+m2=>
   f  mammals/skunk  mammals/skunk
   $ hg debugwalk -v path:mammals
   * matcher:
@@ -436,12 +436,12 @@
   $ hg debugwalk -v beans/black -X 'path:beans'
   * matcher:
   ,
+m1=,
 m2=>
   $ hg debugwalk -v -I 'path:beans/black' -X 'path:beans'
   * matcher:
   ,
+m1=,
 m2=>
 
 Test absolute paths:
@@ -485,11 +485,11 @@
   glob: $ENOENT$
   $ hg debugwalk -v glob:glob:glob
   * matcher:
-  
+  
   f  glob:glob  glob:glob  exact
   $ hg debugwalk -v path:glob:glob
   * matcher:
-  
+  
   f  glob:glob  glob:glob  exact
   $ rm glob:glob
   $ hg addremove
@@ -511,32 +511,32 @@
 
   $ hg debugwalk -v path:beans/black
   * matcher:
-  
+  
   f  beans/black  beans/black  exact
   $ hg debugwalk -v path:beans//black
   * matcher:
-  
+  
   f  beans/black  beans/black  exact
 
   $ hg debugwalk -v relglob:Procyonidae
   * matcher:
   
   $ hg debugwalk -v 'relglob:Procyonidae/**'
   * matcher:
-  
+  
   f  mammals/Procyonidae/cacomistle  mammals/Procyonidae/cacomistle
   f  mammals/Procyonidae/coatimundi  mammals/Procyonidae/coatimundi
   f  mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
   $ hg debugwalk -v 'relglob:Procyonidae/**' fennel
   * matcher:
-  
+  
   f  fennel  fennel  exact
   f  mammals/Procyonidae/cacomistle  mammals/Procyonidae/cacomistle
   f  mammals/Procyonidae/coatimundi  mammals/Procyonidae/coatimundi
   f  mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
   $ hg debugwalk -v beans 'glob:beans/*'
   * matcher:
-  
+  
   f  beans/black beans/black
   f  beans/borlotti  beans/borlotti
   f  beans/kidneybeans/kidney
@@ -598,7 +598,7 @@
   
   $ hg debugwalk -v ignored/file
   * matcher:
-  
+  
   f  ignored/file  ignored/file  exact
 
 Test listfile and listfile0
@@ -612,25 +612,25 @@
   $ $PYTHON -c "open('listfile', 
'wb').write(b'fenugreek\nnew\r\nmammals/skunk\n')"
   $ hg debugwalk -v -I

D3839: stringutil: add a new function to do minimal regex escaping

2018-06-26 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Per https://bugs.python.org/issue29995, re.escape() used to
  over-escape regular expression strings, but in Python 3.7 that's been
  fixed, which also improved the performance of re.escape(). Since it's
  both an output change for us *and* a perfomance win, let's just
  effectively backport the new behavior to hg on all Python versions.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/utils/stringutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py
--- a/mercurial/utils/stringutil.py
+++ b/mercurial/utils/stringutil.py
@@ -23,6 +23,25 @@
 pycompat,
 )
 
+# regex special chars pulled from https://bugs.python.org/issue29995
+# which was part of Python 3.7.
+_respecial = pycompat.bytestr(b'()[]{}?*+-|^$\\.# \t\n\r\v\f')
+_regexescapemap = {ord(i): (b'\\' + i).decode('latin1') for i in _respecial}
+
+def reescape(pat):
+"""Drop-in replacement for re.escape."""
+# NOTE: it is intentional that this works on unicodes and not
+# bytes, as it's only possible to do the escaping with
+# unicode.translate, not bytes.translate. Sigh.
+wantuni = True
+if isinstance(pat, bytes):
+wantuni = False
+pat = pat.decode('latin1')
+pat = pat.translate(_regexescapemap)
+if wantuni:
+return pat
+return pat.encode('latin1')
+
 def pprint(o, bprefix=False):
 """Pretty print an object."""
 if isinstance(o, bytes):



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


Re: [PATCH STABLE] hghave: don't claim we have `tic` if it's NetBSD's binary (issue5698)

2018-06-26 Thread Thomas Klausner
On Mon, Jun 25, 2018 at 09:28:04AM -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler 
> # Date 1529932907 14400
> #  Mon Jun 25 09:21:47 2018 -0400
> # Branch stable
> # Node ID 348d58daa074a5395eb483816c74c31190892d5f
> # Parent  1322ae04d3d71c9bab8ca6e70c77dfa867421c9b
> hghave: don't claim we have `tic` if it's NetBSD's binary (issue5698)
> 
> test-status-color.t fails with different output because of mismatches
> between how `tic` behaves from NetBSD's base system and ncurses'
> verison (if I understand the bug right). The bug suggested using -V to
> avoid the issue, so we'll do that.

I've tried applying the patch to 4.6.1, but the test still fails the
same way.

The 'tic -V' output on NetBSD goes to stderr (not stdout), could that
be the reason?

Btw, how do I run a single test manually?

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


[Bug 5931] New: resumed graft may lose file removal

2018-06-26 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5931

Bug ID: 5931
   Summary: resumed graft may lose file removal
   Product: Mercurial
   Version: default branch
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: y...@tcha.org
CC: mercurial-devel@mercurial-scm.org

File removal isn't recorded by "hg graft" + "hg resolve" +
"hg graft --continue" sequence, and dirstate gets wrong.

Original bug report:
https://bitbucket.org/tortoisehg/thg/issues/5124/

STR

  $ hg init a
  $ cd a
  $ touch file.txt
  $ hg add file.txt
  $ hg commit -m add
  $ hg rm file.txt
  $ hg commit -m remove
  $ hg update 0
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo edited > file.txt
  $ hg commit -m edit
  created new head

Uninterrupted graft works:

  $ echo d | hg --config ui.interactive=1 graft 1
  grafting 1:b906d4b3ba63 "remove"
  local [local] changed file.txt which other [graft] deleted
  use (c)hanged version, (d)elete, or leave (u)nresolved? d
  $ hg log -G -T '{rev} {file_dels}\n'
  @  3 file.txt
  |
  o  2
  |
  | o  1 file.txt
  |/
  o  0


Clean up the last grafted revision:

  $ hg --config extensions.strip= strip .
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  saved backup bundle to
$TESTTMP/a/.hg/strip-backup/11adda799c5d-a0425a0e-backup.hg

Try again with graft + resolve (NOT WORK):

  $ hg graft -t:fail 1
  grafting 1:b906d4b3ba63 "remove"
  abort: unresolved conflicts, can't continue
  (use 'hg resolve' and 'hg graft --continue')
  [255]
  $ echo d | hg --config ui.interactive=1 resolve -a
  local [local] changed file.txt which other [graft] deleted
  use (c)hanged version, (d)elete, or leave (u)nresolved? d
  (no more unresolved files)
  continue: hg graft --continue
  $ hg graft --continue
  grafting 1:b906d4b3ba63 "remove"
  note: graft of 1:b906d4b3ba63 created no changes to commit

The dirstate is clean:

  $ hg stat --all
  ? file.txt.orig
  $ hg debugdirstate

But actually, the file is missing:

  $ hg debugrebuilddirstate
  $ hg stat --all
  ! file.txt
  ? file.txt.orig

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


D3715: namespaces: allow namespaces whose symbols resolve to many nodes (API)

2018-06-26 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   I was also thinking we could do that, but it feels like a workaround to 
me. I think of bookmarks and tags as pointing to specific commits. I think of 
branches as being many commits. `hg help revisions` says this:
  >   
  > Any other string is treated as a bookmark, tag, or branch name. A 
bookmark
  > is a movable pointer to a revision. A tag is a permanent name associated
  > with a revision. A branch name denotes the tipmost open branch head of
  > that branch - or if they are all closed, the tipmost closed head of the
  > branch. Bookmark, tag, and branch names must not contain the ":"
  > character.
  >   
  >   It specifically mentions bookmarks, tags, and branches, and it describes 
how each name resolves to a commit. To me, that makes it sound like some 
symbols can resolve to multiple commits. And indeed, revset aliases can already 
resolve to multiple commits.
  
  I read it implying that any sort of symbol resolves to a single revision since
  all three core "names" work in such way. I'm not against adding multi-node
  symbol resolution because it seems useful, but I agree with Sean that it would
  introduce inconsistency.
  
  I have no idea about the `namemap()` API.

REPOSITORY
  rHG Mercurial

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

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


Re: D3715: namespaces: allow namespaces whose symbols resolve to many nodes (API)

2018-06-26 Thread Yuya Nishihara
>   I was also thinking we could do that, but it feels like a workaround to me. 
> I think of bookmarks and tags as pointing to specific commits. I think of 
> branches as being many commits. `hg help revisions` says this:
>   
> Any other string is treated as a bookmark, tag, or branch name. A bookmark
> is a movable pointer to a revision. A tag is a permanent name associated
> with a revision. A branch name denotes the tipmost open branch head of
> that branch - or if they are all closed, the tipmost closed head of the
> branch. Bookmark, tag, and branch names must not contain the ":"
> character.
>   
>   It specifically mentions bookmarks, tags, and branches, and it describes 
> how each name resolves to a commit. To me, that makes it sound like some 
> symbols can resolve to multiple commits. And indeed, revset aliases can 
> already resolve to multiple commits.

I read it implying that any sort of symbol resolves to a single revision since
all three core "names" work in such way. I'm not against adding multi-node
symbol resolution because it seems useful, but I agree with Sean that it would
introduce inconsistency.

I have no idea about the `namemap()` API.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3835: patchbomb: use email.mime.multipart instead of email.MIMEMultipart

2018-06-26 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG91228d9ae7c8: patchbomb: use email.mime.multipart instead 
of email.MIMEMultipart (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3835?vs=9295&id=9304

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

AFFECTED FILES
  hgext/patchbomb.py

CHANGE DETAILS

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -75,6 +75,7 @@
 
 import email as emailmod
 import email.generator as emailgen
+import email.mime.multipart as emimemultipart
 import email.utils as eutil
 import errno
 import os
@@ -254,7 +255,7 @@
 body += '\n'.join(patchlines)
 
 if addattachment:
-msg = emailmod.MIMEMultipart.MIMEMultipart()
+msg = emimemultipart.MIMEMultipart()
 if body:
 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test')))
 p = mail.mimetextpatch('\n'.join(patchlines), 'x-patch',
@@ -365,7 +366,7 @@
 or prompt(ui, 'Subject:', 'A bundle for your repository'))
 
 body = _getdescription(repo, '', sender, **opts)
-msg = emailmod.MIMEMultipart.MIMEMultipart()
+msg = emimemultipart.MIMEMultipart()
 if body:
 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get(r'test')))
 datapart = emailmod.MIMEBase.MIMEBase('application', 'x-mercurial-bundle')



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


D3834: py3: add b'' prefixes in tests/test-bundle2-pushback.t

2018-06-26 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4c358bdaada8: py3: add b'' prefixes in 
tests/test-bundle2-pushback.t (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3834?vs=9294&id=9303

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

AFFECTED FILES
  contrib/python3-whitelist
  tests/test-bundle2-pushback.t

CHANGE DETAILS

diff --git a/tests/test-bundle2-pushback.t b/tests/test-bundle2-pushback.t
--- a/tests/test-bundle2-pushback.t
+++ b/tests/test-bundle2-pushback.t
@@ -20,18 +20,18 @@
   > It issues an additional pushkey part to send a new
   > bookmark back to the client"""
   > result = bundle2.handlechangegroup(op, inpart)
-  > if 'pushback' in op.reply.capabilities:
-  > params = {'namespace': 'bookmarks',
-  >   'key': 'new-server-mark',
-  >   'old': '',
-  >   'new': 'tip'}
+  > if b'pushback' in op.reply.capabilities:
+  > params = {b'namespace': b'bookmarks',
+  >   b'key': b'new-server-mark',
+  >   b'old': b'',
+  >   b'new': b'tip'}
   > encodedparams = [(k, pushkey.encode(v)) for (k,v) in 
params.items()]
-  > op.reply.newpart('pushkey', mandatoryparams=encodedparams)
+  > op.reply.newpart(b'pushkey', mandatoryparams=encodedparams)
   > else:
-  > op.reply.newpart('output', data='pushback not enabled')
+  > op.reply.newpart(b'output', data=b'pushback not enabled')
   > return result
   > _newhandlechangegroup.params = bundle2.handlechangegroup.params
-  > bundle2.parthandlermapping['changegroup'] = _newhandlechangegroup
+  > bundle2.parthandlermapping[b'changegroup'] = _newhandlechangegroup
   > EOF
 
   $ cat >> $HGRCPATH 

D3833: py3: make tests/test-diff-antipatience.t work with python 3

2018-06-26 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9ef9884e5d50: py3: make tests/test-diff-antipatience.t work 
with python 3 (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3833?vs=9293&id=9302

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

AFFECTED FILES
  contrib/python3-whitelist
  tests/test-diff-antipatience.t

CHANGE DETAILS

diff --git a/tests/test-diff-antipatience.t b/tests/test-diff-antipatience.t
--- a/tests/test-diff-antipatience.t
+++ b/tests/test-diff-antipatience.t
@@ -11,9 +11,9 @@
 Test case that makes use of the weakness of patience diff algorithm
 
   $ hg init
-  >>> open('a', 'wb').write(b'\n'.join(list(b'a' + b'x' * 10 + b'u' + b'x' * 
30 + b'a\n')))
+  >>> open('a', 'wb').write(('\n'.join(list('a' + 'x' * 10 + 'u' + 'x' * 30 + 
'a\n'))).encode('ascii')) and None
   $ hg commit -m 1 -A a
-  >>> open('a', 'wb').write(b'\n'.join(list(b'b' + b'x' * 30 + b'u' + b'x' * 
10 + b'b\n')))
+  >>> open('a', 'wb').write(('\n'.join(list('b' + 'x' * 30 + 'u' + 'x' * 10 + 
'b\n'))).encode('ascii')) and None
 #if xdiff
   $ hg diff
   diff -r f0aeecb49805 a
diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -88,6 +88,7 @@
 test-debugindexdot.t
 test-debugrename.t
 test-default-push.t
+test-diff-antipatience.t
 test-diff-binary-file.t
 test-diff-change.t
 test-diff-copy-depth.t



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


D3836: patchbomb: use email.mime.base instead of email.MIMEBase

2018-06-26 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd17d1ee1d602: patchbomb: use email.mime.base instead of 
email.MIMEBase (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3836?vs=9296&id=9305

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

AFFECTED FILES
  hgext/patchbomb.py

CHANGE DETAILS

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -75,6 +75,7 @@
 
 import email as emailmod
 import email.generator as emailgen
+import email.mime.base as emimebase
 import email.mime.multipart as emimemultipart
 import email.utils as eutil
 import errno
@@ -369,7 +370,7 @@
 msg = emimemultipart.MIMEMultipart()
 if body:
 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get(r'test')))
-datapart = emailmod.MIMEBase.MIMEBase('application', 'x-mercurial-bundle')
+datapart = emimebase.MIMEBase('application', 'x-mercurial-bundle')
 datapart.set_payload(bundle)
 bundlename = '%s.hg' % opts.get(r'bundlename', 'bundle')
 datapart.add_header('Content-Disposition', 'attachment',



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


Re: [PATCH 3 of 7] dispatch: rework the serve --stdio safe argument checks

2018-06-26 Thread Yuya Nishihara
On Mon, 25 Jun 2018 19:51:52 +0200, Paul Morelle wrote:
> On 22/06/18 13:15, Yuya Nishihara wrote:
> > On Thu, 21 Jun 2018 19:46:24 +0200, Paul Morelle wrote:
> >> On 21/06/18 13:53, Yuya Nishihara wrote:
> >>> On Wed, 20 Jun 2018 18:36:24 +0200, Paul Morelle wrote:
> > # HG changeset patch
>  # User Boris Feld 
>  # Date 1529489906 -7200
>  #  Wed Jun 20 12:18:26 2018 +0200
>  # Node ID 81edf3431b95d57257c690f7fe125c6676a78e18
>  # Parent  b7051e4bf783c844f705473a2396458acecc59dc
>  # EXP-Topic remote-debug
>  # Available At https://bitbucket.org/octobus/mercurial-devel/
>  #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
>  81edf3431b95
>  dispatch: rework the serve --stdio safe argument checks
> 
>  We prepare the code to check for arguments after the mandatory ones.
> 
>  We want to relax this check to allow for wider argument passing in 
>  certain
>  conditions (example --debug). We make preliminary refactoring in 
>  different
>  changesets for clarity.
> 
>  diff -r b7051e4bf783 -r 81edf3431b95 mercurial/dispatch.py
>  --- a/mercurial/dispatch.py  Wed Jun 20 12:16:48 2018 +0200
>  +++ b/mercurial/dispatch.py  Wed Jun 20 12:18:26 2018 +0200
>  @@ -285,12 +285,15 @@
>   def unsafe():
>   msg = _('potentially unsafe serve --stdio invocation: 
>  %s')
>   raise error.Abort(msg % (stringutil.pprint(req.args),))
>  -if (len(req.args) != 4 or
>  +if (len(req.args) < 4 or
>   req.args[0] != '-R' or
>   req.args[1].startswith('--') or
>   req.args[2] != 'serve' or
>   req.args[3] != '--stdio'):
>   unsafe()
>  +other_args = req.args[4:]
>  +if other_args:
>  +unsafe()
> >>> It's a bit scary to extend this just for debugging aids because argument
> >>> parsing at this phase has to be ad-hoc. Can't you instead use the
> >>> ssh/authorized_keys file to redirect a server session to 'hg debugserve'?
> >>>
> >>> Alternatively, we could add a wrapper script like hg-ssh.
> >> If I have correctly understood, your proposition is to keep the
> >> client-side version of this, and move the permission management to the
> >> sshkey/ssh-server level. Is this right?
> > Yes.
> >
> >> Something we could do in this area is to replace the call to sshpeer by
> >> `hg debugserve …` when we need the remote-debugging feature.
> >> However, exposing a "debug" command at the wireprotocol level seems bad
> >> ; maybe we could introduce a `--remote-argument` flag that would lift
> >> the check with a permission handling similar to what we have today (in
> >> patch 4).
> >>
> >> However, having all checks disabled (debugserve) is quite different than
> >> what is proposed in this series, which only allows for more information
> >> to be retrieved, and that's it.
> >> Fully bypassing the argument check would allow the client do a full
> >> range of actions (including arbitrary code execution). This is a much
> >> different access level, and in my current use case it would be a problem.
> > Instead of using debugserve, the wrapper script can set ui.debug/traceback
> > flag just like contrib/hg-ssh does for hooks.
> Doing this at the authorized_keys level is not an option for us. In one
> of our target environment for this kind of debugging, any change to the
> ssh script requires validation by admin people that can take from a
> couple of days to a couple of weeks, making it impossible to turn
> debugging on for a couple of commands, or easily compare various settings.

IMHO, that doesn't justify why we have to put everything in hg core.
"hg serve" itself is an SSH script in security POV.

> The ability to control the used debug options from the client is very
> valuable in this case. We have already gathered many useful information
> from it!
> 
> I agree that ad-hoc argument parsing is less than optimal. Handling
> three extra flags (--debug, --profile and --traceback) is not too awful,
> but then we need to pass some associated configuration option (e.g.
> profiling.time-track=real) which will make things even more verbose.
> 
> Maybe we could leverage the contents of `mercurial/configitems.py` by
> adding a "serversafe" attribute to the configuration items? Such config
> item could be specified on the client side (if the user is allowed to).

No, that sounds worse than the original patch. IIUC, the reason why we have
hard-coded check for req.args is that our option parser isn't strict and is
likely to allow command-line injection. Making the whitelist fully configurable
would be dangerous.

> >> I don't think that moving the permission handling outside of Mercurial
> >> would be a good move : implementing similar features for HTTP would
> >> still require some Mer

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

2018-06-26 Thread khanchi97 (Sushil khanchi)
khanchi97 updated this revision to Diff 9301.
khanchi97 edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2409?vs=8961&id=9301

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-completion.t
  tests/test-graft.t

CHANGE DETAILS

diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1885,3 +1885,245 @@
   new changesets detected on destination branch, can't strip
   graft aborted
   working directory is now at 6b98ff0062dd
+
+
+Testing --no-commit option:|
+
+
+  $ cd ..
+  $ hg init nocommit
+  $ cd nocommit
+  $ echo a > a
+  $ hg ci -qAma
+  $ echo b > b
+  $ hg ci -qAmb
+  $ hg up -q 0
+  $ echo c > c
+  $ hg ci -qAmc
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  2:d36c0562f908 c
+  |
+  | o  1:d2ae7f538514 b
+  |/
+  o  0:cb9a9f314b8b a
+  
+
+Check reporting when --no-commit used with non-applicable options:
+
+  $ hg graft 1 --no-commit -e
+  abort: cannot specify --no-commit and --edit together
+  [255]
+
+  $ hg graft 1 --no-commit --log
+  abort: cannot specify --no-commit and --log together
+  [255]
+
+  $ hg graft 1 --no-commit -D
+  abort: cannot specify --no-commit and --currentdate together
+  [255]
+
+Test --no-commit is working:
+  $ hg graft 1 --no-commit
+  grafting 1:d2ae7f538514 "b"
+
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  2:d36c0562f908 c
+  |
+  | o  1:d2ae7f538514 b
+  |/
+  o  0:cb9a9f314b8b a
+  
+
+  $ hg diff
+  diff -r d36c0562f908 b
+  --- /dev/nullThu Jan 01 00:00:00 1970 +
+  +++ b/b  Thu Jan 01 00:00:00 1970 +
+  @@ -0,0 +1,1 @@
+  +b
+
+Prepare wrdir to check --no-commit is resepected after --continue:
+
+  $ hg up -qC
+  $ echo A>a
+  $ hg ci -qm "A in file a"
+  $ hg up -q 1
+  $ echo B>a
+  $ hg ci -qm "B in file a"
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  4:2aa9ad1006ff B in file a
+  |
+  | o  3:09e253b87e17 A in file a
+  | |
+  | o  2:d36c0562f908 c
+  | |
+  o |  1:d2ae7f538514 b
+  |/
+  o  0:cb9a9f314b8b a
+  
+
+  $ hg graft 3 --no-commit
+  grafting 3:09e253b87e17 "A in file a"
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  abort: unresolved conflicts, can't continue
+  (use 'hg resolve' and 'hg graft --continue')
+  [255]
+
+Resolve conflict:
+  $ echo A>a
+  $ hg resolve --mark
+  (no more unresolved files)
+  continue: hg graft --continue
+
+  $ hg graft --continue
+  grafting 3:09e253b87e17 "A in file a"
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  4:2aa9ad1006ff B in file a
+  |
+  | o  3:09e253b87e17 A in file a
+  | |
+  | o  2:d36c0562f908 c
+  | |
+  o |  1:d2ae7f538514 b
+  |/
+  o  0:cb9a9f314b8b a
+  
+  $ hg diff
+  diff -r 2aa9ad1006ff a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,1 +1,1 @@
+  -B
+  +A
+
+  $ hg up -qC
+
+Check --no-commit is resepected when passed with --continue:
+
+  $ hg graft 3
+  grafting 3:09e253b87e17 "A in file a"
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  abort: unresolved conflicts, can't continue
+  (use 'hg resolve' and 'hg graft --continue')
+  [255]
+
+Resolve conflict:
+  $ echo A>a
+  $ hg resolve --mark
+  (no more unresolved files)
+  continue: hg graft --continue
+
+  $ hg graft --continue --no-commit
+  grafting 3:09e253b87e17 "A in file a"
+  $ hg diff
+  diff -r 2aa9ad1006ff a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,1 +1,1 @@
+  -B
+  +A
+
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  4:2aa9ad1006ff B in file a
+  |
+  | o  3:09e253b87e17 A in file a
+  | |
+  | o  2:d36c0562f908 c
+  | |
+  o |  1:d2ae7f538514 b
+  |/
+  o  0:cb9a9f314b8b a
+  
+  $ hg up -qC
+
+Test --no-commit when graft multiple revisions:
+When there is conflict:
+  $ hg graft -r "2::3" --no-commit
+  grafting 2:d36c0562f908 "c"
+  grafting 3:09e253b87e17 "A in file a"
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  abort: unresolved conflicts, can't continue
+  (use 'hg resolve' and 'hg graft --continue')
+  [255]
+
+  $ echo A>a
+  $ hg resolve --mark
+  (no more unresolved files)
+  continue: hg graft --continue
+  $ hg graft --continue
+  grafting 3:09e253b87e17 "A in file a"
+  $ hg diff
+  diff -r 2aa9ad1006ff a
+  --- a/a  Thu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:00 1970 +
+  @@ -1,1 +1,1 @@
+  -B
+  +A
+  diff -r 2aa9ad1006ff c
+  --- /dev/nullThu Jan 01 00:00:00 1970 +
+  +++ b/c  Thu Jan 01 00:00:00 1970 +
+  @@ -0,0 +1,1 @@
+  +c
+
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  4:2aa9ad1006ff B in file a
+  |
+  | o  3:09e253b87e17 A in file a
+  | |
+  | o  2:d36c0562f908 c
+  | |
+  o |  1:d2ae7f538514 b
+  |/
+  o

D3838: terse: pass "clean" and "unknown" booleans by name for clarity

2018-06-26 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG854c2ccc800e: terse: pass "clean" and 
"unknown" booleans by name for clarity (authored by martinvonz, 
committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3838?vs=9298&id=9300

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5067,7 +5067,8 @@
 # we need to compute clean and unknown to terse
 stat = repo.status(ctx1.node(), ctx2.node(), m,
'ignored' in show or 'i' in terse,
-True, True, opts.get('subrepos'))
+clean=True, unknown=True,
+listsubrepos=opts.get('subrepos'))
 
 stat = cmdutil.tersedir(stat, terse)
 else:



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


D3837: terse: add tests of running from subdirectory

2018-06-26 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG09b09fe7ee90: terse: add tests of running from subdirectory 
(authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3837?vs=9297&id=9299

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

AFFECTED FILES
  tests/test-status-terse.t

CHANGE DETAILS

diff --git a/tests/test-status-terse.t b/tests/test-status-terse.t
--- a/tests/test-status-terse.t
+++ b/tests/test-status-terse.t
@@ -67,6 +67,48 @@
   ? x/
   ? y/
 
+Run from subdirectory
+  $ hg status --terse u --cwd x/l
+  ? .hgignore
+  ? a
+  ? b
+  ? x/
+  ? y/
+  $ relstatus() {
+  >   hg status --terse u --config commands.status.relative=1 "$@";
+  > }
+This should probably have {"l/", "m/", "n/"} instead of {"."}. They should
+probably come after "../y/".
+  $ relstatus --cwd x
+  ? ../.hgignore
+  ? ../a
+  ? ../b
+  ? .
+  ? ../y/
+This should probably have {"u/", "../m/", "../n/"} instead of {"../"}.
+  $ relstatus --cwd x/l
+  ? ../../.hgignore
+  ? ../../a
+  ? ../../b
+  ? ../
+  ? ../../y/
+This should probably have {"a/", "bb", "../aa", "../../m/", "../../n/"}
+instead of {"../../"}.
+  $ relstatus --cwd x/l/u
+  ? ../../../.hgignore
+  ? ../../../a
+  ? ../../../b
+  ? ../../
+  ? ../../../y/
+This should probably have {"bb", "../bb", "../../aa", "../../../m/",
+"../../../n/"} instead of {"../../../"}.
+  $ relstatus --cwd x/l/u/a
+  ? ../../../../.hgignore
+  ? ../../../../a
+  ? ../../../../b
+  ? ../../../
+  ? ../../../../y/
+
   $ hg add x/aa x/bb .hgignore
   $ hg status --terse au
   A .hgignore



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


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

2018-06-26 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  The patch mostly looks good to me. Added some minor nits. It will be great if 
you can add test where we graft multiple revs with --no-commit flag.

INLINE COMMENTS

> test-graft.t:1551
> +  $ hg ci -qAm2
> +  $ hg log
> +  changeset:   2:db815d6d32e6

We should print a graphical version of log so that test can be understand 
better. Maybe replace this with `hg log -GT "{rev}:{node|short} {desc}\n"`. 
Comment applies to other instances of `hg log` in test too.

> test-graft.t:1677
> +  grafting 4:a08bb3910e7c "4"
> +  $ hg tip -T "rev: {rev}\n"
> +  rev: 5

`hg log` will serve the purpose better here.

REPOSITORY
  rHG Mercurial

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

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