D492: context: remove unnecessary default values for matchers (API)

2017-08-23 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D492#7991, @dsp wrote:
  
  > if match can't be None, then we should remove it as the default value. 
Otherwise I look at this in a year and think "why do we not handle a None 
matcher, when it clearly can be None if the value for match is not set".
  
  
  Definitely. Good catch.

REPOSITORY
  rHG Mercurial

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

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


D492: context: remove unnecessary default values for matchers (API)

2017-08-23 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 1243.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D492?vs=1207=1243

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1743,11 +1743,9 @@
 # Even if the wlock couldn't be grabbed, clear out the list.
 self._repo.clearpostdsstatus()
 
-def _dirstatestatus(self, match=None, ignored=False, clean=False,
-unknown=False):
+def _dirstatestatus(self, match, ignored=False, clean=False, 
unknown=False):
 '''Gets the status from the dirstate -- internal use only.'''
 listignored, listclean, listunknown = ignored, clean, unknown
-match = match or matchmod.always(self._repo.root, self._repo.getcwd())
 subrepos = []
 if '.hgsub' in self:
 subrepos = sorted(self.substate)
@@ -1973,14 +1971,12 @@
 super(workingctx, self).__init__(repo, text, user, date, extra,
  changes)
 
-def _dirstatestatus(self, match=None, ignored=False, clean=False,
-unknown=False):
+def _dirstatestatus(self, match, ignored=False, clean=False, 
unknown=False):
 """Return matched files only in ``self._status``
 
 Uncommitted files appear "clean" via this context, even if
 they aren't actually so in the working directory.
 """
-match = match or matchmod.always(self._repo.root, self._repo.getcwd())
 if clean:
 clean = [f for f in self._manifest if f not in self._changedset]
 else:



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


D494: test-casecollision-merge: fix the test

2017-08-23 Thread dsp (David Soria Parra)
dsp accepted this revision.
dsp added a comment.


  Thanks

REPOSITORY
  rHG Mercurial

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

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


D492: context: remove unnecessary default values for matchers (API)

2017-08-23 Thread dsp (David Soria Parra)
dsp requested changes to this revision.
dsp added a comment.
This revision now requires changes to proceed.


  if match can't be None, then we should remove it as the default value. 
Otherwise I look at this in a year and think "why do we not handle a None 
matcher, when it clearly can be None if the value for match is not set".

REPOSITORY
  rHG Mercurial

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

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


D491: context: always pass a matcher into _matchstatus() (API)

2017-08-23 Thread dsp (David Soria Parra)
dsp accepted this revision.
dsp added a comment.


  I guess either works. I personally prefer the inheritance here as it feels 
easier to get it right from an unsuspected caller, but i can see benefits on 
both sides.

REPOSITORY
  rHG Mercurial

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

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


D441: revset: optimize "draft() & ::x" pattern

2017-08-23 Thread quark (Jun Wu)
quark planned changes to this revision.
quark added a comment.


  Let's wait for my revset order and Yuya's matchtree patches first.

REPOSITORY
  rHG Mercurial

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

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


D422: mdiff: add a --ignore-space-at-eol option

2017-08-23 Thread dsp (David Soria Parra)
dsp updated this revision to Diff 1241.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D422?vs=1240=1241

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/help/config.txt
  mercurial/mdiff.py
  mercurial/patch.py
  tests/test-completion.t
  tests/test-diff-ignore-whitespace.t
  tests/test-help.t
  tests/test-qrecord.t
  tests/test-record.t

CHANGE DETAILS

diff --git a/tests/test-record.t b/tests/test-record.t
--- a/tests/test-record.t
+++ b/tests/test-record.t
@@ -62,6 +62,7 @@
-w --ignore-all-spaceignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines  ignore changes whose lines are all blank
+   -E --ignore-space-at-eol ignore changes in whitespace at EOL
   
   (some details hidden, use --verbose to show complete help)
 
diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
--- a/tests/test-qrecord.t
+++ b/tests/test-qrecord.t
@@ -79,6 +79,7 @@
-w --ignore-all-spaceignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines  ignore changes whose lines are all blank
+   -E --ignore-space-at-eol ignore changes in whitespace at EOL
   
   (some details hidden, use --verbose to show complete help)
 
@@ -152,6 +153,7 @@
-w --ignore-all-spaceignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines  ignore changes whose lines are all blank
+   -E --ignore-space-at-eol ignore changes in whitespace at EOL
   --mq  operate on patch repository
   
   (some details hidden, use --verbose to show complete help)
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -553,6 +553,7 @@
-w --ignore-all-spaceignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines  ignore changes whose lines are all blank
+   -E --ignore-space-at-eol ignore changes in whitespace at EOL
-U --unified NUM number of lines of context to show
   --statoutput diffstat-style summary of changes
   --root DIRproduce diffs relative to subdirectory
diff --git a/tests/test-diff-ignore-whitespace.t 
b/tests/test-diff-ignore-whitespace.t
--- a/tests/test-diff-ignore-whitespace.t
+++ b/tests/test-diff-ignore-whitespace.t
@@ -407,8 +407,16 @@
   +goodbye\r (no-eol) (esc)
   world
 
+Test \r (carriage return) as used in "DOS" line endings:
+
+  $ printf 'hello world\r\ngoodbye world\n' >foo
+
+  $ hg ndiff --ignore-space-at-eol
+
 No completely blank lines to ignore:
 
+  $ printf 'hello world\r\n\r\ngoodbye\rworld\n' >foo
+
   $ hg ndiff --ignore-blank-lines
   diff -r 540c40a65b78 foo
   --- a/foo
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -218,10 +218,10 @@
 Show all commands + options
   $ hg debugcommands
   add: include, exclude, subrepos, dry-run
-  annotate: rev, follow, no-follow, text, user, file, date, number, changeset, 
line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, 
include, exclude, template
+  annotate: rev, follow, no-follow, text, user, file, date, number, changeset, 
line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, include, exclude, template
   clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, 
insecure
   commit: addremove, close-branch, amend, secret, edit, interactive, include, 
exclude, message, logfile, date, user, subrepos
-  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, 
stat, root, include, exclude, subrepos
+  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
   export: output, switch-parent, rev, text, git, binary, nodates
   forget: include, exclude
   init: ssh, remotecmd, insecure
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2282,6 +2282,7 @@
   'ignorewsamount')
 buildopts['ignoreblanklines'] = get('ignore_blank_lines',
 'ignoreblanklines')
+buildopts['ignorewseol'] = get('ignore_space_at_eol', 'ignorewseol')
 if formatchanging:
 buildopts['text'] = opts and opts.get('text')
 binary = None if opts is None else opts.get('binary')
diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ 

D422: mdiff: add a --ignore-space-at-eol option

2017-08-23 Thread dsp (David Soria Parra)
dsp updated this revision to Diff 1240.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D422?vs=1022=1240

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/help/config.txt
  mercurial/mdiff.py
  mercurial/patch.py
  tests/test-completion.t
  tests/test-diff-ignore-whitespace.t
  tests/test-help.t
  tests/test-qrecord.t
  tests/test-record.t

CHANGE DETAILS

diff --git a/tests/test-record.t b/tests/test-record.t
--- a/tests/test-record.t
+++ b/tests/test-record.t
@@ -62,6 +62,7 @@
-w --ignore-all-spaceignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines  ignore changes whose lines are all blank
+   -e --ignore-space-at-eol ignore changes in whitespace at EOL
   
   (some details hidden, use --verbose to show complete help)
 
diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
--- a/tests/test-qrecord.t
+++ b/tests/test-qrecord.t
@@ -79,6 +79,7 @@
-w --ignore-all-spaceignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines  ignore changes whose lines are all blank
+   -e --ignore-space-at-eol ignore changes in whitespace at EOL
   
   (some details hidden, use --verbose to show complete help)
 
@@ -152,6 +153,7 @@
-w --ignore-all-spaceignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines  ignore changes whose lines are all blank
+   -e --ignore-space-at-eol ignore changes in whitespace at EOL
   --mq  operate on patch repository
   
   (some details hidden, use --verbose to show complete help)
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -553,6 +553,7 @@
-w --ignore-all-spaceignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines  ignore changes whose lines are all blank
+   -e --ignore-space-at-eol ignore changes in whitespace at EOL
-U --unified NUM number of lines of context to show
   --statoutput diffstat-style summary of changes
   --root DIRproduce diffs relative to subdirectory
diff --git a/tests/test-diff-ignore-whitespace.t 
b/tests/test-diff-ignore-whitespace.t
--- a/tests/test-diff-ignore-whitespace.t
+++ b/tests/test-diff-ignore-whitespace.t
@@ -407,8 +407,16 @@
   +goodbye\r (no-eol) (esc)
   world
 
+Test \r (carriage return) as used in "DOS" line endings:
+
+  $ printf 'hello world\r\ngoodbye world\n' >foo
+
+  $ hg ndiff --ignore-space-at-eol
+
 No completely blank lines to ignore:
 
+  $ printf 'hello world\r\n\r\ngoodbye\rworld\n' >foo
+
   $ hg ndiff --ignore-blank-lines
   diff -r 540c40a65b78 foo
   --- a/foo
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -218,10 +218,10 @@
 Show all commands + options
   $ hg debugcommands
   add: include, exclude, subrepos, dry-run
-  annotate: rev, follow, no-follow, text, user, file, date, number, changeset, 
line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, 
include, exclude, template
+  annotate: rev, follow, no-follow, text, user, file, date, number, changeset, 
line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, include, exclude, template
   clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, 
insecure
   commit: addremove, close-branch, amend, secret, edit, interactive, include, 
exclude, message, logfile, date, user, subrepos
-  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, 
stat, root, include, exclude, subrepos
+  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
   export: output, switch-parent, rev, text, git, binary, nodates
   forget: include, exclude
   init: ssh, remotecmd, insecure
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2282,6 +2282,7 @@
   'ignorewsamount')
 buildopts['ignoreblanklines'] = get('ignore_blank_lines',
 'ignoreblanklines')
+buildopts['ignorewseol'] = get('ignore_space_at_eol', 'ignorewseol')
 if formatchanging:
 buildopts['text'] = opts and opts.get('text')
 binary = None if opts is None else opts.get('binary')
diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ 

D368: releasenotes: add check flag for use of admonitions and its validity

2017-08-23 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  @rishabhmadan96 Sorry for jumping late, can you followup with a patch adding 
some docs for the flag. Also document the behavior of `hg releasenotes -c` and 
it will be great if you can add a test for that too.

REPOSITORY
  rHG Mercurial

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

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


D450: filemerge: add wctx to all internal tools

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1238.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D450?vs=1237=1238

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

AFFECTED FILES
  mercurial/filemerge.py
  mercurial/tagmerge.py

CHANGE DETAILS

diff --git a/mercurial/tagmerge.py b/mercurial/tagmerge.py
--- a/mercurial/tagmerge.py
+++ b/mercurial/tagmerge.py
@@ -216,7 +216,7 @@
 # whole list of lr nodes
 return lrnodes + hrnodes[commonidx:]
 
-def merge(repo, fcd, fco, fca):
+def merge(repo, wctx, fcd, fco, fca):
 '''
 Merge the tags of two revisions, taking into account the base tags
 Try to minimize the diff between the merged tags and the first parent tags
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -238,7 +238,7 @@
 util.writefile(file, newdata)
 
 @internaltool('prompt', nomerge)
-def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iprompt(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Asks the user which of the local `p1()` or the other `p2()` version to
 keep as the merged version."""
 ui = repo.ui
@@ -263,26 +263,26 @@
 choice = ['local', 'other', 'unresolved'][index]
 
 if choice == 'other':
-return _iother(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
labels)
 elif choice == 'local':
-return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ilocal(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
labels)
 elif choice == 'unresolved':
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   labels)
 except error.ResponseExpected:
 ui.write("\n")
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   labels)
 
 @internaltool('local', nomerge)
-def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ilocal(repo, wtcx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the local `p1()` version of files as the merged version."""
 return 0, fcd.isabsent()
 
 @internaltool('other', nomerge)
-def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the other `p2()` version of files as the merged version."""
 if fco.isabsent():
 # local changed, remote deleted -- 'deleted' picked
@@ -294,7 +294,7 @@
 return 0, deleted
 
 @internaltool('fail', nomerge)
-def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """
 Rather than attempting to merge files that were modified on both
 branches, it marks them as unresolved. The resolve command must be
@@ -362,7 +362,8 @@
 return False
 return True
 
-def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
+def _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files, labels,
+   mode):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
@@ -380,32 +381,35 @@
   _("warning: conflicts while merging %s! "
 "(edit, then use 'hg resolve --mark')\n"),
   precheck=_mergecheck)
-def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _iunion(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will use both left and right sides for conflict regions.
 No markers are inserted."""
-return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   files, labels, 'union')
 
 @internaltool('merge', fullmerge,
   _("warning: conflicts while merging %s! "
 "(edit, then use 'hg resolve --mark')\n"),
   precheck=_mergecheck)
-def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _imerge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
 the partially merged file. Markers will have two sections, one for each 
side
 of merge."""
-return _merge(repo, mynode, 

D449: merge: pass wctx to premerge, filemerge

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1236.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D449?vs=1235=1236

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/filemerge.py
  mercurial/merge.py
  tests/failfilemerge.py

CHANGE DETAILS

diff --git a/tests/failfilemerge.py b/tests/failfilemerge.py
--- a/tests/failfilemerge.py
+++ b/tests/failfilemerge.py
@@ -9,7 +9,8 @@
 )
 
 def failfilemerge(filemergefn,
-  premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
+  premerge, repo, wctx, mynode, orig, fcd, fco, fca,
+  labels=None):
 raise error.Abort("^C")
 return filemergefn(premerge, repo, mynode, orig, fcd, fco, fca, labels)
 
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -495,12 +495,14 @@
 f.close()
 else:
 wctx[dfile].remove(ignoremissing=True)
-complete, r, deleted = filemerge.premerge(self._repo, self._local,
-  lfile, fcd, fco, fca,
+complete, r, deleted = filemerge.premerge(self._repo, wctx,
+  self._local, lfile, fcd,
+  fco, fca,
   labels=self._labels)
 else:
-complete, r, deleted = filemerge.filemerge(self._repo, self._local,
-   lfile, fcd, fco, fca,
+complete, r, deleted = filemerge.filemerge(self._repo, wctx,
+   self._local, lfile, fcd,
+   fco, fca,
labels=self._labels)
 if r is None:
 # no real conflict
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -586,7 +586,7 @@
 "o": " [%s]" % labels[1],
 }
 
-def _filemerge(premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
+def _filemerge(premerge, repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
 """perform a 3-way merge in the working directory
 
 premerge = whether this is a premerge
@@ -728,11 +728,13 @@
 
 return r
 
-def premerge(repo, mynode, orig, fcd, fco, fca, labels=None):
-return _filemerge(True, repo, mynode, orig, fcd, fco, fca, labels=labels)
+def premerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
+return _filemerge(True, repo, wctx, mynode, orig, fcd, fco, fca,
+  labels=labels)
 
-def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None):
-return _filemerge(False, repo, mynode, orig, fcd, fco, fca, labels=labels)
+def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
+return _filemerge(False, repo, wctx, mynode, orig, fcd, fco, fca,
+  labels=labels)
 
 def loadinternalmerge(ui, extname, registrarobj):
 """Load internal merge tool from specified registrarobj
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -545,10 +545,10 @@
 
 # Override filemerge to prompt the user about how they wish to merge
 # largefiles. This will handle identical edits without prompting the user.
-def overridefilemerge(origfn, premerge, repo, mynode, orig, fcd, fco, fca,
+def overridefilemerge(origfn, premerge, repo, wctx, mynode, orig, fcd, fco, 
fca,
   labels=None):
 if not lfutil.isstandin(orig) or fcd.isabsent() or fco.isabsent():
-return origfn(premerge, repo, mynode, orig, fcd, fco, fca,
+return origfn(premerge, repo, wctx, mynode, orig, fcd, fco, fca,
   labels=labels)
 
 ahash = lfutil.readasstandin(fca).lower()



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


D450: filemerge: add wctx to all internal tools

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1237.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D450?vs=1234=1237

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

AFFECTED FILES
  mercurial/filemerge.py
  mercurial/tagmerge.py

CHANGE DETAILS

diff --git a/mercurial/tagmerge.py b/mercurial/tagmerge.py
--- a/mercurial/tagmerge.py
+++ b/mercurial/tagmerge.py
@@ -216,7 +216,7 @@
 # whole list of lr nodes
 return lrnodes + hrnodes[commonidx:]
 
-def merge(repo, fcd, fco, fca):
+def merge(repo, wctx, fcd, fco, fca):
 '''
 Merge the tags of two revisions, taking into account the base tags
 Try to minimize the diff between the merged tags and the first parent tags
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -238,7 +238,7 @@
 util.writefile(file, newdata)
 
 @internaltool('prompt', nomerge)
-def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iprompt(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Asks the user which of the local `p1()` or the other `p2()` version to
 keep as the merged version."""
 ui = repo.ui
@@ -263,26 +263,26 @@
 choice = ['local', 'other', 'unresolved'][index]
 
 if choice == 'other':
-return _iother(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
labels)
 elif choice == 'local':
-return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ilocal(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
labels)
 elif choice == 'unresolved':
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   labels)
 except error.ResponseExpected:
 ui.write("\n")
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   labels)
 
 @internaltool('local', nomerge)
-def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ilocal(repo, wtcx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the local `p1()` version of files as the merged version."""
 return 0, fcd.isabsent()
 
 @internaltool('other', nomerge)
-def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the other `p2()` version of files as the merged version."""
 if fco.isabsent():
 # local changed, remote deleted -- 'deleted' picked
@@ -294,7 +294,7 @@
 return 0, deleted
 
 @internaltool('fail', nomerge)
-def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """
 Rather than attempting to merge files that were modified on both
 branches, it marks them as unresolved. The resolve command must be
@@ -362,7 +362,8 @@
 return False
 return True
 
-def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
+def _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files, labels,
+   mode):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
@@ -380,32 +381,35 @@
   _("warning: conflicts while merging %s! "
 "(edit, then use 'hg resolve --mark')\n"),
   precheck=_mergecheck)
-def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _iunion(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will use both left and right sides for conflict regions.
 No markers are inserted."""
-return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   files, labels, 'union')
 
 @internaltool('merge', fullmerge,
   _("warning: conflicts while merging %s! "
 "(edit, then use 'hg resolve --mark')\n"),
   precheck=_mergecheck)
-def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _imerge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
 the partially merged file. Markers will have two sections, one for each 
side
 of merge."""
-return _merge(repo, mynode, 

D449: merge: pass wctx to premerge, filemerge

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1235.
phillco edited the summary of this revision.
phillco retitled this revision from "merge: pass `wctx` object to `premerge()` 
and `filemerge`" to "merge: pass wctx to premerge, filemerge".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D449?vs=1083=1235

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/filemerge.py
  mercurial/merge.py
  tests/failfilemerge.py

CHANGE DETAILS

diff --git a/tests/failfilemerge.py b/tests/failfilemerge.py
--- a/tests/failfilemerge.py
+++ b/tests/failfilemerge.py
@@ -9,7 +9,8 @@
 )
 
 def failfilemerge(filemergefn,
-  premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
+  premerge, repo, wctx, mynode, orig, fcd, fco, fca,
+  labels=None):
 raise error.Abort("^C")
 return filemergefn(premerge, repo, mynode, orig, fcd, fco, fca, labels)
 
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -495,12 +495,14 @@
 f.close()
 else:
 wctx[dfile].remove(ignoremissing=True)
-complete, r, deleted = filemerge.premerge(self._repo, self._local,
-  lfile, fcd, fco, fca,
+complete, r, deleted = filemerge.premerge(self._repo, wctx,
+  self._local, lfile, fcd,
+  fco, fca,
   labels=self._labels)
 else:
-complete, r, deleted = filemerge.filemerge(self._repo, self._local,
-   lfile, fcd, fco, fca,
+complete, r, deleted = filemerge.filemerge(self._repo, wctx,
+   self._local, lfile, fcd,
+   fco, fca,
labels=self._labels)
 if r is None:
 # no real conflict
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -586,7 +586,7 @@
 "o": " [%s]" % labels[1],
 }
 
-def _filemerge(premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
+def _filemerge(premerge, repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
 """perform a 3-way merge in the working directory
 
 premerge = whether this is a premerge
@@ -728,11 +728,12 @@
 
 return r
 
-def premerge(repo, mynode, orig, fcd, fco, fca, labels=None):
+def premerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
 return _filemerge(True, repo, mynode, orig, fcd, fco, fca, labels=labels)
 
-def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None):
-return _filemerge(False, repo, mynode, orig, fcd, fco, fca, labels=labels)
+def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
+return _filemerge(False, repo, wctx, mynode, orig, fcd, fco, fca,
+  labels=labels)
 
 def loadinternalmerge(ui, extname, registrarobj):
 """Load internal merge tool from specified registrarobj
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -545,10 +545,10 @@
 
 # Override filemerge to prompt the user about how they wish to merge
 # largefiles. This will handle identical edits without prompting the user.
-def overridefilemerge(origfn, premerge, repo, mynode, orig, fcd, fco, fca,
+def overridefilemerge(origfn, premerge, repo, wctx, mynode, orig, fcd, fco, 
fca,
   labels=None):
 if not lfutil.isstandin(orig) or fcd.isabsent() or fco.isabsent():
-return origfn(premerge, repo, mynode, orig, fcd, fco, fca,
+return origfn(premerge, repo, wctx, mynode, orig, fcd, fco, fca,
   labels=labels)
 
 ahash = lfutil.readasstandin(fca).lower()



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


D450: filemerge: add wctx to all internal tools

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1234.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D450?vs=1211=1234

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

AFFECTED FILES
  mercurial/filemerge.py
  mercurial/tagmerge.py

CHANGE DETAILS

diff --git a/mercurial/tagmerge.py b/mercurial/tagmerge.py
--- a/mercurial/tagmerge.py
+++ b/mercurial/tagmerge.py
@@ -216,7 +216,7 @@
 # whole list of lr nodes
 return lrnodes + hrnodes[commonidx:]
 
-def merge(repo, fcd, fco, fca):
+def merge(repo, wctx, fcd, fco, fca):
 '''
 Merge the tags of two revisions, taking into account the base tags
 Try to minimize the diff between the merged tags and the first parent tags
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -238,7 +238,7 @@
 util.writefile(file, newdata)
 
 @internaltool('prompt', nomerge)
-def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iprompt(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Asks the user which of the local `p1()` or the other `p2()` version to
 keep as the merged version."""
 ui = repo.ui
@@ -263,26 +263,26 @@
 choice = ['local', 'other', 'unresolved'][index]
 
 if choice == 'other':
-return _iother(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
labels)
 elif choice == 'local':
-return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ilocal(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
labels)
 elif choice == 'unresolved':
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   labels)
 except error.ResponseExpected:
 ui.write("\n")
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   labels)
 
 @internaltool('local', nomerge)
-def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ilocal(repo, wtcx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the local `p1()` version of files as the merged version."""
 return 0, fcd.isabsent()
 
 @internaltool('other', nomerge)
-def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the other `p2()` version of files as the merged version."""
 if fco.isabsent():
 # local changed, remote deleted -- 'deleted' picked
@@ -294,7 +294,7 @@
 return 0, deleted
 
 @internaltool('fail', nomerge)
-def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """
 Rather than attempting to merge files that were modified on both
 branches, it marks them as unresolved. The resolve command must be
@@ -362,7 +362,8 @@
 return False
 return True
 
-def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
+def _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files, labels,
+   mode):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
@@ -380,32 +381,35 @@
   _("warning: conflicts while merging %s! "
 "(edit, then use 'hg resolve --mark')\n"),
   precheck=_mergecheck)
-def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _iunion(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will use both left and right sides for conflict regions.
 No markers are inserted."""
-return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   files, labels, 'union')
 
 @internaltool('merge', fullmerge,
   _("warning: conflicts while merging %s! "
 "(edit, then use 'hg resolve --mark')\n"),
   precheck=_mergecheck)
-def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _imerge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
 the partially merged file. Markers will have two sections, one for each 
side
 of merge."""
-return _merge(repo, mynode, 

D499: merge: pass wctx to premerge, filemerge

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1233.
phillco retitled this revision from "filemerge: add wctx to all internal tools" 
to "merge: pass wctx to premerge, filemerge".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D499?vs=1232=1233

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/filemerge.py
  mercurial/merge.py
  tests/failfilemerge.py

CHANGE DETAILS

diff --git a/tests/failfilemerge.py b/tests/failfilemerge.py
--- a/tests/failfilemerge.py
+++ b/tests/failfilemerge.py
@@ -9,7 +9,8 @@
 )
 
 def failfilemerge(filemergefn,
-  premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
+  premerge, repo, wctx, mynode, orig, fcd, fco, fca,
+  labels=None):
 raise error.Abort("^C")
 return filemergefn(premerge, repo, mynode, orig, fcd, fco, fca, labels)
 
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -495,12 +495,14 @@
 f.close()
 else:
 wctx[dfile].remove(ignoremissing=True)
-complete, r, deleted = filemerge.premerge(self._repo, self._local,
-  lfile, fcd, fco, fca,
+complete, r, deleted = filemerge.premerge(self._repo, wctx,
+  self._local, lfile, fcd,
+  fco, fca,
   labels=self._labels)
 else:
-complete, r, deleted = filemerge.filemerge(self._repo, self._local,
-   lfile, fcd, fco, fca,
+complete, r, deleted = filemerge.filemerge(self._repo, wctx,
+   self._local, lfile, fcd,
+   fco, fca,
labels=self._labels)
 if r is None:
 # no real conflict
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -586,7 +586,7 @@
 "o": " [%s]" % labels[1],
 }
 
-def _filemerge(premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
+def _filemerge(premerge, repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
 """perform a 3-way merge in the working directory
 
 premerge = whether this is a premerge
@@ -728,11 +728,12 @@
 
 return r
 
-def premerge(repo, mynode, orig, fcd, fco, fca, labels=None):
+def premerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
 return _filemerge(True, repo, mynode, orig, fcd, fco, fca, labels=labels)
 
-def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None):
-return _filemerge(False, repo, mynode, orig, fcd, fco, fca, labels=labels)
+def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
+return _filemerge(False, repo, wctx, mynode, orig, fcd, fco, fca,
+  labels=labels)
 
 def loadinternalmerge(ui, extname, registrarobj):
 """Load internal merge tool from specified registrarobj
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -545,10 +545,10 @@
 
 # Override filemerge to prompt the user about how they wish to merge
 # largefiles. This will handle identical edits without prompting the user.
-def overridefilemerge(origfn, premerge, repo, mynode, orig, fcd, fco, fca,
+def overridefilemerge(origfn, premerge, repo, wctx, mynode, orig, fcd, fco, 
fca,
   labels=None):
 if not lfutil.isstandin(orig) or fcd.isabsent() or fco.isabsent():
-return origfn(premerge, repo, mynode, orig, fcd, fco, fca,
+return origfn(premerge, repo, wctx, mynode, orig, fcd, fco, fca,
   labels=labels)
 
 ahash = lfutil.readasstandin(fca).lower()



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


D499: filemerge: add wctx to all internal tools

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1232.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D499?vs=1231=1232

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

AFFECTED FILES
  mercurial/filemerge.py
  mercurial/tagmerge.py

CHANGE DETAILS

diff --git a/mercurial/tagmerge.py b/mercurial/tagmerge.py
--- a/mercurial/tagmerge.py
+++ b/mercurial/tagmerge.py
@@ -216,7 +216,7 @@
 # whole list of lr nodes
 return lrnodes + hrnodes[commonidx:]
 
-def merge(repo, fcd, fco, fca):
+def merge(repo, wctx, fcd, fco, fca):
 '''
 Merge the tags of two revisions, taking into account the base tags
 Try to minimize the diff between the merged tags and the first parent tags
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -238,7 +238,7 @@
 util.writefile(file, newdata)
 
 @internaltool('prompt', nomerge)
-def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iprompt(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Asks the user which of the local `p1()` or the other `p2()` version to
 keep as the merged version."""
 ui = repo.ui
@@ -263,26 +263,26 @@
 choice = ['local', 'other', 'unresolved'][index]
 
 if choice == 'other':
-return _iother(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
labels)
 elif choice == 'local':
-return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ilocal(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
labels)
 elif choice == 'unresolved':
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   labels)
 except error.ResponseExpected:
 ui.write("\n")
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   labels)
 
 @internaltool('local', nomerge)
-def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ilocal(repo, wtcx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the local `p1()` version of files as the merged version."""
 return 0, fcd.isabsent()
 
 @internaltool('other', nomerge)
-def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the other `p2()` version of files as the merged version."""
 if fco.isabsent():
 # local changed, remote deleted -- 'deleted' picked
@@ -294,7 +294,7 @@
 return 0, deleted
 
 @internaltool('fail', nomerge)
-def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """
 Rather than attempting to merge files that were modified on both
 branches, it marks them as unresolved. The resolve command must be
@@ -362,7 +362,8 @@
 return False
 return True
 
-def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
+def _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files, labels,
+   mode):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
@@ -380,32 +381,35 @@
   _("warning: conflicts while merging %s! "
 "(edit, then use 'hg resolve --mark')\n"),
   precheck=_mergecheck)
-def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _iunion(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will use both left and right sides for conflict regions.
 No markers are inserted."""
-return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   files, labels, 'union')
 
 @internaltool('merge', fullmerge,
   _("warning: conflicts while merging %s! "
 "(edit, then use 'hg resolve --mark')\n"),
   precheck=_mergecheck)
-def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _imerge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
 the partially merged file. Markers will have two 

D464: commit: use an unambiguous path suffix for the commit editor file

2017-08-23 Thread smf (Sean Farley)
smf added a comment.


  Everything I was talking about in https://phab.mercurial-scm.org/D468 was 
meant to be posted here. (I am not doing well with phabricator it seems)

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread smf (Sean Farley)
smf added a comment.


  In https://phab.mercurial-scm.org/D468#7920, @mbolin wrote:
  
  > @smf so are you OK with this patch as-is?
  
  
  Yeah, should be fine.

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread mbolin (Michael Bolin)
mbolin added a comment.


  @smf so are you OK with this patch as-is?

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread smf (Sean Farley)
smf added a comment.


  In https://phab.mercurial-scm.org/D468#7915, @mbolin wrote:
  
  > @smf Personally, I think that https://phab.mercurial-scm.org/D464 is a 
better place to have that discussion.
  
  
  Sigh. Yes, this is what I was confused about.

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread smf (Sean Farley)
smf added a comment.


  In https://phab.mercurial-scm.org/D468#7916, @durin42 wrote:
  
  > In https://phab.mercurial-scm.org/D468#7914, @smf wrote:
  >
  > > Basically, I was pondering aloud if '~' would be enough to future-proof 
us and if we shouldn't just rename all temp files to something unique 
(HG_EDITOR for commits, HG_HISTEDIT for histedit, etc). What I was hoping for 
was a discussion on that.
  >
  >
  > This sounds like a good idea. However, if I'm understanding @mbolin 
correctly, we /also/ want a ~ suffix (or similar) so that devtools don't need 
to grow hg-specific logic for tempfiles (since, in the case of a ~ suffix, 
we'll be enough like vim that they will already correctly ignore things). Do I 
have a reasonable handle on this, or is there more nuance that I'm missing?
  
  
  Yeah, I don't know what happened. I guess I misread this and thought it was 
similar to work I did before. I withdraw my concerns and apologize for 
derailing this.

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread smf (Sean Farley)
smf added a comment.


  In https://phab.mercurial-scm.org/D468#7912, @mbolin wrote:
  
  > @smf As I put in the summary, I think this use of `tempfile.mkstemp()` is 
different than the others in the codebase because it uses the `dir=` argument 
to create a file in the working copy. As such, I'd argue that it's reasonable 
to consider it separately from the others.
  >
  > In particular, I think it's independent of how temp files are created for 
things like commit messages as those are paths that are intended to be exposed 
to the user insofar as they are opened in the user's editor. As it stands, I 
have https://phab.mercurial-scm.org/D464 out for review as a first step to 
impose some order on path names for those types of files.
  >
  > As far as this change is concerned, the focus is to preserve the existing 
behavior of `mktempcopy()` while minimizing its impact on other developer tools.
  
  
  Jesus, I confused myself on this patch. Yes, you're right. I completely 
mistook this for other patches I worked on mucking around with the tmp 
directories.
  
  That's definitely on me, sorry!

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread durin42 (Augie Fackler)
durin42 added a comment.


  In https://phab.mercurial-scm.org/D468#7914, @smf wrote:
  
  > Basically, I was pondering aloud if '~' would be enough to future-proof us 
and if we shouldn't just rename all temp files to something unique (HG_EDITOR 
for commits, HG_HISTEDIT for histedit, etc). What I was hoping for was a 
discussion on that.
  
  
  This sounds like a good idea. However, if I'm understanding @mbolin 
correctly, we /also/ want a ~ suffix (or similar) so that devtools don't need 
to grow hg-specific logic for tempfiles (since, in the case of a ~ suffix, 
we'll be enough like vim that they will already correctly ignore things). Do I 
have a reasonable handle on this, or is there more nuance that I'm missing?

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread mbolin (Michael Bolin)
mbolin added a comment.


  @smf Personally, I think that https://phab.mercurial-scm.org/D464 is a better 
place to have that discussion.

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread smf (Sean Farley)
smf added a comment.


  In https://phab.mercurial-scm.org/D468#7910, @smf wrote:
  
  > That seems a bit over complicated to me. Why not just just use the
  >  random tmp as a directory instead of a file while renaming the file at
  >  the same time:
  >
  > /tmp/XYZ123/hg-editor (or HG_EDITOR or whatever)
  >
  > This would allow 'editortmpinhg'[1] to just be .hg/hg-editor (or
  >  HG_EDITOR etc). The '~' seems a bit like a quick hack and I think I'd
  >  prefer to do this cleanly. My logic here is:
  >
  > 1. if we can append a character to the suffix, then we should be able to 
change the directory
  > 2. we might want different 'file types' for different tmp files and '~' 
seems that it might not get us far enough. For instance: a) editor, b) 
conflicts c) histedit etc
  >
  >   For (a) and (c), I hacked something together for my fork of magit (called 
mahgic) so that I can have different modes for commit (to show the diff) and 
for histedit (so that 'tab' and 'enter' will show the commit at the point).
  >
  >   [1] I planned on making editortmpinhg a more thorough thing so that 
everything would be in the .hg directory so that programs (like emacs) would be 
able to find the correct repo given only the tmp file.
  
  
  Basically, I was pondering aloud if '~' would be enough to future-proof us 
and if we shouldn't just rename all temp files to something unique (HG_EDITOR 
for commits, HG_HISTEDIT for histedit, etc). What I was hoping for was a 
discussion on that.

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread mbolin (Michael Bolin)
mbolin added a comment.


  @smf As I put in the summary, I think this use of `tempfile.mkstemp()` is 
different than the others in the codebase because it uses the `dir=` argument 
to create a file in the working copy. As such, I'd argue that it's reasonable 
to consider it separately from the others.
  
  In particular, I think it's independent of how temp files are created for 
things like commit messages as those are paths that are intended to be exposed 
to the user insofar as they are opened in the user's editor. As it stands, I 
have https://phab.mercurial-scm.org/D464 out for review as a first step to 
impose some order on path names for those types of files.
  
  As far as this change is concerned, the focus is to preserve the existing 
behavior of `mktempcopy()` while minimizing its impact on other developer tools.

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread smf (Sean Farley)
smf added a comment.


  In https://phab.mercurial-scm.org/D468#7909, @durin42 wrote:
  
  > In https://phab.mercurial-scm.org/D468#7908, @smf wrote:
  >
  > > In https://phab.mercurial-scm.org/D468#7836, @quark wrote:
  > >
  > > > In https://phab.mercurial-scm.org/D468#7833, @smf wrote:
  > > >
  > > > > Basically, I'd like a more unified approach for all types of temp 
files (commit message, histedit, conflicts, etc).
  > > >
  > > >
  > > > I think this patch is about low-level `util` function that shouldn't be 
coupled with `ui` or config. It has value on its own and I don't think such 
"unified approach" should block this patch - we can always add configs and make 
callers of `util.mktempcopy` pass `suffix` down here AFTER this patch.
  > >
  > >
  > > Um, what? That's the whole point of review. Yes, I know you think you can 
do this AFTER (why are we yelling?). I don't like this patch as-is and am 
frankly tired of trying to jam stuff through review and promise to clean up 
later. I am against this patch.
  >
  >
  > As a bystander here, I'm not even sure what the proposals are. Can one of 
you summarize what the competing ideas are?
  >
  > (In general I agree with smf that a more unified error-resistant API should 
be a goal, and I'm -0 on adding complexity to hg in the name of buck 
performance if there's a better proposal on the table (but if there is I've 
missed it.))
  
  
  From the mailing list (just posting this here for now so I can reply to it in 
the next message):
  
  Jun Wu  writes:
  
  > I think this patch is about changing the suffix. I guess some less powerful
  >  editors may only support matching file types by suffixes.
  
  Yeah, it seems that way.
  
  > Please correct me if I'm wrong, but I failed to see how the
  >  "experimental.editortmpinhg" setting could be used as-is to change the
  >  suffix. Therefore I think the patch is still needed.
  > 
  > Maybe we can change it to a config option? Like, instead of saying:
  > 
  >   extra_defaults = {
  >   'prefix': 'editor',
  >   'suffix': '.txt',
  >   }
  > 
  > Changing ".txt" there to be a config option (maybe
  >  experimental.editorsuffix).
  
  That seems a bit over complicated to me. Why not just just use the
  random tmp as a directory instead of a file while renaming the file at
  the same time:
  
  /tmp/XYZ123/hg-editor (or HG_EDITOR or whatever)
  
  This would allow 'editortmpinhg'[1] to just be .hg/hg-editor (or
  HG_EDITOR etc). The '~' seems a bit like a quick hack and I think I'd
  prefer to do this cleanly. My logic here is:
  
  1. if we can append a character to the suffix, then we should be able to
  
  change the directory
  
  2. we might want different 'file types' for different tmp files and '~' seems 
that it might not get us far enough. For instance: a) editor, b) conflicts c) 
histedit etc
  
  For (a) and (c), I hacked something together for my fork of magit
  (called mahgic) so that I can have different modes for commit (to show
  the diff) and for histedit (so that 'tab' and 'enter' will show the
  commit at the point).
  
  [1] I planned on making editortmpinhg a more thorough thing so that
  everything would be in the .hg directory so that programs (like emacs)
  would be able to find the correct repo given only the tmp file.

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread durin42 (Augie Fackler)
durin42 added a comment.


  In https://phab.mercurial-scm.org/D468#7908, @smf wrote:
  
  > In https://phab.mercurial-scm.org/D468#7836, @quark wrote:
  >
  > > In https://phab.mercurial-scm.org/D468#7833, @smf wrote:
  > >
  > > > Basically, I'd like a more unified approach for all types of temp files 
(commit message, histedit, conflicts, etc).
  > >
  > >
  > > I think this patch is about low-level `util` function that shouldn't be 
coupled with `ui` or config. It has value on its own and I don't think such 
"unified approach" should block this patch - we can always add configs and make 
callers of `util.mktempcopy` pass `suffix` down here AFTER this patch.
  >
  >
  > Um, what? That's the whole point of review. Yes, I know you think you can 
do this AFTER (why are we yelling?). I don't like this patch as-is and am 
frankly tired of trying to jam stuff through review and promise to clean up 
later. I am against this patch.
  
  
  As a bystander here, I'm not even sure what the proposals are. Can one of you 
summarize what the competing ideas are?
  
  (In general I agree with smf that a more unified error-resistant API should 
be a goal, and I'm -0 on adding complexity to hg in the name of buck 
performance if there's a better proposal on the table (but if there is I've 
missed it.))

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread smf (Sean Farley)
smf added a comment.


  In https://phab.mercurial-scm.org/D468#7836, @quark wrote:
  
  > In https://phab.mercurial-scm.org/D468#7833, @smf wrote:
  >
  > > Basically, I'd like a more unified approach for all types of temp files 
(commit message, histedit, conflicts, etc).
  >
  >
  > I think this patch is about low-level `util` function that shouldn't be 
coupled with `ui` or config. It has value on its own and I don't think such 
"unified approach" should block this patch - we can always add configs and make 
callers of `util.mktempcopy` pass `suffix` down here AFTER this patch.
  
  
  Um, what? That's the whole point of review. Yes, I know you think you can do 
this AFTER (why are we yelling?). I don't like this patch as-is and am frankly 
tired of trying to jam stuff through review and promise to clean up later. I am 
against this patch.

REPOSITORY
  rHG Mercurial

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

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


D290: bundlerepo: move bundle2 part handling out to a function

2017-08-23 Thread durham (Durham Goode)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf672d060a931: bundlerepo: move bundle2 part handling out to 
a function (authored by durham).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D290?vs=1217=1229

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

AFFECTED FILES
  mercurial/bundlerepo.py

CHANGE DETAILS

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -283,26 +283,18 @@
 self.bundlefile = self.bundle = exchange.readbundle(ui, f, bundlename)
 
 if isinstance(self.bundle, bundle2.unbundle20):
-cgstream = None
+hadchangegroup = False
 for part in self.bundle.iterparts():
 if part.type == 'changegroup':
-if cgstream is not None:
+if hadchangegroup:
 raise NotImplementedError("can't process "
   "multiple changegroups")
-cgstream = part
-version = part.params.get('version', '01')
-legalcgvers = changegroup.supportedincomingversions(self)
-if version not in legalcgvers:
-msg = _('Unsupported changegroup version: %s')
-raise error.Abort(msg % version)
-if self.bundle.compressed():
-cgstream = self._writetempbundle(part.read,
- ".cg%sun" % version)
+hadchangegroup = True
 
-if cgstream is None:
-raise error.Abort(_('No changegroups found'))
+self._handlebundle2part(part)
 
-self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
+if not hadchangegroup:
+raise error.Abort(_("No changegroups found"))
 
 elif self.bundle.compressed():
 f = self._writetempbundle(self.bundle.read, '.hg10un',
@@ -318,6 +310,20 @@
 phases.retractboundary(self, None, phases.draft,
[ctx.node() for ctx in self[self.firstnewrev:]])
 
+def _handlebundle2part(self, part):
+if part.type == 'changegroup':
+cgstream = part
+version = part.params.get('version', '01')
+legalcgvers = changegroup.supportedincomingversions(self)
+if version not in legalcgvers:
+msg = _('Unsupported changegroup version: %s')
+raise error.Abort(msg % version)
+if self.bundle.compressed():
+cgstream = self._writetempbundle(part.read,
+ ".cg%sun" % version)
+
+self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
+
 def _writetempbundle(self, readfn, suffix, header=''):
 """Write a temporary file to disk
 """



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


D289: bundle2: seek part back during iteration

2017-08-23 Thread durham (Durham Goode)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG891118dcd279: bundle2: seek part back during iteration 
(authored by durham).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D289?vs=1216=1228

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/bundlerepo.py

CHANGE DETAILS

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -301,7 +301,6 @@
 
 if cgstream is None:
 raise error.Abort(_('No changegroups found'))
-cgstream.seek(0)
 
 self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
 
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -828,7 +828,11 @@
 while headerblock is not None:
 part = unbundlepart(self.ui, headerblock, self._fp)
 yield part
+# Seek to the end of the part to force it's consumption so the next
+# part can be read. But then seek back to the beginning so the
+# code consuming this generator has a part that starts at 0.
 part.seek(0, 2)
+part.seek(0)
 headerblock = self._readpartheader()
 indebug(self.ui, 'end of bundle2 stream')
 



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


D288: bundlerepo: move temp bundle creation to a separate function

2017-08-23 Thread durham (Durham Goode)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG702a26fec3e2: bundlerepo: move temp bundle creation to a 
separate function (authored by durham).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D288?vs=1215=1227

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

AFFECTED FILES
  mercurial/bundlerepo.py

CHANGE DETAILS

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -264,24 +264,6 @@
 
 class bundlerepository(localrepo.localrepository):
 def __init__(self, ui, path, bundlename):
-def _writetempbundle(read, suffix, header=''):
-"""Write a temporary file to disk
-
-This is closure because we need to make sure this tracked by
-self.tempfile for cleanup purposes."""
-fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-",
-suffix=".hg10un")
-self.tempfile = temp
-
-with os.fdopen(fdtemp, pycompat.sysstr('wb')) as fptemp:
-fptemp.write(header)
-while True:
-chunk = read(2**18)
-if not chunk:
-break
-fptemp.write(chunk)
-
-return self.vfs.open(self.tempfile, mode="rb")
 self._tempparent = None
 try:
 localrepo.localrepository.__init__(self, ui, path)
@@ -314,17 +296,18 @@
 msg = _('Unsupported changegroup version: %s')
 raise error.Abort(msg % version)
 if self.bundle.compressed():
-cgstream = _writetempbundle(part.read,
-".cg%sun" % version)
+cgstream = self._writetempbundle(part.read,
+ ".cg%sun" % version)
 
 if cgstream is None:
 raise error.Abort(_('No changegroups found'))
 cgstream.seek(0)
 
 self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
 
 elif self.bundle.compressed():
-f = _writetempbundle(self.bundle.read, '.hg10un', header='HG10UN')
+f = self._writetempbundle(self.bundle.read, '.hg10un',
+  header='HG10UN')
 self.bundlefile = self.bundle = exchange.readbundle(ui, f,
 bundlename,
 self.vfs)
@@ -336,6 +319,23 @@
 phases.retractboundary(self, None, phases.draft,
[ctx.node() for ctx in self[self.firstnewrev:]])
 
+def _writetempbundle(self, readfn, suffix, header=''):
+"""Write a temporary file to disk
+"""
+fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-",
+suffix=".hg10un")
+self.tempfile = temp
+
+with os.fdopen(fdtemp, pycompat.sysstr('wb')) as fptemp:
+fptemp.write(header)
+while True:
+chunk = readfn(2**18)
+if not chunk:
+break
+fptemp.write(chunk)
+
+return self.vfs.open(self.tempfile, mode="rb")
+
 @localrepo.unfilteredpropertycache
 def _phasecache(self):
 return bundlephasecache(self, self._phasedefaults)



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


D422: mdiff: add a --ignore-space-at-eol option

2017-08-23 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D422#7818, @akushner wrote:
  
  > @martinvonz  - a reasonable first pass would be to whitelist known 
contributors for CI runs.
  
  
  That sounds reasonable. Still not my area of expertise, but I'd be happy to 
see it done.

REPOSITORY
  rHG Mercurial

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

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


D288: bundlerepo: move temp bundle creation to a separate function

2017-08-23 Thread durham (Durham Goode)
durham added a comment.


  I fixed the comment and renamed read to readfn. I know we usually do renames 
as separate from code moves, but this was a tiny rename (only one use).

REPOSITORY
  rHG Mercurial

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

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


D404: filemerge: add _restorebackup

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1225.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D404?vs=913=1225

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -348,9 +348,7 @@
 return 0
 if premerge not in validkeep:
 # restore from backup and try again
-# TODO: Add a workingfilectx.write(otherfilectx) path so we can use
-# util.copy here instead.
-fcd.write(util.readfile(back), fcd.flags())
+_restorebackup(fcd, back)
 return 1 # continue merging
 
 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf):
@@ -591,6 +589,11 @@
 "o": " [%s]" % labels[1],
 }
 
+def _restorebackup(fcd, back):
+# TODO: Add a workingfilectx.write(otherfilectx) path so we can use
+# util.copy here instead.
+fcd.write(util.readfile(back), fcd.flags())
+
 def _makebackup(repo, ui, fcd, premerge):
 """Makes a backup of the local `fcd` file prior to merging.
 



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


D444: merge: move some of the logic in batchget() to workingfilectx

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1226.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D444?vs=1073=1226

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

AFFECTED FILES
  mercurial/context.py
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1150,9 +1150,7 @@
 except OSError as e:
 if e.errno != errno.ENOENT:
 raise
-
-if repo.wvfs.isdir(f) and not repo.wvfs.islink(f):
-repo.wvfs.removedirs(f)
+wctx[f].clearunknown()
 wctx[f].write(fctx(f).data(), flags, backgroundclose=True)
 if i == 100:
 yield i, f
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1968,6 +1968,19 @@
 self._repo.wwrite(self._path, data, flags,
   backgroundclose=backgroundclose)
 
+def clearunknown(self):
+"""Removes conflicting items in the working directory (and creates any
+missing parent directories) so that ``write()`` can be called
+successfully.
+"""
+if self._repo.wvfs.isdir(self._path) and not self._repo.wvfs.islink(
+self._path):
+self._repo.wvfs.removedirs(self._path)
+
+dirname = os.path.dirname(self._path)
+if not self._repo.wvfs.isdir(dirname):
+self._repo.wvfs.makedirs(dirname)
+
 def setflags(self, l, x):
 self._repo.wvfs.setflags(self._path, l, x)
 



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


D403: filemerge: reduce creation of tempfiles until needed

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1224.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D403?vs=912=1224

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -471,7 +471,6 @@
 This implies permerge. Therefore, files aren't dumped, if premerge
 runs successfully. Use :forcedump to forcibly write files out.
 """
-unused, unused, unused, unused = files
 a = _workingpath(repo, fcd)
 fd = fcd.path()
 
@@ -495,34 +494,38 @@
 repo.ui.warn(_('warning: %s cannot merge change/delete conflict '
'for %s\n') % (tool, fcd.path()))
 return False, 1, None
-unused, b, c, back = files
+unused, unused, unused, back = files
 a = _workingpath(repo, fcd)
-out = ""
-env = {'HG_FILE': fcd.path(),
-   'HG_MY_NODE': short(mynode),
-   'HG_OTHER_NODE': str(fco.changectx()),
-   'HG_BASE_NODE': str(fca.changectx()),
-   'HG_MY_ISLINK': 'l' in fcd.flags(),
-   'HG_OTHER_ISLINK': 'l' in fco.flags(),
-   'HG_BASE_ISLINK': 'l' in fca.flags(),
-   }
-
-ui = repo.ui
+b, c = _maketempfiles(repo, fco, fca)
+try:
+out = ""
+env = {'HG_FILE': fcd.path(),
+   'HG_MY_NODE': short(mynode),
+   'HG_OTHER_NODE': str(fco.changectx()),
+   'HG_BASE_NODE': str(fca.changectx()),
+   'HG_MY_ISLINK': 'l' in fcd.flags(),
+   'HG_OTHER_ISLINK': 'l' in fco.flags(),
+   'HG_BASE_ISLINK': 'l' in fca.flags(),
+   }
+ui = repo.ui
 
-args = _toolstr(ui, tool, "args", '$local $base $other')
-if "$output" in args:
-out, a = a, back # read input from backup, write to original
-replace = {'local': a, 'base': b, 'other': c, 'output': out}
-args = util.interpolate(r'\$', replace, args,
-lambda s: util.shellquote(util.localpath(s)))
-cmd = toolpath + ' ' + args
-if _toolbool(ui, tool, "gui"):
-repo.ui.status(_('running merge tool %s for file %s\n') %
-   (tool, fcd.path()))
-repo.ui.debug('launching merge tool: %s\n' % cmd)
-r = ui.system(cmd, cwd=repo.root, environ=env, blockedtag='mergetool')
-repo.ui.debug('merge tool returned: %s\n' % r)
-return True, r, False
+args = _toolstr(ui, tool, "args", '$local $base $other')
+if "$output" in args:
+out, a = a, back # read input from backup, write to original
+replace = {'local': a, 'base': b, 'other': c, 'output': out}
+args = util.interpolate(r'\$', replace, args,
+lambda s: util.shellquote(util.localpath(s)))
+cmd = toolpath + ' ' + args
+if _toolbool(ui, tool, "gui"):
+repo.ui.status(_('running merge tool %s for file %s\n') %
+   (tool, fcd.path()))
+repo.ui.debug('launching merge tool: %s\n' % cmd)
+r = ui.system(cmd, cwd=repo.root, environ=env, blockedtag='mergetool')
+repo.ui.debug('merge tool returned: %s\n' % r)
+return True, r, False
+finally:
+util.unlink(b)
+util.unlink(c)
 
 def _formatconflictmarker(repo, ctx, template, label, pad):
 """Applies the given template to the ctx, prefixed by the label.
@@ -604,12 +607,9 @@
 util.copyfile(a, back)
 return back
 
-def _maketempfiles(repo, fcd, fco, fca):
+def _maketempfiles(repo, fco, fca):
 """Writes out `fco` and `fca` as temporary files, so an external merge
 tool may use them.
-
-`fcd` is returned as-is, by convention, because it currently doubles as 
both
-the local version and merge destination.
 """
 def temp(prefix, ctx):
 fullbase, ext = os.path.splitext(ctx.path())
@@ -621,11 +621,10 @@
 f.close()
 return name
 
-a = repo.wjoin(fcd.path())
 b = temp("base", fca)
 c = temp("other", fco)
 
-return a, b, c
+return b, c
 
 def _filemerge(premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
 """perform a 3-way merge in the working directory
@@ -688,7 +687,7 @@
 return True, 1, False
 
 back = _makebackup(repo, ui, fcd, premerge)
-files = _maketempfiles(repo, fcd, fco, fca) + (back,)
+files = (None, None, None, back)
 r = 1
 try:
 markerstyle = ui.config('ui', 'mergemarkers')
@@ -716,12 +715,10 @@
 finally:
 if not r and back is not None:
 util.unlink(back)
-util.unlink(files[1])
-util.unlink(files[2])
 
 def _check(repo, r, ui, tool, fcd, files):
 fd = fcd.path()
-a, unused, unused, back = files
+unused, unused, unused, back = files
 
 if not r and (_toolbool(ui, tool, "checkconflicts") or
   'conflicts' in 

D401: filemerge: add `_workingpath`

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1223.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D401?vs=911=1223

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -471,8 +471,8 @@
 This implies permerge. Therefore, files aren't dumped, if premerge
 runs successfully. Use :forcedump to forcibly write files out.
 """
-a, b, c, back = files
-
+unused, unused, unused, unused = files
+a = _workingpath(repo, fcd)
 fd = fcd.path()
 
 util.copyfile(a, a + ".local")
@@ -495,7 +495,8 @@
 repo.ui.warn(_('warning: %s cannot merge change/delete conflict '
'for %s\n') % (tool, fcd.path()))
 return False, 1, None
-a, b, c, back = files
+unused, b, c, back = files
+a = _workingpath(repo, fcd)
 out = ""
 env = {'HG_FILE': fcd.path(),
'HG_MY_NODE': short(mynode),
@@ -597,7 +598,7 @@
 if fcd.isabsent():
 return None
 
-a = repo.wjoin(fcd.path())
+a = _workingpath(repo, fcd)
 back = scmutil.origpath(ui, repo, a)
 if premerge:
 util.copyfile(a, back)
@@ -705,7 +706,7 @@
  toolconf, files, labels=labels)
 
 if needcheck:
-r = _check(r, ui, tool, fcd, files)
+r = _check(repo, r, ui, tool, fcd, files)
 
 if r:
 if onfailure:
@@ -718,7 +719,7 @@
 util.unlink(files[1])
 util.unlink(files[2])
 
-def _check(r, ui, tool, fcd, files):
+def _check(repo, r, ui, tool, fcd, files):
 fd = fcd.path()
 a, unused, unused, back = files
 
@@ -738,17 +739,20 @@
 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or
   'changed' in
   _toollist(ui, tool, "check")):
-if back is not None and filecmp.cmp(a, back):
+if back is not None and filecmp.cmp(_workingpath(repo, fcd), back):
 if ui.promptchoice(_(" output file %s appears unchanged\n"
  "was merge successful (yn)?"
  "$$  $$ ") % fd, 1):
 r = 1
 
 if back is not None and _toolbool(ui, tool, "fixeol"):
-_matcheol(a, back)
+_matcheol(_workingpath(repo, fcd), back)
 
 return r
 
+def _workingpath(repo, ctx):
+return repo.wjoin(ctx.path())
+
 def premerge(repo, mynode, orig, fcd, fco, fca, labels=None):
 return _filemerge(True, repo, mynode, orig, fcd, fco, fca, labels=labels)
 



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


D388: filemerge: extract _maketemp and _makebackup

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1221.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D388?vs=880=1221

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -586,6 +586,45 @@
 "o": " [%s]" % labels[1],
 }
 
+def _makebackup(repo, ui, fcd, premerge):
+"""Makes a backup of the local `fcd` file prior to merging.
+
+In addition to preserving the user's pre-existing modifications to `fcd`
+(if any), the backup is used to undo certain a premerge, confirm a merge
+changed anything, and determine what line endings the new file should have.
+"""
+if fcd.isabsent():
+return None
+
+a = repo.wjoin(fcd.path())
+back = scmutil.origpath(ui, repo, a)
+if premerge:
+util.copyfile(a, back)
+return back
+
+def _maketempfiles(repo, fcd, fco, fca):
+"""Writes out `fco` and `fca` as temporary files, so an external merge
+tool may use them.
+
+`fcd` is returned as-is, by convention, because it currently doubles as 
both
+the local version and merge destination.
+"""
+def temp(prefix, ctx):
+fullbase, ext = os.path.splitext(ctx.path())
+pre = "%s~%s." % (os.path.basename(fullbase), prefix)
+(fd, name) = tempfile.mkstemp(prefix=pre, suffix=ext)
+data = repo.wwritedata(ctx.path(), ctx.data())
+f = os.fdopen(fd, pycompat.sysstr("wb"))
+f.write(data)
+f.close()
+return name
+
+a = repo.wjoin(fcd.path())
+b = temp("base", fca)
+c = temp("other", fco)
+
+return a, b, c
+
 def _filemerge(premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
 """perform a 3-way merge in the working directory
 
@@ -599,16 +638,6 @@
 Returns whether the merge is complete, the return value of the merge, and
 a boolean indicating whether the file was deleted from disk."""
 
-def temp(prefix, ctx):
-fullbase, ext = os.path.splitext(ctx.path())
-pre = "%s~%s." % (os.path.basename(fullbase), prefix)
-(fd, name) = tempfile.mkstemp(prefix=pre, suffix=ext)
-data = repo.wwritedata(ctx.path(), ctx.data())
-f = os.fdopen(fd, pycompat.sysstr("wb"))
-f.write(data)
-f.close()
-return name
-
 if not fco.cmp(fcd): # files identical?
 return True, None, False
 
@@ -656,17 +685,8 @@
 ui.warn(onfailure % fd)
 return True, 1, False
 
-a = repo.wjoin(fd)
-b = temp("base", fca)
-c = temp("other", fco)
-if not fcd.isabsent():
-back = scmutil.origpath(ui, repo, a)
-if premerge:
-util.copyfile(a, back)
-else:
-back = None
-files = (a, b, c, back)
-
+back = _makebackup(repo, ui, fcd, premerge)
+files = _maketempfiles(repo, fcd, fco, fca) + (back,)
 r = 1
 try:
 markerstyle = ui.config('ui', 'mergemarkers')
@@ -694,8 +714,8 @@
 finally:
 if not r and back is not None:
 util.unlink(back)
-util.unlink(b)
-util.unlink(c)
+util.unlink(files[1])
+util.unlink(files[2])
 
 def _check(r, ui, tool, fcd, files):
 fd = fcd.path()



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


D381: simplemerge: stop accepting, and passing, file parameters

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1220.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D381?vs=1041=1220

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

AFFECTED FILES
  contrib/simplemerge
  mercurial/filemerge.py
  mercurial/simplemerge.py

CHANGE DETAILS

diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -419,8 +419,8 @@
 
 return [name_a, name_b, name_base]
 
-def simplemerge(ui, localfile, basefile, otherfile,
-localctx=None, basectx=None, otherctx=None, repo=None, **opts):
+def simplemerge(ui, localctx=None, basectx=None, otherctx=None, repo=None,
+**opts):
 """Performs the simplemerge algorithm.
 
 {local|base|other}ctx are optional. If passed, they (local/base/other) will
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -341,7 +341,7 @@
 labels = _defaultconflictlabels
 if len(labels) < 3:
 labels.append('base')
-r = simplemerge.simplemerge(ui, a, b, c, fcd, fca, fco,
+r = simplemerge.simplemerge(ui, fcd, fca, fco,
 quiet=True, label=labels, repo=repo)
 if not r:
 ui.debug(" premerge successful\n")
@@ -372,7 +372,7 @@
 
 ui = repo.ui
 
-r = simplemerge.simplemerge(ui, a, b, c, fcd, fca, fco,
+r = simplemerge.simplemerge(ui, fcd, fca, fco,
 label=labels, mode=mode, repo=repo)
 return True, r, False
 
@@ -425,7 +425,7 @@
 assert localorother is not None
 tool, toolpath, binary, symlink = toolconf
 a, b, c, back = files
-r = simplemerge.simplemerge(repo.ui, a, b, c, fcd, fca, fco,
+r = simplemerge.simplemerge(repo.ui, fcd, fca, fco,
 label=labels, localorother=localorother,
 repo=repo)
 return True, r
diff --git a/contrib/simplemerge b/contrib/simplemerge
--- a/contrib/simplemerge
+++ b/contrib/simplemerge
@@ -77,9 +77,6 @@
 raise ParseError(_('wrong number of arguments'))
 local, base, other = args
 sys.exit(simplemerge.simplemerge(ui.ui.load(),
- local,
- base,
- other,
  filebackedctx(local),
  filebackedctx(base),
  filebackedctx(other),



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


D399: filemerge: eliminate most uses of tempfiles

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1222.
phillco edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D399?vs=906=1222

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -318,7 +318,7 @@
 tool, toolpath, binary, symlink = toolconf
 if symlink or fcd.isabsent() or fco.isabsent():
 return 1
-a, b, c, back = files
+unused, unused, unused, back = files
 
 ui = repo.ui
 
@@ -347,7 +347,8 @@
 ui.debug(" premerge successful\n")
 return 0
 if premerge not in validkeep:
-util.copyfile(back, a) # restore from backup and try again
+# restore from backup and try again
+util.copyfile(back, repo.wjoin(fcd.path()))
 return 1 # continue merging
 
 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf):
@@ -368,8 +369,6 @@
 files. It will fail if there are any conflicts and leave markers in
 the partially merged file. Markers will have two sections, one for each 
side
 of merge, unless mode equals 'union' which suppresses the markers."""
-a, b, c, back = files
-
 ui = repo.ui
 
 r = simplemerge.simplemerge(ui, fcd, fca, fco,
@@ -719,7 +718,7 @@
 
 def _check(r, ui, tool, fcd, files):
 fd = fcd.path()
-a, b, c, back = files
+a, unused, unused, back = files
 
 if not r and (_toolbool(ui, tool, "checkconflicts") or
   'conflicts' in _toollist(ui, tool, "check")):



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


D434: context: add `decodeddata()` to basefilectx

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1219.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D434?vs=1036=1219

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1097,6 +1097,13 @@
 c = visit.pop(max(visit))
 yield c
 
+def decodeddata(self):
+"""Returns `data()` after running repository decoding filters.
+
+This is often equivalent to how the data would be expressed on disk.
+"""
+return self._repo.wwritedata(self.path(), self.data())
+
 def _annotatepair(parents, childfctx, child, skipchild, diffopts):
 r'''
 Given parent and child fctxes and annotate data for parents, for all lines



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


D400: filemerge: move a util copy call to filectx.write

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1218.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D400?vs=907=1218

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -348,7 +348,9 @@
 return 0
 if premerge not in validkeep:
 # restore from backup and try again
-util.copyfile(back, repo.wjoin(fcd.path()))
+# TODO: Add a workingfilectx.write(otherfilectx) path so we can use
+# util.copy here instead.
+fcd.write(util.readfile(back), fcd.flags())
 return 1 # continue merging
 
 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf):



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


D289: bundle2: seek part back during iteration

2017-08-23 Thread durham (Durham Goode)
durham updated this revision to Diff 1216.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D289?vs=659=1216

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/bundlerepo.py

CHANGE DETAILS

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -301,7 +301,6 @@
 
 if cgstream is None:
 raise error.Abort(_('No changegroups found'))
-cgstream.seek(0)
 
 self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
 
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -828,7 +828,11 @@
 while headerblock is not None:
 part = unbundlepart(self.ui, headerblock, self._fp)
 yield part
+# Seek to the end of the part to force it's consumption so the next
+# part can be read. But then seek back to the beginning so the
+# code consuming this generator has a part that starts at 0.
 part.seek(0, 2)
+part.seek(0)
 headerblock = self._readpartheader()
 indebug(self.ui, 'end of bundle2 stream')
 



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


D288: bundlerepo: move temp bundle creation to a separate function

2017-08-23 Thread durham (Durham Goode)
durham updated this revision to Diff 1215.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D288?vs=658=1215

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

AFFECTED FILES
  mercurial/bundlerepo.py

CHANGE DETAILS

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -264,24 +264,6 @@
 
 class bundlerepository(localrepo.localrepository):
 def __init__(self, ui, path, bundlename):
-def _writetempbundle(read, suffix, header=''):
-"""Write a temporary file to disk
-
-This is closure because we need to make sure this tracked by
-self.tempfile for cleanup purposes."""
-fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-",
-suffix=".hg10un")
-self.tempfile = temp
-
-with os.fdopen(fdtemp, pycompat.sysstr('wb')) as fptemp:
-fptemp.write(header)
-while True:
-chunk = read(2**18)
-if not chunk:
-break
-fptemp.write(chunk)
-
-return self.vfs.open(self.tempfile, mode="rb")
 self._tempparent = None
 try:
 localrepo.localrepository.__init__(self, ui, path)
@@ -314,17 +296,18 @@
 msg = _('Unsupported changegroup version: %s')
 raise error.Abort(msg % version)
 if self.bundle.compressed():
-cgstream = _writetempbundle(part.read,
-".cg%sun" % version)
+cgstream = self._writetempbundle(part.read,
+ ".cg%sun" % version)
 
 if cgstream is None:
 raise error.Abort(_('No changegroups found'))
 cgstream.seek(0)
 
 self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
 
 elif self.bundle.compressed():
-f = _writetempbundle(self.bundle.read, '.hg10un', header='HG10UN')
+f = self._writetempbundle(self.bundle.read, '.hg10un',
+  header='HG10UN')
 self.bundlefile = self.bundle = exchange.readbundle(ui, f,
 bundlename,
 self.vfs)
@@ -336,6 +319,23 @@
 phases.retractboundary(self, None, phases.draft,
[ctx.node() for ctx in self[self.firstnewrev:]])
 
+def _writetempbundle(self, readfn, suffix, header=''):
+"""Write a temporary file to disk
+"""
+fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-",
+suffix=".hg10un")
+self.tempfile = temp
+
+with os.fdopen(fdtemp, pycompat.sysstr('wb')) as fptemp:
+fptemp.write(header)
+while True:
+chunk = readfn(2**18)
+if not chunk:
+break
+fptemp.write(chunk)
+
+return self.vfs.open(self.tempfile, mode="rb")
+
 @localrepo.unfilteredpropertycache
 def _phasecache(self):
 return bundlephasecache(self, self._phasedefaults)



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


D290: bundlerepo: move bundle2 part handling out to a function

2017-08-23 Thread durham (Durham Goode)
durham updated this revision to Diff 1217.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D290?vs=660=1217

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

AFFECTED FILES
  mercurial/bundlerepo.py

CHANGE DETAILS

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -283,26 +283,18 @@
 self.bundlefile = self.bundle = exchange.readbundle(ui, f, bundlename)
 
 if isinstance(self.bundle, bundle2.unbundle20):
-cgstream = None
+hadchangegroup = False
 for part in self.bundle.iterparts():
 if part.type == 'changegroup':
-if cgstream is not None:
+if hadchangegroup:
 raise NotImplementedError("can't process "
   "multiple changegroups")
-cgstream = part
-version = part.params.get('version', '01')
-legalcgvers = changegroup.supportedincomingversions(self)
-if version not in legalcgvers:
-msg = _('Unsupported changegroup version: %s')
-raise error.Abort(msg % version)
-if self.bundle.compressed():
-cgstream = self._writetempbundle(part.read,
- ".cg%sun" % version)
+hadchangegroup = True
 
-if cgstream is None:
-raise error.Abort(_('No changegroups found'))
+self._handlebundle2part(part)
 
-self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
+if not hadchangegroup:
+raise error.Abort(_("No changegroups found"))
 
 elif self.bundle.compressed():
 f = self._writetempbundle(self.bundle.read, '.hg10un',
@@ -318,6 +310,20 @@
 phases.retractboundary(self, None, phases.draft,
[ctx.node() for ctx in self[self.firstnewrev:]])
 
+def _handlebundle2part(self, part):
+if part.type == 'changegroup':
+cgstream = part
+version = part.params.get('version', '01')
+legalcgvers = changegroup.supportedincomingversions(self)
+if version not in legalcgvers:
+msg = _('Unsupported changegroup version: %s')
+raise error.Abort(msg % version)
+if self.bundle.compressed():
+cgstream = self._writetempbundle(part.read,
+ ".cg%sun" % version)
+
+self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
+
 def _writetempbundle(self, readfn, suffix, header=''):
 """Write a temporary file to disk
 """



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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread quark (Jun Wu)
quark added a comment.


  In https://phab.mercurial-scm.org/D468#7846, @mbolin wrote:
  
  > @quark Rather than exposing the additional keyword argument now, why don't 
we wait until there is a compelling use-case to use something other than `~`? 
As it stands, creating an API for this would just open things up to misuse.
  
  
  @smf: I think this is a question for you.
  
  I'm personally fine with either way.

REPOSITORY
  rHG Mercurial

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

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


D497: bundlerepo: move bundle2 part handling out to a function

2017-08-23 Thread durham (Durham Goode)
durham abandoned this revision.
durham added a comment.


  Duplciate

REPOSITORY
  rHG Mercurial

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

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


D495: bundlerepo: move temp bundle creation to a separate function

2017-08-23 Thread durham (Durham Goode)
durham abandoned this revision.
durham added a comment.


  Duplicate

REPOSITORY
  rHG Mercurial

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

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


D496: bundle2: seek part back during iteration

2017-08-23 Thread durham (Durham Goode)
durham abandoned this revision.
durham added a comment.


  Duplicate

REPOSITORY
  rHG Mercurial

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

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


D495: bundlerepo: move temp bundle creation to a separate function

2017-08-23 Thread durham (Durham Goode)
durham created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  A future patch will refactor certain parts of bundlerepo initiatlization such
  that we need to create temp bundles from another function. Let's move this to
  another function to support that.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/bundlerepo.py

CHANGE DETAILS

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -264,24 +264,6 @@
 
 class bundlerepository(localrepo.localrepository):
 def __init__(self, ui, path, bundlename):
-def _writetempbundle(read, suffix, header=''):
-"""Write a temporary file to disk
-
-This is closure because we need to make sure this tracked by
-self.tempfile for cleanup purposes."""
-fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-",
-suffix=".hg10un")
-self.tempfile = temp
-
-with os.fdopen(fdtemp, pycompat.sysstr('wb')) as fptemp:
-fptemp.write(header)
-while True:
-chunk = read(2**18)
-if not chunk:
-break
-fptemp.write(chunk)
-
-return self.vfs.open(self.tempfile, mode="rb")
 self._tempparent = None
 try:
 localrepo.localrepository.__init__(self, ui, path)
@@ -314,17 +296,18 @@
 msg = _('Unsupported changegroup version: %s')
 raise error.Abort(msg % version)
 if self.bundle.compressed():
-cgstream = _writetempbundle(part.read,
-".cg%sun" % version)
+cgstream = self._writetempbundle(part.read,
+ ".cg%sun" % version)
 
 if cgstream is None:
 raise error.Abort(_('No changegroups found'))
 cgstream.seek(0)
 
 self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
 
 elif self.bundle.compressed():
-f = _writetempbundle(self.bundle.read, '.hg10un', header='HG10UN')
+f = self._writetempbundle(self.bundle.read, '.hg10un',
+  header='HG10UN')
 self.bundlefile = self.bundle = exchange.readbundle(ui, f,
 bundlename,
 self.vfs)
@@ -336,6 +319,23 @@
 phases.retractboundary(self, None, phases.draft,
[ctx.node() for ctx in self[self.firstnewrev:]])
 
+def _writetempbundle(self, readfn, suffix, header=''):
+"""Write a temporary file to disk
+"""
+fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-",
+suffix=".hg10un")
+self.tempfile = temp
+
+with os.fdopen(fdtemp, pycompat.sysstr('wb')) as fptemp:
+fptemp.write(header)
+while True:
+chunk = readfn(2**18)
+if not chunk:
+break
+fptemp.write(chunk)
+
+return self.vfs.open(self.tempfile, mode="rb")
+
 @localrepo.unfilteredpropertycache
 def _phasecache(self):
 return bundlephasecache(self, self._phasedefaults)



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


D496: bundle2: seek part back during iteration

2017-08-23 Thread durham (Durham Goode)
durham created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Previously, iterparts would yield the part to users, then consume the part. 
This
  changed the part after the user was given it and left it at the end, both of
  which seem unexpected.  Let's seek back to the beginning after we've consumed
  it. I tried not seeking to the end at all, but that seems important for the
  overall bundle2 consumption.
  
  This is used in a future patch to let us move the bundlerepo
  bundle2-changegroup-part to be handled entirely within the for loop, instead 
of
  having to do a seek back to 0 after the entire loop finishes.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/bundlerepo.py

CHANGE DETAILS

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -301,7 +301,6 @@
 
 if cgstream is None:
 raise error.Abort(_('No changegroups found'))
-cgstream.seek(0)
 
 self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
 
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -828,7 +828,11 @@
 while headerblock is not None:
 part = unbundlepart(self.ui, headerblock, self._fp)
 yield part
+# Seek to the end of the part to force it's consumption so the next
+# part can be read. But then seek back to the beginning so the
+# code consuming this generator has a part that starts at 0.
 part.seek(0, 2)
+part.seek(0)
 headerblock = self._readpartheader()
 indebug(self.ui, 'end of bundle2 stream')
 



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


D497: bundlerepo: move bundle2 part handling out to a function

2017-08-23 Thread durham (Durham Goode)
durham created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This moves the bundle2 part handling for bundlerepo out to a separate function
  so extensions can participate in bundlerepo setup when using bundle2 bundles.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/bundlerepo.py

CHANGE DETAILS

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -283,26 +283,18 @@
 self.bundlefile = self.bundle = exchange.readbundle(ui, f, bundlename)
 
 if isinstance(self.bundle, bundle2.unbundle20):
-cgstream = None
+hadchangegroup = False
 for part in self.bundle.iterparts():
 if part.type == 'changegroup':
-if cgstream is not None:
+if hadchangegroup:
 raise NotImplementedError("can't process "
   "multiple changegroups")
-cgstream = part
-version = part.params.get('version', '01')
-legalcgvers = changegroup.supportedincomingversions(self)
-if version not in legalcgvers:
-msg = _('Unsupported changegroup version: %s')
-raise error.Abort(msg % version)
-if self.bundle.compressed():
-cgstream = self._writetempbundle(part.read,
- ".cg%sun" % version)
+hadchangegroup = True
 
-if cgstream is None:
-raise error.Abort(_('No changegroups found'))
+self._handlebundle2part(part)
 
-self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
+if not hadchangegroup:
+raise error.Abort(_("No changegroups found"))
 
 elif self.bundle.compressed():
 f = self._writetempbundle(self.bundle.read, '.hg10un',
@@ -318,6 +310,20 @@
 phases.retractboundary(self, None, phases.draft,
[ctx.node() for ctx in self[self.firstnewrev:]])
 
+def _handlebundle2part(self, part):
+if part.type == 'changegroup':
+cgstream = part
+version = part.params.get('version', '01')
+legalcgvers = changegroup.supportedincomingversions(self)
+if version not in legalcgvers:
+msg = _('Unsupported changegroup version: %s')
+raise error.Abort(msg % version)
+if self.bundle.compressed():
+cgstream = self._writetempbundle(part.read,
+ ".cg%sun" % version)
+
+self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
+
 def _writetempbundle(self, readfn, suffix, header=''):
 """Write a temporary file to disk
 """



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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread mbolin (Michael Bolin)
mbolin requested review of this revision.
mbolin added a comment.


  @quark Rather than exposing the additional keyword argument now, why don't we 
wait until there is a compelling use-case to use something other than `~`? As 
it stands, creating an API for this would just open things up to misuse.

REPOSITORY
  rHG Mercurial

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

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


D450: filemerge: add wctx to all internal tools

2017-08-23 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1211.
phillco edited the summary of this revision.
phillco retitled this revision from "filemerge: pass `wctx` to all internal 
merge tool functions" to "filemerge: add wctx to all internal tools".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D450?vs=1084=1211

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

AFFECTED FILES
  contrib/phabricator.py
  mercurial/filemerge.py
  mercurial/tagmerge.py

CHANGE DETAILS

diff --git a/mercurial/tagmerge.py b/mercurial/tagmerge.py
--- a/mercurial/tagmerge.py
+++ b/mercurial/tagmerge.py
@@ -216,7 +216,7 @@
 # whole list of lr nodes
 return lrnodes + hrnodes[commonidx:]
 
-def merge(repo, fcd, fco, fca):
+def merge(repo, wctx, fcd, fco, fca):
 '''
 Merge the tags of two revisions, taking into account the base tags
 Try to minimize the diff between the merged tags and the first parent tags
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -250,7 +250,7 @@
 util.writefile(file, newdata)
 
 @internaltool('prompt', nomerge)
-def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iprompt(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Asks the user which of the local `p1()` or the other `p2()` version to
 keep as the merged version."""
 ui = repo.ui
@@ -275,26 +275,26 @@
 choice = ['local', 'other', 'unresolved'][index]
 
 if choice == 'other':
-return _iother(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
labels)
 elif choice == 'local':
-return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ilocal(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
labels)
 elif choice == 'unresolved':
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   labels)
 except error.ResponseExpected:
 ui.write("\n")
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   labels)
 
 @internaltool('local', nomerge)
-def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ilocal(repo, wtcx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the local `p1()` version of files as the merged version."""
 return 0, fcd.isabsent()
 
 @internaltool('other', nomerge)
-def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the other `p2()` version of files as the merged version."""
 if fco.isabsent():
 # local changed, remote deleted -- 'deleted' picked
@@ -306,7 +306,7 @@
 return 0, deleted
 
 @internaltool('fail', nomerge)
-def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """
 Rather than attempting to merge files that were modified on both
 branches, it marks them as unresolved. The resolve command must be
@@ -374,7 +374,8 @@
 return False
 return True
 
-def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
+def _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files, labels,
+   mode):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
@@ -392,32 +393,35 @@
   _("warning: conflicts while merging %s! "
 "(edit, then use 'hg resolve --mark')\n"),
   precheck=_mergecheck)
-def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _iunion(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will use both left and right sides for conflict regions.
 No markers are inserted."""
-return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
+return _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
   files, labels, 'union')
 
 @internaltool('merge', fullmerge,
   _("warning: conflicts while merging %s! "
 "(edit, then use 'hg resolve --mark')\n"),
   precheck=_mergecheck)
-def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _imerge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for 

D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread quark (Jun Wu)
quark requested changes to this revision.
quark added a comment.
This revision now requires changes to proceed.


  Back to you to add the keyword argument.

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread quark (Jun Wu)
quark added a comment.


  In https://phab.mercurial-scm.org/D468#7833, @smf wrote:
  
  > Basically, I'd like a more unified approach for all types of temp files 
(commit message, histedit, conflicts, etc).
  
  
  I think this patch is about low-level `util` function that shouldn't be 
coupled with `ui` or config. It has value on its own and I don't think such 
"unified approach" should block this patch - we can always add configs and make 
callers of `util.mktempcopy` pass `suffix` down here AFTER this patch.

INLINE COMMENTS

> util.py:1517
>  
>  def mktempcopy(name, emptyok=False, createmode=None):
>  """Create a temporary file with the same contents from name

Could you make `suffix` a keyword argument here, default to `~`?

Therefore we can give callsite control about what extension it wants.

> util.py:1528
>  d, fn = os.path.split(name)
> -fd, temp = tempfile.mkstemp(prefix='.%s-' % fn, dir=d)
> +fd, temp = tempfile.mkstemp(prefix='.%s-' % fn, suffix='~', dir=d)
>  os.close(fd)

And use `suffix=suffix` here.

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread smf (Sean Farley)
smf added a comment.


  In https://phab.mercurial-scm.org/D468#7748, @durin42 wrote:
  
  > I don't object to this, but maybe others do. Reviewers not on vacation, 
please feel encouraged to push this.
  
  
  Well, I had some objections on the mailing list. It's sad that those don't 
show up in phabricator. Basically, I'd like a more unified approach for all 
types of temp files (commit message, histedit, conflicts, etc).

REPOSITORY
  rHG Mercurial

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

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


D358: copytrace: move fb extension to core under flag experimental.fastcopytrace

2017-08-23 Thread pulkit (Pulkit Goyal)
pulkit abandoned this revision.
pulkit added a comment.


  There is work ongoing on improving copytrace in fb-hgext. I will resend 
patches with updated copytrace logic once the work is done.

REPOSITORY
  rHG Mercurial

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

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


D494: test-casecollision-merge: fix the test

2017-08-23 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  https://phab.mercurial-scm.org/D30 makes the error message unpredictable, 
therefore the fix.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-casecollision-merge.t

CHANGE DETAILS

diff --git a/tests/test-casecollision-merge.t b/tests/test-casecollision-merge.t
--- a/tests/test-casecollision-merge.t
+++ b/tests/test-casecollision-merge.t
@@ -144,7 +144,7 @@
   $ hg commit -m '#4'
 
   $ hg merge
-  abort: case-folding collision between a and A
+  abort: case-folding collision between [aA] and [Aa] (re)
   [255]
   $ hg parents --template '{rev}\n'
   4
@@ -157,7 +157,7 @@
   $ hg update --clean 2
   1 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ hg merge
-  abort: case-folding collision between a and A
+  abort: case-folding collision between [aA] and [Aa] (re)
   [255]
   $ hg parents --template '{rev}\n'
   2
@@ -327,7 +327,7 @@
   $ hg status
   A B
   $ hg update
-  abort: case-folding collision between b and B
+  abort: case-folding collision between [bB] and [Bb] (re)
   [255]
 
   $ hg update --check



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


D288: bundlerepo: move temp bundle creation to a separate function

2017-08-23 Thread krbullock (Kevin Bullock)
krbullock added inline comments.

INLINE COMMENTS

> martinvonz wrote in bundlerepo.py:322
> I think we usually use a "fn" prefix for function arguments. I think "readfn" 
> would be clearer.

I agree, but as it is, this is simple code movement. Usually we like renames to 
be done in separate changes. Updating the docstring as @indygreg suggests is 
appropriate, though.

REPOSITORY
  rHG Mercurial

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

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


D422: mdiff: add a --ignore-space-at-eol option

2017-08-23 Thread akushner (Aaron Kushner)
akushner added a comment.


  @martinvonz  - a reasonable first pass would be to whitelist known 
contributors for CI runs.

REPOSITORY
  rHG Mercurial

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

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


D493: dirstate: perform transactions with _copymap using single call, where possible

2017-08-23 Thread mbolin (Michael Bolin)
mbolin updated this revision to Diff 1209.
mbolin added a comment.


  Minor fix.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D493?vs=1208=1209

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -406,13 +406,15 @@
 
 # Discard 'm' markers when moving away from a merge state
 if s[0] == 'm':
-if f in self._copymap:
-copies[f] = self._copymap[f]
+source = self._copymap.get(f)
+if source:
+copies[f] = source
 self.normallookup(f)
 # Also fix up otherparent markers
 elif s[0] == 'n' and s[2] == -2:
-if f in self._copymap:
-copies[f] = self._copymap[f]
+source = self._copymap.get(f)
+if source:
+copies[f] = source
 self.add(f)
 return copies
 
@@ -518,8 +520,7 @@
 self._copymap[dest] = source
 self._updatedfiles.add(source)
 self._updatedfiles.add(dest)
-elif dest in self._copymap:
-del self._copymap[dest]
+elif self._copymap.pop(dest, None):
 self._updatedfiles.add(dest)
 
 def copied(self, file):
@@ -568,8 +569,7 @@
 mtime = s.st_mtime
 self._addpath(f, 'n', s.st_mode,
   s.st_size & _rangemask, mtime & _rangemask)
-if f in self._copymap:
-del self._copymap[f]
+self._copymap.pop(f, None)
 if f in self._nonnormalset:
 self._nonnormalset.remove(f)
 if mtime > self._lastnormaltime:
@@ -597,8 +597,7 @@
 if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
 return
 self._addpath(f, 'n', 0, -1, -1)
-if f in self._copymap:
-del self._copymap[f]
+self._copymap.pop(f, None)
 if f in self._nonnormalset:
 self._nonnormalset.remove(f)
 
@@ -613,15 +612,12 @@
 else:
 # add-like
 self._addpath(f, 'n', 0, -2, -1)
-
-if f in self._copymap:
-del self._copymap[f]
+self._copymap.pop(f, None)
 
 def add(self, f):
 '''Mark a file added.'''
 self._addpath(f, 'a', 0, -1, -1)
-if f in self._copymap:
-del self._copymap[f]
+self._copymap.pop(f, None)
 
 def remove(self, f):
 '''Mark a file removed.'''
@@ -638,8 +634,8 @@
 self._otherparentset.add(f)
 self._map[f] = dirstatetuple('r', 0, size, 0)
 self._nonnormalset.add(f)
-if size == 0 and f in self._copymap:
-del self._copymap[f]
+if size == 0:
+self._copymap.pop(f, None)
 
 def merge(self, f):
 '''Mark a file merged.'''
@@ -655,8 +651,7 @@
 del self._map[f]
 if f in self._nonnormalset:
 self._nonnormalset.remove(f)
-if f in self._copymap:
-del self._copymap[f]
+self._copymap.pop(f, None)
 
 def _discoverpath(self, path, normed, ignoremissing, exists, storemap):
 if exists is None:



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


D493: dirstate: perform transactions with _copymap using single call, where possible

2017-08-23 Thread mbolin (Michael Bolin)
mbolin created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This replaces patterns such as this:
  
if f in self._copymap:
del self._copymap[f]
  
  with this:
  
self._copymap.pop(f, None)
  
  Although eliminating the extra lookup/call may be a negligible performance win
  in the standard dirstate, alternative implementations, such as
  sqldirstate 

  may see a bigger win where each of these calls results in an RPC,
  so the savings is greater.

TEST PLAN
  `make tests`

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -406,13 +406,15 @@
 
 # Discard 'm' markers when moving away from a merge state
 if s[0] == 'm':
-if f in self._copymap:
-copies[f] = self._copymap[f]
+source = self._copymap.get(f)
+if source:
+copies[f] = source
 self.normallookup(f)
 # Also fix up otherparent markers
 elif s[0] == 'n' and s[2] == -2:
+source = self._copymap.get(f)
 if f in self._copymap:
-copies[f] = self._copymap[f]
+copies[f] = source
 self.add(f)
 return copies
 
@@ -518,8 +520,7 @@
 self._copymap[dest] = source
 self._updatedfiles.add(source)
 self._updatedfiles.add(dest)
-elif dest in self._copymap:
-del self._copymap[dest]
+elif self._copymap.pop(dest, None):
 self._updatedfiles.add(dest)
 
 def copied(self, file):
@@ -568,8 +569,7 @@
 mtime = s.st_mtime
 self._addpath(f, 'n', s.st_mode,
   s.st_size & _rangemask, mtime & _rangemask)
-if f in self._copymap:
-del self._copymap[f]
+self._copymap.pop(f, None)
 if f in self._nonnormalset:
 self._nonnormalset.remove(f)
 if mtime > self._lastnormaltime:
@@ -597,8 +597,7 @@
 if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
 return
 self._addpath(f, 'n', 0, -1, -1)
-if f in self._copymap:
-del self._copymap[f]
+self._copymap.pop(f, None)
 if f in self._nonnormalset:
 self._nonnormalset.remove(f)
 
@@ -613,15 +612,12 @@
 else:
 # add-like
 self._addpath(f, 'n', 0, -2, -1)
-
-if f in self._copymap:
-del self._copymap[f]
+self._copymap.pop(f, None)
 
 def add(self, f):
 '''Mark a file added.'''
 self._addpath(f, 'a', 0, -1, -1)
-if f in self._copymap:
-del self._copymap[f]
+self._copymap.pop(f, None)
 
 def remove(self, f):
 '''Mark a file removed.'''
@@ -638,8 +634,8 @@
 self._otherparentset.add(f)
 self._map[f] = dirstatetuple('r', 0, size, 0)
 self._nonnormalset.add(f)
-if size == 0 and f in self._copymap:
-del self._copymap[f]
+if size == 0:
+self._copymap.pop(f, None)
 
 def merge(self, f):
 '''Mark a file merged.'''
@@ -655,8 +651,7 @@
 del self._map[f]
 if f in self._nonnormalset:
 self._nonnormalset.remove(f)
-if f in self._copymap:
-del self._copymap[f]
+self._copymap.pop(f, None)
 
 def _discoverpath(self, path, normed, ignoremissing, exists, storemap):
 if exists is None:



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


D422: mdiff: add a --ignore-space-at-eol option

2017-08-23 Thread quark (Jun Wu)
quark requested changes to this revision.
quark added a comment.
This revision now requires changes to proceed.


  Maybe we should set up CI on Phabricator.

REPOSITORY
  rHG Mercurial

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

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


D289: bundle2: seek part back during iteration

2017-08-23 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> bundle2.py:811
> +# code consuming this generator has a part that starts at 0.
>  part.seek(0, 2)
> +part.seek(0)

Unrelated to this patch, but seems like we should define constants for 
"whence". I don't think seek(0, 2) is clear at all.

REPOSITORY
  rHG Mercurial

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

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


D288: bundlerepo: move temp bundle creation to a separate function

2017-08-23 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> bundlerepo.py:322
>  
> +def _writetempbundle(self, read, suffix, header=''):
> +"""Write a temporary file to disk

I think we usually use a "fn" prefix for function arguments. I think "readfn" 
would be clearer.

REPOSITORY
  rHG Mercurial

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

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


D422: mdiff: add a --ignore-space-at-eol option

2017-08-23 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  
  
  In https://phab.mercurial-scm.org/D422#7797, @martinvonz wrote:
  
  > In https://phab.mercurial-scm.org/D422#7795, @martinvonz wrote:
  >
  > > Looks like you didn't run test-help.t. I'll fix it in flight, but please 
run all tests next time.
  >
  >
  > ...and test-completion.t and test-qrecord.t
  
  
  ...and test-record.t and test-duplicateoptions.py. This is getting a bit too 
many, especially since the last one is not trivial, so please send an update 
instead.

REPOSITORY
  rHG Mercurial

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

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


D422: mdiff: add a --ignore-space-at-eol option

2017-08-23 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D422#7795, @martinvonz wrote:
  
  > Looks like you didn't run test-help.t. I'll fix it in flight, but please 
run all tests next time.
  
  
  ...and test-completion.t and test-qrecord.t

REPOSITORY
  rHG Mercurial

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

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


D422: mdiff: add a --ignore-space-at-eol option

2017-08-23 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  Looks like you didn't run test-help.t. I'll fix it in flight, but please run 
all tests next time.

REPOSITORY
  rHG Mercurial

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

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


Re: Handling path conflicts

2017-08-23 Thread Mark Thomas
On 23/08/2017, 15:26, "Kevin Bullock"  wrote:

> On Aug 23, 2017, at 06:05, Mark Thomas  wrote:
> 
> Hi,
>  
> I’m looking at implementing path conflict handling, as the lack of it has 
caused a few bugs, including 
https://urldefense.proofpoint.com/v2/url?u=https-3A__bz.mercurial-2Dscm.org_show-5Fbug.cgi-3Fid-3D5628=DwIFaQ=5VD0RTtNlTh3ycd41b3MUw=p_Xvja0WNU6-WnXI-KUj5w=0S-RHTt9AQit35BZMuQ_Sjd5HKOZJDbJYmXaZFvRbzM=nOrNvdZBIPCTFWlWx-xLlfbgecUs2LwfyQHIsvKSx0U=
 , and it is something that bites us here at Facebook from time to time.
>  
> I’ve written up my proposal on the wiki at 
https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_wiki_PathConflictsPlan=DwIFaQ=5VD0RTtNlTh3ycd41b3MUw=p_Xvja0WNU6-WnXI-KUj5w=0S-RHTt9AQit35BZMuQ_Sjd5HKOZJDbJYmXaZFvRbzM=Kvo5oROMET0ajRB80Tjic9SUF-Iz_kp4DMYHm7EifzU=
 .  Since I’m new to Mercurial development, I’d appreciate any comments on 
this, particularly if there’s something that I’ve missed that’s going to affect 
what I’m proposing.

Thanks for writing that up. I haven't fully read thru it yet, but one quick 
question: Are the bugs listed in that page filed in the bug tracker 
 yet? Could you cross-link them with that page for reference when you get a 
chance?

The only bug that I’m aware of (having searched Bugzilla) is #5628.  I have 
added this to the wiki page.  Once we’d found the situation listed in the bug 
report, I explored around that area to find the list of things that are wrong 
listed in the plan.

Makr.

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


D492: context: remove unnecessary default values for matchers (API)

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

REVISION SUMMARY
  ctx._dirstatestatus() is called only from workingctx._buildstatus()
  and that function, in turn, is called only from
  basectx.status(). basectx.status() will always pass a matcher to
  _buildstatus(), so there's no need to handle a None matcher there.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1747,7 +1747,6 @@
 unknown=False):
 '''Gets the status from the dirstate -- internal use only.'''
 listignored, listclean, listunknown = ignored, clean, unknown
-match = match or matchmod.always(self._repo.root, self._repo.getcwd())
 subrepos = []
 if '.hgsub' in self:
 subrepos = sorted(self.substate)
@@ -1980,7 +1979,6 @@
 Uncommitted files appear "clean" via this context, even if
 they aren't actually so in the working directory.
 """
-match = match or matchmod.always(self._repo.root, self._repo.getcwd())
 if clean:
 clean = [f for f in self._manifest if f not in self._changedset]
 else:



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


D491: context: always pass a matcher into _matchstatus() (API)

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

REVISION SUMMARY
  This just makes it a little easier to follow and removes the need to
  call the superclass's method in workingctx.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -103,12 +103,10 @@
 return self.manifest()
 
 def _matchstatus(self, other, match):
-"""return match.always if match is none
-
-This internal method provides a way for child objects to override the
+"""This internal method provides a way for child objects to override 
the
 match operator.
 """
-return match or matchmod.always(self._repo.root, self._repo.getcwd())
+return match
 
 def _buildstatus(self, other, s, match, listignored, listclean,
  listunknown):
@@ -392,6 +390,7 @@
 reversed = True
 ctx1, ctx2 = ctx2, ctx1
 
+match = match or matchmod.always(self._repo.root, self._repo.getcwd())
 match = ctx2._matchstatus(ctx1, match)
 r = scmutil.status([], [], [], [], [], [], [])
 r = ctx2._buildstatus(ctx1, r, match, listignored, listclean,
@@ -1841,8 +1840,6 @@
 If we aren't comparing against the working directory's parent, then we
 just use the default match object sent to us.
 """
-superself = super(workingctx, self)
-match = superself._matchstatus(other, match)
 if other != self._repo['.']:
 def bad(f, msg):
 # 'f' may be a directory pattern from 'match.files()',



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


D472: extensions: make wrapfunction() return a context manager

2017-08-23 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D472#7758, @quark wrote:
  
  > In https://phab.mercurial-scm.org/D472#7756, @lothiraldan wrote:
  >
  > > All users of wrapfunction will need to be updated anyway to use the 
context manager style
  >
  >
  > I think only those who use the return value of wrapfunction will need 
change (actually, new code is more correct regarding on nested wrapfunction 
handling) and expect that to be not too many. If wrapfunction is used to 
replace a function permanently, it does not need change.
  >
  > Reusing name is more consistent with `repo.transaction`, `repo.lock` and 
`open`.
  
  
  I personally don't care much which way we go here. I originally did make it a 
separate function (wrappedfunction()) and did the wrapping in __enter__, but 
I'm fine either way.

REPOSITORY
  rHG Mercurial

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

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


D477: revlog: add option to mmap revlog index

2017-08-23 Thread quark (Jun Wu)
quark added a comment.


  I think it might make sense to only apply it to manifest and changelog. 
Filelogs are usually short and probably do not need it.

REPOSITORY
  rHG Mercurial

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

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


D423: pushvars: do not mangle repo state

2017-08-23 Thread quark (Jun Wu)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG800bb35d891e: pushvars: do not mangle repo state (authored 
by quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D423?vs=1019=1203

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/exchange.py
  tests/test-pushvars.t

CHANGE DETAILS

diff --git a/tests/test-pushvars.t b/tests/test-pushvars.t
--- a/tests/test-pushvars.t
+++ b/tests/test-pushvars.t
@@ -66,5 +66,6 @@
   $ hg commit -Aqm b
   $ hg push --pushvars "DEBUG"
   pushing to $TESTTMP/repo (glob)
+  searching for changes
   abort: unable to parse variable 'DEBUG', should follow 'KEY=VALUE' or 'KEY=' 
format
   [255]
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -294,7 +294,7 @@
 """
 
 def __init__(self, repo, remote, force=False, revs=None, newbranch=False,
- bookmarks=()):
+ bookmarks=(), pushvars=None):
 # repo we push from
 self.repo = repo
 self.ui = repo.ui
@@ -352,6 +352,8 @@
 # map { pushkey partid -> callback handling failure}
 # used to handle exception from mandatory pushkey part failure
 self.pkfailcb = {}
+# an iterable of pushvars or None
+self.pushvars = pushvars
 
 @util.propertycache
 def futureheads(self):
@@ -876,10 +878,20 @@
 @b2partsgenerator('pushvars', idx=0)
 def _getbundlesendvars(pushop, bundler):
 '''send shellvars via bundle2'''
-if getattr(pushop.repo, '_shellvars', ()):
+pushvars = pushop.pushvars
+if pushvars:
+shellvars = {}
+for raw in pushvars:
+if '=' not in raw:
+msg = ("unable to parse variable '%s', should follow "
+"'KEY=VALUE' or 'KEY=' format")
+raise error.Abort(msg % raw)
+k, v = raw.split('=', 1)
+shellvars[k] = v
+
 part = bundler.newpart('pushvars')
 
-for key, value in pushop.repo._shellvars.iteritems():
+for key, value in shellvars.iteritems():
 part.addparam(key, value, mandatory=False)
 
 def _pushbundle2(pushop):
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4082,26 +4082,13 @@
 finally:
 del repo._subtoppath
 
-pushvars = opts.get('pushvars')
-if pushvars:
-shellvars = {}
-for raw in pushvars:
-if '=' not in raw:
-msg = ("unable to parse variable '%s', should follow "
-"'KEY=VALUE' or 'KEY=' format")
-raise error.Abort(msg % raw)
-k, v = raw.split('=', 1)
-shellvars[k] = v
-
-repo._shellvars = shellvars
+opargs = dict(opts.get('opargs', {})) # copy opargs since we may mutate it
+opargs.setdefault('pushvars', []).extend(opts.get('pushvars', []))
 
 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
newbranch=opts.get('new_branch'),
bookmarks=opts.get('bookmark', ()),
-   opargs=opts.get('opargs'))
-
-if pushvars:
-del repo._shellvars
+   opargs=opargs)
 
 result = not pushop.cgresult
 



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


D461: morestatus: check whether the conflict message is None before printing

2017-08-23 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe5d104c35e51: morestatus: check whether the conflict 
message is None before printing (authored by pulkit).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D461?vs=1122=1202

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-bisect.t

CHANGE DETAILS

diff --git a/tests/test-bisect.t b/tests/test-bisect.t
--- a/tests/test-bisect.t
+++ b/tests/test-bisect.t
@@ -187,7 +187,6 @@
   $ hg status -v
   # The repository is in an unfinished *bisect* state.
   
-  None
   # To mark the changeset good:hg bisect --good
   # To mark the changeset bad: hg bisect --bad
   # To abort:  hg bisect --reset
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -673,7 +673,8 @@
 statemsg = _('The repository is in an unfinished *%s* state.') % state
 fm.write('statemsg', '%s\n',  _commentlines(statemsg), label=label)
 conmsg = _conflictsmsg(repo)
-fm.write('conflictsmsg', '%s\n', conmsg, label=label)
+if conmsg:
+fm.write('conflictsmsg', '%s\n', conmsg, label=label)
 if helpfulmsg:
 helpmsg = helpfulmsg()
 fm.write('helpmsg', '%s\n', helpmsg, label=label)



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


D440: exchange: don't attempt phase exchange if phase-heads was in bundle

2017-08-23 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG13dc7f29531e: exchange: don't attempt phase exchange if 
phase-heads was in bundle (authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D440?vs=1054=1204

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/exchange.py

CHANGE DETAILS

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1401,6 +1401,10 @@
 if pullop.fetch:
 pullop.cgresult = bundle2.combinechangegroupresults(op)
 
+# If the bundle had a phase-heads part, then phase exchange is already done
+if op.records['phase-heads']:
+pullop.stepsdone.add('phases')
+
 # processing phases change
 for namespace, value in op.records['listkeys']:
 if namespace == 'phases':
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1815,6 +1815,7 @@
 """apply phases from bundle part to repo"""
 headsbyphase = _readphaseheads(inpart)
 phases.updatephases(op.repo.unfiltered(), op.gettransaction(), 
headsbyphase)
+op.records.add('phase-heads', {})
 
 @parthandler('reply:pushkey', ('return', 'in-reply-to'))
 def handlepushkeyreply(op, inpart):



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


D477: revlog: add option to mmap revlog index

2017-08-23 Thread durin42 (Augie Fackler)
durin42 requested changes to this revision.
durin42 added a comment.


  Also, please include at least one `log` invocation or similar in a test with 
the config knob set? And maybe some rough benchmark results in the commit 
message to justify the feature. :)

REPOSITORY
  rHG Mercurial

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

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


D472: extensions: make wrapfunction() return a context manager

2017-08-23 Thread quark (Jun Wu)
quark added a comment.


  In https://phab.mercurial-scm.org/D472#7756, @lothiraldan wrote:
  
  > All users of wrapfunction will need to be updated anyway to use the context 
manager style
  
  
  I think only those who use the return value of wrapfunction will need change 
(actually, new code is more correct regarding on nested wrapfunction handling) 
and expect that to be not too many. If wrapfunction is used to replace a 
function permanently, it does not need change.

REPOSITORY
  rHG Mercurial

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

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


D472: extensions: make wrapfunction() return a context manager

2017-08-23 Thread lothiraldan (Boris Feld)
lothiraldan added a comment.


  Maybe instead of replacing wrapfunction with a context manager, what about 
introducing it with a separate name? All users of wrapfunction will need to be 
updated anyway to use the context manager style

REPOSITORY
  rHG Mercurial

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

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


D468: util: use ~ as a suffix for a temp file in the same directory as a source file

2017-08-23 Thread durin42 (Augie Fackler)
durin42 accepted this revision as: durin42.
durin42 added a comment.


  I don't object to this, but maybe others do. Reviewers not on vacation, 
please feel encouraged to push this.

REPOSITORY
  rHG Mercurial

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

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


D472: extensions: make wrapfunction() return a context manager

2017-08-23 Thread quark (Jun Wu)
quark added inline comments.

INLINE COMMENTS

> mjpieters wrote in extensions.py:408-412
> Move this to `__enter__`. You want to be able to create the context manager 
> separately from actually entering the context:
> 
>   cmwrapper = wrapfunction(cont, 'name', wrapper)
>   
>   # do other things, `cont.name` is *not* wrapped
>   
>   with cmwrapper:
>   # `cont.name` is wrapped

The point is `wrapfunction` is also intended to work with non-context case:

  wrapfunction(x, y, z) # works and should have immediate side effect

REPOSITORY
  rHG Mercurial

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

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


D451: revset: remove order information from tree

2017-08-23 Thread quark (Jun Wu)
quark added a comment.


  In https://phab.mercurial-scm.org/D451#7698, @yuja wrote:
  
  > The point is these implementations would become invalid if `subset` were
  >  optimized to "any" order. That's breaking change, but which is likely to be
  >  not covered by tests.
  
  
  How about making `registrar.revsetpredicate` be conservative? If it sees any
  predicate registered with the old API, Disable `anyorder` optimization and
  change it to `followorder` in runtime?
  
  > As I said, most revset predicates have no explicit order. I introduced the
  >  order flag in order to work around a few exceptions, which are `x:y`,
  >  `x + y`, `sort()` and `reverse()`, IIRC. A strong "define" is exceptional.
  
  I feel it inconsistent if `x:y` has a strong order but `x::y` does not have.
  
  > So, is it really make sense to revamp the revset ordering rules? I don't
  >  think so. I generally like this series, but -1 for bringing "any" order
  >  everywhere.
  
  Maybe more conservative? Disable "anyorder" optimization unless:
  
  1. A config flag was set
  2. There is no user of 3-tuple registrar predicate
  
  I really like optimizations.

REPOSITORY
  rHG Mercurial

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

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


D482: bundle2: fixed usage of an attribute that was removed in py3k

2017-08-23 Thread alex.gaynor (Alex Gaynor)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8d75b9effa07: bundle2: fixed usage of an attribute that was 
removed in py3k (authored by alex.gaynor).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D482?vs=1164=1201

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

AFFECTED FILES
  mercurial/bundle2.py

CHANGE DETAILS

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -587,7 +587,7 @@
 """add a stream level parameter"""
 if not name:
 raise ValueError('empty parameter name')
-if name[0] not in string.letters:
+if name[0] not in pycompat.bytestr(string.ascii_letters):
 raise ValueError('non letter first character: %r' % name)
 self._params.append((name, value))
 
@@ -765,7 +765,7 @@
 """
 if not name:
 raise ValueError('empty parameter name')
-if name[0] not in string.letters:
+if name[0] not in pycompat.bytestr(string.ascii_letters):
 raise ValueError('non letter first character: %r' % name)
 try:
 handler = b2streamparamsmap[name.lower()]



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


D477: revlog: add option to mmap revlog index

2017-08-23 Thread indygreg (Gregory Szorc)
indygreg requested changes to this revision.
indygreg added a comment.
This revision now requires changes to proceed.


  This seems reasonable as an experimental feature.
  
  I worry about memory mapping all files without regards to size. That seems 
unnecessary.
  
  Do you know what happens with the underlying file descriptor when it is 
memory mapped? If an fd stays open, that could lead to fd exhaustion. This can 
be mitigated by only using mmap for certain files (minimize size, changelog, 
etc). It's something I'd like an answer to before this is queued.

INLINE COMMENTS

> localrepo.py:602-603
>  self.svfs.options['maxdeltachainspan'] = chainspan
> +self.svfs.options['mmapindex'] = self.ui.configbool('experimental',
> +'mmapindex')
>  

As you wrote in the commit message, the benefits of memory mapping likely kick 
in at some threshold and we'll want to make this behavior conditional on index 
size. It is tempting to implement that today to facilitate experimentation. If 
you can do that without introducing extra system calls for the default file 
open case, do it.

> revlog.py:328
>  self._maxdeltachainspan = opts['maxdeltachainspan']
> +if sys.version_info >= (2, 7) and 'mmapindex' in opts:
> +self._mmapindex = opts['mmapindex']

We only support 2.7 now. So this version sniffing can be removed.

REPOSITORY
  rHG Mercurial

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

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


D368: releasenotes: add check flag for use of admonitions and its validity

2017-08-23 Thread rishabhmadan96 (Rishabh Madan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6a49c74b1e8f: releasenotes: add check flag for use of 
admonitions and its validity (authored by rishabhmadan96).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D368?vs=973=1200#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D368?vs=973=1200

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

AFFECTED FILES
  hgext/releasenotes.py
  tests/test-releasenotes-formatting.t

CHANGE DETAILS

diff --git a/tests/test-releasenotes-formatting.t 
b/tests/test-releasenotes-formatting.t
--- a/tests/test-releasenotes-formatting.t
+++ b/tests/test-releasenotes-formatting.t
@@ -378,3 +378,32 @@
   
   * Adds a new feature.
 
+  $ cd ..
+
+Testing output for the --check (-c) flag
+
+  $ hg init check-flag
+  $ cd check-flag
+
+  $ touch a
+  $ hg -q commit -A -l - << EOF
+  > .. asf::
+  > 
+  >First paragraph under this admonition.
+  > EOF
+
+Suggest similar admonition in place of the invalid one.
+
+  $ hg releasenotes -r . -c
+  Invalid admonition 'asf' present in changeset 4026fe9e1c20
+
+  $ touch b
+  $ hg -q commit -A -l - << EOF
+  > .. fixes::
+  > 
+  >First paragraph under this admonition.
+  > EOF
+
+  $ hg releasenotes -r . -c
+  Invalid admonition 'fixes' present in changeset 0e7130d2705c
+  (did you mean fix?)
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -13,6 +13,7 @@
 
 from __future__ import absolute_import
 
+import difflib
 import errno
 import re
 import sys
@@ -242,6 +243,38 @@
 read('.hgreleasenotes')
 return p['sections']
 
+def checkadmonitions(ui, repo, directives, revs):
+"""
+Checks the commit messages for admonitions and their validity.
+
+.. abcd::
+
+   First paragraph under this admonition
+
+For this commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'abcd' present in changeset 3ea92981e103
+
+As admonition 'abcd' is neither present in default nor custom admonitions
+"""
+for rev in revs:
+ctx = repo[rev]
+admonition = re.search(RE_DIRECTIVE, ctx.description())
+if admonition:
+if admonition.group(1) in directives:
+continue
+else:
+ui.write(_("Invalid admonition '%s' present in changeset %s"
+   "\n") % (admonition.group(1), ctx.hex()[:12]))
+sim = lambda x: difflib.SequenceMatcher(None,
+admonition.group(1), x).ratio()
+
+similar = [s for s in directives if sim(s) > 0.6]
+if len(similar) == 1:
+ui.write(_("(did you mean %s?)\n") % similar[0])
+elif similar:
+ss = ", ".join(sorted(similar))
+ui.write(_("(did you mean one of %s?)\n") % ss)
+
 def parsenotesfromrevisions(repo, directives, revs):
 notes = parsedreleasenotes()
 
@@ -432,9 +465,11 @@
 return '\n'.join(lines)
 
 @command('releasenotes',
-[('r', 'rev', '', _('revisions to process for release notes'), _('REV'))],
-_('[-r REV] FILE'))
-def releasenotes(ui, repo, file_, rev=None):
+[('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
+('c', 'check', False, _('checks for validity of admonitions (if any)'),
+_('REV'))],
+_('hg releasenotes [-r REV] [-c] FILE'))
+def releasenotes(ui, repo, file_=None, **opts):
 """parse release notes from commit messages into an output file
 
 Given an output file and set of revisions, this command will parse commit
@@ -511,8 +546,12 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+rev = opts.get('rev')
 
 revs = scmutil.revrange(repo, [rev or 'not public()'])
+if opts.get('check'):
+return checkadmonitions(ui, repo, sections.names(), revs)
+
 incoming = parsenotesfromrevisions(repo, sections.names(), revs)
 
 try:



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


D482: bundle2: fixed usage of an attribute that was removed in py3k

2017-08-23 Thread lothiraldan (Boris Feld)
lothiraldan added a comment.


  Good for me.
  
  I have the impression that we tend to defined static data (like 
`pycompat.bytestr(string.ascii_letters)` or some translations) inside functions 
while they could be defined once at module level. Is it intentional, is it for 
reducing startup time?

REPOSITORY
  rHG Mercurial

BRANCH
  py3k-stuff (bookmark) on default (branch)

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

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


D368: releasenotes: add check flag for use of admonitions and its validity

2017-08-23 Thread krbullock (Kevin Bullock)
krbullock accepted this revision.
krbullock added a comment.


  Looks good, queued!

REPOSITORY
  rHG Mercurial

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

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


D476: util: add an mmapread method

2017-08-23 Thread indygreg (Gregory Szorc)
indygreg added inline comments.

INLINE COMMENTS

> simonfar wrote in util.py:413
> As per comment on https://phab.mercurial-scm.org/D477 - do we want this to be 
> raw, or `buffer(mmap.mmap(...`?

Some consumers may want file like objects. Others may want buffers.

Whatever you do, I would rename the function to what it actually does. e.g. 
``mmapfd`` or ``mmapbuffer``.

REPOSITORY
  rHG Mercurial

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

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


[PATCH 7 of 9 V4] template: compute dates in obsfatedate

2017-08-23 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499088850 -7200
#  Mon Jul 03 15:34:10 2017 +0200
# Node ID b8b8b5bd728a5fb9fa847d56dd489c77a054b5ee
# Parent  fc257b24c35c492591f348b039d9e3f9488118a8
# EXP-Topic obsfatetemplate
template: compute dates in obsfatedate

Extract the dates from obsmarkers. Compute the min and max date from the
obsmarker range list.

diff -r fc257b24c35c -r b8b8b5bd728a mercurial/obsutil.py
--- a/mercurial/obsutil.py  Mon Jul 03 15:34:00 2017 +0200
+++ b/mercurial/obsutil.py  Mon Jul 03 15:34:10 2017 +0200
@@ -587,6 +587,11 @@
 
 return sorted(users)
 
+def _markersdates(markers):
+"""returns the list of dates for a list of markers
+"""
+return [m[4] for m in markers]
+
 def successorsandmarkers(repo, ctx):
 """compute the raw data needed for computing obsfate
 Returns a list of dict, one dict per successors set
diff -r fc257b24c35c -r b8b8b5bd728a mercurial/templater.py
--- a/mercurial/templater.pyMon Jul 03 15:34:00 2017 +0200
+++ b/mercurial/templater.pyMon Jul 03 15:34:10 2017 +0200
@@ -888,6 +888,55 @@
 data = obsutil._markersusers(markers)
 return templatekw._hybrid(None, data, lambda x: x, lambda d: d)
 
+@templatefunc('obsfatedate(markers)')
+def obsfatedate(context, mapping, args):
+""" Compute obsfate related information based on markers
+
+(EXPERIMENTAL)
+"""
+if not len(args) == 1:
+# i18n: "obsfatedate" is a keyword
+raise error.ParseError(_("obsfatedate expects one arguments"))
+
+markers = evalfuncarg(context, mapping, args[0])
+if not isinstance(markers, collections.Iterable):
+# i18n: "obsfatedate" is a keyword
+errmsg = "obsfatedate first argument should be an iterable"
+raise error.ParseError(errmsg)
+
+data = obsutil._markersdates(markers)
+return templatekw._hybrid(None, data, lambda x: x, lambda d: d)
+
+@templatefunc('min(iterable)')
+def tmplmin(context, mapping, args, **kwargs):
+""" Return the min of an iterable
+"""
+if not len(args) == 1:
+# i18n: "min" is a keyword
+raise error.ParseError(_("min expects one arguments"))
+
+iterable = evalfuncarg(context, mapping, args[0])
+if not isinstance(iterable, collections.Iterable):
+# i18n: "obsfatedate" is a keyword
+raise error.ParseError(_("min first argument should be an iterable"))
+
+return min(iterable)
+
+@templatefunc('max(iterable)')
+def tmplmax(context, mapping, args, **kwargs):
+""" Return the max of an iterable
+"""
+if not len(args) == 1:
+# i18n: "max" is a keyword
+raise error.ParseError(_("max expects one arguments"))
+
+iterable = evalfuncarg(context, mapping, args[0])
+if not isinstance(iterable, collections.Iterable):
+# i18n: "obsfatedate" is a keyword
+raise error.ParseError(_("max first argument should be an iterable"))
+
+return max(iterable)
+
 @templatefunc('relpath(path)')
 def relpath(context, mapping, args):
 """Convert a repository-absolute path into a filesystem path relative to
diff -r fc257b24c35c -r b8b8b5bd728a tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t   Mon Jul 03 15:34:00 2017 +0200
+++ b/tests/test-obsmarker-template.t   Mon Jul 03 15:34:10 2017 +0200
@@ -15,7 +15,8 @@
   > obsfatesuccessors = " as {join(successors, ", ")}"
   > obsfateverb = "{obsfateverb(successors)}"
   > obsfateusers = "{if(obsfateusers(markers), " by 
{join(obsfateusers(markers), ", ")}")}"
-  > obsfate = "{obsfateverb}{obsfatesuccessors}{obsfateusers}; "
+  > obsfatedate = "{if(obsfatedate(markers), "{ifeq(min(obsfatedate(markers)), 
max(obsfatedate(markers)), " (at {min(obsfatedate(markers))|isodate})", " 
(between {min(obsfatedate(markers))|isodate} and 
{max(obsfatedate(markers))|isodate})")}")}"
+  > obsfate = "{obsfateverb}{obsfatesuccessors}{obsfateusers}{obsfatedate}; "
   > [alias]
   > tlog = log -G -T '{node|short}\
   > {if(predecessors, "\n  Predecessors: {predecessors}")}\
@@ -94,21 +95,21 @@
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/ Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
+  |/ Obsfate: rewritten as 4:d004c8f274b9 by test1, test2 (between 
2001-04-19 04:25 + and 2009-02-13 23:31 +);
   o  ea207398892e
   
   $ hg fatelog
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/ Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
+  |/ Obsfate: rewritten as 4:d004c8f274b9 by test1, test2 (between 
2001-04-19 04:25 + and 2009-02-13 23:31 +);
   o  ea207398892e
   
   $ hg fatelog -v
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/ Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
+  |/ Obsfate: rewritten as 4:d004c8f274b9 by test1, test2 (between 
2001-04-19 04:25 + and 2009-02-13 23:31 +);
   o  ea207398892e
   
   $ hg up 'desc(A1)' --hidden
@@ -131,7 +132,7 @@
   o  d004c8f274b9
   |
   | @  a468dc9b3633
-  |/ 

[PATCH 9 of 9 V4] test: add more obsmarker tests for pruning scenarios

2017-08-23 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1502986172 -7200
#  Thu Aug 17 18:09:32 2017 +0200
# Node ID 153f799f30f949735b7c1ae0d64209f83ea5baf1
# Parent  852ba8848f1cbab25b1f6cdd6574c51e16ef601e
# EXP-Topic obsfatetemplate
test: add more obsmarker tests for pruning scenarios

The obsfate output in cases of pruning is not ideal right now, add some tests
so have these scenarios around.

diff -r 852ba8848f1c -r 153f799f30f9 tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t   Mon Jul 03 17:38:56 2017 +0200
+++ b/tests/test-obsmarker-template.t   Thu Aug 17 18:09:32 2017 +0200
@@ -1643,3 +1643,138 @@
   |Obsfate: pruned by test (at 1970-01-01 00:00 +);
   o  ea207398892e
   
+Test templates with multiple pruned commits
+===
+
+Test setup
+--
+
+  $ hg init $TESTTMP/multiple-local-prune
+  $ cd $TESTTMP/multiple-local-prune
+  $ mkcommit ROOT
+  $ mkcommit A0
+  $ hg commit --amend -m "A1"
+  $ hg debugobsolete --record-parent `getid "."`
+  obsoleted 1 changesets
+
+  $ hg up -r "desc(A0)" --hidden
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg commit --amend -m "A2"
+  $ hg debugobsolete --record-parent `getid "."`
+  obsoleted 1 changesets
+
+Check output
+
+
+  $ hg up "desc(A0)" --hidden
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg tlog
+  @  471f378eab4c
+  |
+  o  ea207398892e
+  
+# todo: the obsfate output is not ideal
+  $ hg fatelog
+  @  471f378eab4c
+  |Obsfate: pruned;
+  o  ea207398892e
+  
+  $ hg fatelog -v --hidden
+  x  65b757b745b9
+  |Obsfate: pruned by test (at 1970-01-01 00:00 +);
+  | x  fdf9bde5129a
+  |/ Obsfate: pruned by test (at 1970-01-01 00:00 +);
+  | @  471f378eab4c
+  |/ Obsfate: rewritten as 2:fdf9bde5129a by test (at 1970-01-01 00:00 
+); rewritten as 3:65b757b745b9 by test (at 1970-01-01 00:00 +);
+  o  ea207398892e
+  
+
+Test templates with splitted and pruned commit
+==
+
+  $ hg init $TESTTMP/templates-local-split-prune
+  $ cd $TESTTMP/templates-local-split-prune
+  $ mkcommit ROOT
+  $ echo 42 >> a
+  $ echo 43 >> b
+  $ hg commit -A -m "A0"
+  adding a
+  adding b
+  $ hg log --hidden -G
+  @  changeset:   1:471597cad322
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: A0
+  |
+  o  changeset:   0:ea207398892e
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: ROOT
+  
+# Simulate split
+  $ hg up -r "desc(ROOT)"
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo 42 >> a
+  $ hg commit -A -m "A1"
+  adding a
+  created new head
+  $ echo 43 >> b
+  $ hg commit -A -m "A2"
+  adding b
+  $ hg debugobsolete `getid "1"` `getid "2"` `getid "3"`
+  obsoleted 1 changesets
+
+# Simulate prune
+  $ hg debugobsolete --record-parent `getid "."`
+  obsoleted 1 changesets
+
+  $ hg log --hidden -G
+  @  changeset:   3:0d0ef4bdf70e
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: A2
+  |
+  o  changeset:   2:617adc3a144c
+  |  parent:  0:ea207398892e
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: A1
+  |
+  | x  changeset:   1:471597cad322
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: A0
+  |
+  o  changeset:   0:ea207398892e
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: ROOT
+  
+Check templates
+---
+
+  $ hg up 'desc("A0")' --hidden
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+# todo: the obsfate output is not ideal
+  $ hg fatelog
+  o  617adc3a144c
+  |
+  | @  471597cad322
+  |/ Obsfate: pruned;
+  o  ea207398892e
+  
+  $ hg up -r 'desc("A2")' --hidden
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ hg fatelog --hidden
+  @  0d0ef4bdf70e
+  |Obsfate: pruned by test (at 1970-01-01 00:00 +);
+  o  617adc3a144c
+  |
+  | x  471597cad322
+  |/ Obsfate: split as 2:617adc3a144c, 3:0d0ef4bdf70e by test (at 
1970-01-01 00:00 +);
+  o  ea207398892e
+  
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 8 of 9 V4] template: better prune support in obsfate

2017-08-23 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499096336 -7200
#  Mon Jul 03 17:38:56 2017 +0200
# Node ID 852ba8848f1cbab25b1f6cdd6574c51e16ef601e
# Parent  b8b8b5bd728a5fb9fa847d56dd489c77a054b5ee
# EXP-Topic obsfatetemplate
template: better prune support in obsfate

successorssets don't returns good results for pruned commit, add a workaround
for simple cases.

A proper fix would require a large rework of successorssets algorithm, I will
send a separate series for this refactoring.

diff -r b8b8b5bd728a -r 852ba8848f1c mercurial/obsutil.py
--- a/mercurial/obsutil.py  Mon Jul 03 15:34:10 2017 +0200
+++ b/mercurial/obsutil.py  Mon Jul 03 17:38:56 2017 +0200
@@ -601,8 +601,40 @@
 
 ssets = successorssets(repo, ctx.node(), closest=True)
 
+# closestsuccessors returns an empty list for pruned revisions, remap it
+# into a list containing an empty list for future processing
+if ssets == []:
+ssets = [[]]
+
+# Try to recover pruned markers
+succsmap = repo.obsstore.successors
+fullsuccessorsets = [] # successor set + markers
+for sset in ssets:
+if sset:
+fullsuccessorsets.append(sset)
+else:
+# successorsset return an empty set() when ctx or one of its
+# successors is pruned.
+# In this case, walk the obs-markers tree again starting with ctx
+# and find the relevant pruning obs-makers, the ones without
+# successors.
+# Having these markers allow us to compute some information about
+# its fate, like who pruned this changeset and when.
+
+# XXX we do not catch all prune markers (eg rewritten then pruned)
+# (fix me later)
+foundany = False
+for mark in succsmap.get(ctx.node(), ()):
+if not mark[1]:
+foundany = True
+sset = _succs()
+sset.markers.add(mark)
+fullsuccessorsets.append(sset)
+if not foundany:
+fullsuccessorsets.append(_succs())
+
 values = []
-for sset in ssets:
+for sset in fullsuccessorsets:
 values.append({'successors': sset, 'markers': sset.markers})
 
 return values
diff -r b8b8b5bd728a -r 852ba8848f1c tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t   Mon Jul 03 15:34:10 2017 +0200
+++ b/tests/test-obsmarker-template.t   Mon Jul 03 17:38:56 2017 +0200
@@ -12,7 +12,7 @@
   > [experimental]
   > stabilization=all
   > [templates]
-  > obsfatesuccessors = " as {join(successors, ", ")}"
+  > obsfatesuccessors = "{if(successors, " as ")}{join(successors, ", ")}"
   > obsfateverb = "{obsfateverb(successors)}"
   > obsfateusers = "{if(obsfateusers(markers), " by 
{join(obsfateusers(markers), ", ")}")}"
   > obsfatedate = "{if(obsfatedate(markers), "{ifeq(min(obsfatedate(markers)), 
max(obsfatedate(markers)), " (at {min(obsfatedate(markers))|isodate})", " 
(between {min(obsfatedate(markers))|isodate} and 
{max(obsfatedate(markers))|isodate})")}")}"
@@ -165,7 +165,7 @@
   | @  a468dc9b3633
   |/ Obsfate: rewritten as 4:d004c8f274b9 by test2 (at 2001-04-19 04:25 
+);
   | x  f137d23bb3e1
-  | |
+  | |Obsfate: pruned by test1 (at 2009-02-13 23:31 +);
   | x  471f378eab4c
   |/ Obsfate: rewritten as 3:a468dc9b3633 by test1 (at 2009-02-13 23:31 
+);
   o  ea207398892e
@@ -214,7 +214,7 @@
   | x  a468dc9b3633
   |/ Obsfate: rewritten as 4:d004c8f274b9 by test2 (at 2001-04-19 04:25 
+);
   | x  f137d23bb3e1
-  | |
+  | |Obsfate: pruned by test1 (at 2009-02-13 23:31 +);
   | x  471f378eab4c
   |/ Obsfate: rewritten as 3:a468dc9b3633 by test1 (at 2009-02-13 23:31 
+);
   o  ea207398892e
@@ -225,7 +225,7 @@
   | x  a468dc9b3633
   |/ Obsfate: [{"markers": [["a468dc9b36338b14fdb7825f55ce3df4e71517ad", 
["d004c8f274b9ec480a47a93c10dac5eee63adb78"], 0, [["user", "test2"]], 
[987654321.0, 0], null]], "successors": 
["d004c8f274b9ec480a47a93c10dac5eee63adb78"]}]
   | x  f137d23bb3e1
-  | |
+  | |Obsfate: [{"markers": [["f137d23bb3e11dc1daeb6264fac9cb2433782e15", 
[], 0, [["user", "test1"]], [1234567890.0, 0], 
["471f378eab4c5e25f6c77f785b27c936efb22874"]]], "successors": []}]
   | x  471f378eab4c
   |/ Obsfate: [{"markers": [["471f378eab4c5e25f6c77f785b27c936efb22874", 
["a468dc9b36338b14fdb7825f55ce3df4e71517ad"], 0, [["user", "test1"]], 
[1234567890.0, 0], null]], "successors": 
["a468dc9b36338b14fdb7825f55ce3df4e71517ad"]}]
   o  ea207398892e
@@ -1218,7 +1218,7 @@
   o  f897c6137566
   |
   | @  471f378eab4c
-  |/
+  |/ Obsfate: pruned;
   o  ea207398892e
   
 
@@ -1635,11 +1635,11 @@
   
   $ hg fatelog
   @  471f378eab4c
-  |
+  |Obsfate: pruned by test (at 1970-01-01 00:00 +);
   o  ea207398892e
   
   $ hg fatelog -v
   @  471f378eab4c
-  |
+  |Obsfate: pruned by test (at 1970-01-01 00:00 +);
   o  ea207398892e
   

[PATCH 6 of 9 V4] template: compute user in obsfateusers

2017-08-23 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499088840 -7200
#  Mon Jul 03 15:34:00 2017 +0200
# Node ID fc257b24c35c492591f348b039d9e3f9488118a8
# Parent  8c1da4748240142e1ee62521279cf8556192c79e
# EXP-Topic obsfatetemplate
template: compute user in obsfateusers

Extract, deduplicate users informations from obs markers in order to display
them.

Print all users for the moment, we might want to display users only in verbose
mode later.

diff -r 8c1da4748240 -r fc257b24c35c mercurial/obsutil.py
--- a/mercurial/obsutil.py  Mon Jul 03 15:33:27 2017 +0200
+++ b/mercurial/obsutil.py  Mon Jul 03 15:34:00 2017 +0200
@@ -579,6 +579,14 @@
 verb = 'split'
 return verb
 
+def _markersusers(markers):
+""" Returns a sorted list of markers users without duplicates
+"""
+markersmeta = [dict(m[3]) for m in markers]
+users = set(meta.get('user') for meta in markersmeta if meta.get('user'))
+
+return sorted(users)
+
 def successorsandmarkers(repo, ctx):
 """compute the raw data needed for computing obsfate
 Returns a list of dict, one dict per successors set
diff -r 8c1da4748240 -r fc257b24c35c mercurial/templater.py
--- a/mercurial/templater.pyMon Jul 03 15:33:27 2017 +0200
+++ b/mercurial/templater.pyMon Jul 03 15:34:00 2017 +0200
@@ -7,10 +7,10 @@
 
 from __future__ import absolute_import
 
+import collections
 import os
 import re
 import types
-import collections
 
 from .i18n import _
 from . import (
@@ -869,6 +869,25 @@
 
 return obsutil._successorsetverb(successors)
 
+@templatefunc('obsfateusers(markers)')
+def obsfateusers(context, mapping, args):
+""" Compute obsfate related information based on markers
+
+(EXPERIMENTAL)
+"""
+if not len(args) == 1:
+# i18n: "obsfateusers" is a keyword
+raise error.ParseError(_("obsfateusers expects two arguments"))
+
+markers = evalfuncarg(context, mapping, args[0])
+if not isinstance(markers, collections.Iterable):
+# i18n: "obsfateusers" is a keyword
+errmsg = "obsfateusers first argument should be an iterable"
+raise error.ParseError(errmsg)
+
+data = obsutil._markersusers(markers)
+return templatekw._hybrid(None, data, lambda x: x, lambda d: d)
+
 @templatefunc('relpath(path)')
 def relpath(context, mapping, args):
 """Convert a repository-absolute path into a filesystem path relative to
diff -r 8c1da4748240 -r fc257b24c35c tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t   Mon Jul 03 15:33:27 2017 +0200
+++ b/tests/test-obsmarker-template.t   Mon Jul 03 15:34:00 2017 +0200
@@ -14,7 +14,8 @@
   > [templates]
   > obsfatesuccessors = " as {join(successors, ", ")}"
   > obsfateverb = "{obsfateverb(successors)}"
-  > obsfate = "{obsfateverb}{obsfatesuccessors}; "
+  > obsfateusers = "{if(obsfateusers(markers), " by 
{join(obsfateusers(markers), ", ")}")}"
+  > obsfate = "{obsfateverb}{obsfatesuccessors}{obsfateusers}; "
   > [alias]
   > tlog = log -G -T '{node|short}\
   > {if(predecessors, "\n  Predecessors: {predecessors}")}\
@@ -93,21 +94,21 @@
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/ Obsfate: rewritten as 4:d004c8f274b9;
+  |/ Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
   o  ea207398892e
   
   $ hg fatelog
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/ Obsfate: rewritten as 4:d004c8f274b9;
+  |/ Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
   o  ea207398892e
   
   $ hg fatelog -v
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/ Obsfate: rewritten as 4:d004c8f274b9;
+  |/ Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
   o  ea207398892e
   
   $ hg up 'desc(A1)' --hidden
@@ -130,7 +131,7 @@
   o  d004c8f274b9
   |
   | @  a468dc9b3633
-  |/ Obsfate: rewritten as 4:d004c8f274b9;
+  |/ Obsfate: rewritten as 4:d004c8f274b9 by test2;
   o  ea207398892e
   
 Predecessors template should show all the predecessors as we force their 
display
@@ -161,11 +162,11 @@
   o  d004c8f274b9
   |
   | @  a468dc9b3633
-  |/ Obsfate: rewritten as 4:d004c8f274b9;
+  |/ Obsfate: rewritten as 4:d004c8f274b9 by test2;
   | x  f137d23bb3e1
   | |
   | x  471f378eab4c
-  |/ Obsfate: rewritten as 3:a468dc9b3633;
+  |/ Obsfate: rewritten as 3:a468dc9b3633 by test1;
   o  ea207398892e
   
 
@@ -210,14 +211,13 @@
   @  d004c8f274b9
   |
   | x  a468dc9b3633
-  |/ Obsfate: rewritten as 4:d004c8f274b9;
+  |/ Obsfate: rewritten as 4:d004c8f274b9 by test2;
   | x  f137d23bb3e1
   | |
   | x  471f378eab4c
-  |/ Obsfate: rewritten as 3:a468dc9b3633;
+  |/ Obsfate: rewritten as 3:a468dc9b3633 by test1;
   o  ea207398892e
   
-
   $ hg fatelogjson --hidden
   @  d004c8f274b9
   |
@@ -319,7 +319,7 @@
   o  337fec4d2edc
   |
   | @  471597cad322
-  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a;
+  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test;
   o  ea207398892e
   
   $ hg up 

[PATCH 3 of 9 V4] obsolete: track markers in _succs

2017-08-23 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499045278 -7200
#  Mon Jul 03 03:27:58 2017 +0200
# Node ID e8087ac6f8c52088233f5d499133de7f881a0c12
# Parent  da1000201623558319d5cc9da567f6416166e982
# EXP-Topic obsfatetemplate
obsolete: track markers in _succs

We now also store markers in _succs. It will be useful for the obsfate template 
that
will use them to display more meaningful information like the list of users
that have evolved a changeset into its successors.

diff -r da1000201623 -r e8087ac6f8c5 mercurial/obsutil.py
--- a/mercurial/obsutil.py  Mon Jul 03 03:13:17 2017 +0200
+++ b/mercurial/obsutil.py  Mon Jul 03 03:27:58 2017 +0200
@@ -330,8 +330,14 @@
 class _succs(list):
 """small class to represent a successors with some metadata about it"""
 
+def __init__(self, *args, **kwargs):
+super(_succs, self).__init__(*args, **kwargs)
+self.markers = set()
+
 def copy(self):
-return _succs(self)
+new = _succs(self)
+new.markers = self.markers.copy()
+return new
 
 def successorssets(repo, initialnode, closest=False, cache=None):
 """Return set of all latest successors of initial nodes
@@ -527,13 +533,16 @@
 succssets = []
 for mark in sorted(succmarkers[current]):
 # successors sets contributed by this marker
-markss = [_succs()]
+base = _succs()
+base.markers.add(mark)
+markss = [base]
 for suc in mark[1]:
 # cardinal product with previous successors
 productresult = []
 for prefix in markss:
 for suffix in cache[suc]:
 newss = prefix.copy()
+newss.markers.update(suffix.markers)
 for part in suffix:
 # do not duplicated entry in successors set
 # first entry wins.
@@ -548,12 +557,13 @@
 candidate = sorted(((set(s), s) for s in succssets if s),
key=lambda x: len(x[1]), reverse=True)
 for setversion, listversion in candidate:
-for seenset in seen:
+for seenset, seensuccs in seen:
 if setversion.issubset(seenset):
+seensuccs.markers.update(listversion.markers)
 break
 else:
 final.append(listversion)
-seen.append(setversion)
+seen.append((setversion, listversion))
 final.reverse() # put small successors set first
 cache[current] = final
 return cache[initialnode]
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 9 V4] obsolete: introduce a _succs class

2017-08-23 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499036035 -7200
#  Mon Jul 03 00:53:55 2017 +0200
# Node ID b689080388e11ecbfe69ca9b826a4367b6fd4384
# Parent  3cfc9070245fbaa8c4c010327f24d579a416370f
# EXP-Topic obsfatetemplate
obsolete: introduce a _succs class

It will be useful later when we will be adding markers to _succs in order to
represent a successorset with the list of markers from the root to each
successors sets. This information will be needed for the obsfate template I will
introduce.

Makes it a subclass of list so all callers will continue to work.

diff -r 3cfc9070245f -r b689080388e1 mercurial/obsutil.py
--- a/mercurial/obsutil.py  Wed Aug 16 10:44:06 2017 -0700
+++ b/mercurial/obsutil.py  Mon Jul 03 00:53:55 2017 +0200
@@ -327,6 +327,9 @@
 obsoleted.add(rev)
 return obsoleted
 
+class _succs(list):
+"""small class to represent a successors with some metadata about it"""
+
 def successorssets(repo, initialnode, closest=False, cache=None):
 """Return set of all latest successors of initial nodes
 
@@ -445,7 +448,7 @@
 # case (2): end of walk.
 if current in repo:
 # We have a valid successors.
-cache[current] = [(current,)]
+cache[current] = [_succs((current,))]
 else:
 # Final obsolete version is unknown locally.
 # Do not count that as a valid successors
@@ -521,13 +524,13 @@
 succssets = []
 for mark in sorted(succmarkers[current]):
 # successors sets contributed by this marker
-markss = [[]]
+markss = [_succs()]
 for suc in mark[1]:
 # cardinal product with previous successors
 productresult = []
 for prefix in markss:
 for suffix in cache[suc]:
-newss = list(prefix)
+newss = _succs(prefix)
 for part in suffix:
 # do not duplicated entry in successors set
 # first entry wins.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 9 V4] template: add minimal obsfate template function

2017-08-23 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1502987171 -7200
#  Thu Aug 17 18:26:11 2017 +0200
# Node ID c2702967b47010d10ee0b8cf9ee633928d4b6214
# Parent  e8087ac6f8c52088233f5d499133de7f881a0c12
# EXP-Topic obsfatetemplate
template: add minimal obsfate template function

The goal of this series is to have templates capable of displaying the
evolution of a changeset in a clean and human-readable way.

Add the succsandmarkers template return successors and markers so it can be
used separately like this:

> {succsandmarkers % "{get(succsandmarkers, "markers")|json};"}

The following patches will add template functions that takes successors and
markers as inputs and compute various obsfate fields from them.

diff -r e8087ac6f8c5 -r c2702967b470 mercurial/obsutil.py
--- a/mercurial/obsutil.py  Mon Jul 03 03:27:58 2017 +0200
+++ b/mercurial/obsutil.py  Thu Aug 17 18:26:11 2017 +0200
@@ -567,3 +567,18 @@
 final.reverse() # put small successors set first
 cache[current] = final
 return cache[initialnode]
+
+def successorsandmarkers(repo, ctx):
+"""compute the raw data needed for computing obsfate
+Returns a list of dict, one dict per successors set
+"""
+if not ctx.obsolete():
+return None
+
+ssets = successorssets(repo, ctx.node(), closest=True)
+
+values = []
+for sset in ssets:
+values.append({'successors': sset, 'markers': sset.markers})
+
+return values
diff -r e8087ac6f8c5 -r c2702967b470 mercurial/templatekw.py
--- a/mercurial/templatekw.py   Mon Jul 03 03:27:58 2017 +0200
+++ b/mercurial/templatekw.py   Thu Aug 17 18:26:11 2017 +0200
@@ -18,6 +18,7 @@
 encoding,
 error,
 hbisect,
+node as nodemod,
 obsutil,
 patch,
 pycompat,
@@ -662,6 +663,50 @@
 return _hybrid(gen(data), data, lambda x: {'successorset': x},
lambda d: d["successorset"])
 
+@templatekeyword("succsandmarkers")
+def showsuccsandmarkers(repo, ctx, **args):
+"""Returns a list of dict for each final successor of ctx.
+
+The dict contains successors node id in "successors" keys and the list of
+obs-markers from ctx to the set of successors in "markers"
+
+(EXPERIMENTAL)
+"""
+
+values = obsutil.successorsandmarkers(repo, ctx)
+
+if values is None:
+values = []
+
+# Format successors and markers to avoid exposing binary to templates
+hex = nodemod.hex
+
+data = []
+for i in values:
+# Format successors
+successors = i['successors']
+
+successors = [hex(n) for n in successors]
+successors = _hybrid(None, successors,
+ lambda x: {'ctx': repo[x], 'revcache': {}},
+ lambda d: _formatrevnode(d['ctx']))
+
+# Format markers
+finalmarkers = []
+for m in i['markers']:
+hexprec = hex(m[0])
+hexsucs = tuple(hex(n) for n in m[1])
+hexparents = None
+if m[5] is not None:
+hexparents = tuple(hex(n) for n in m[5])
+newmarker = (hexprec, hexsucs) + m[2:5] + (hexparents,) + m[6:]
+finalmarkers.append(newmarker)
+
+data.append({'successors': successors, 'markers': finalmarkers})
+
+f = _showlist('succsandmarkers', data, args)
+return _hybrid(f, data, lambda x: x, lambda d: d)
+
 @templatekeyword('p1rev')
 def showp1rev(repo, ctx, templ, **args):
 """Integer. The repository-local revision number of the changeset's
diff -r e8087ac6f8c5 -r c2702967b470 tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t   Mon Jul 03 03:27:58 2017 +0200
+++ b/tests/test-obsmarker-template.t   Thu Aug 17 18:26:11 2017 +0200
@@ -11,6 +11,9 @@
   > publish=False
   > [experimental]
   > stabilization=all
+  > [templates]
+  > obsfatesuccessors = " as {join(successors, ", ")}"
+  > obsfate = "rewritten{obsfatesuccessors}; "
   > [alias]
   > tlog = log -G -T '{node|short}\
   > {if(predecessors, "\n  Predecessors: {predecessors}")}\
@@ -20,6 +23,8 @@
   > {if(successorssets, "\n  Successors: {successorssets}")}\
   > {if(successorssets, "\n  multi-line: {join(successorssets, "\n  
multi-line: ")}")}\
   > {if(successorssets, "\n  json: {successorssets|json}")}\n'
+  > fatelog = log -G -T '{node|short}\n{if(succsandmarkers, "  Obsfate: 
{succsandmarkers % "{obsfate}"} \n" )}'
+  > fatelogjson = log -G -T '{node|short}\n{if(succsandmarkers, "  Obsfate: 
{succsandmarkers|json}\n")}'
   > EOF
 
 Test templates on amended commit
@@ -33,8 +38,8 @@
   $ mkcommit ROOT
   $ mkcommit A0
   $ echo 42 >> A0
-  $ hg commit --amend -m "A1"
-  $ hg commit --amend -m "A2"
+  $ HGUSER=test1 hg commit --amend -m "A1" --config 
devel.default-date="1234567890 0"
+  $ HGUSER=test2 hg commit --amend -m "A2" --config 
devel.default-date="987654321 0"
 
   $ hg log --hidden -G
   @  changeset:   4:d004c8f274b9
@@ -83,6 +88,27 @@
   | 

[PATCH 2 of 9 V4] obsolete: add an explicit '_succs.copy()' method

2017-08-23 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499044397 -7200
#  Mon Jul 03 03:13:17 2017 +0200
# Node ID da1000201623558319d5cc9da567f6416166e982
# Parent  b689080388e11ecbfe69ca9b826a4367b6fd4384
# EXP-Topic obsfatetemplate
obsolete: add an explicit '_succs.copy()' method

Mimic the standard API for copying in the _succs class, it makes the code
slightly cleaner and will be needed later for copying markers at the same time
than copying the list content.

diff -r b689080388e1 -r da1000201623 mercurial/obsutil.py
--- a/mercurial/obsutil.py  Mon Jul 03 00:53:55 2017 +0200
+++ b/mercurial/obsutil.py  Mon Jul 03 03:13:17 2017 +0200
@@ -330,6 +330,9 @@
 class _succs(list):
 """small class to represent a successors with some metadata about it"""
 
+def copy(self):
+return _succs(self)
+
 def successorssets(repo, initialnode, closest=False, cache=None):
 """Return set of all latest successors of initial nodes
 
@@ -530,7 +533,7 @@
 productresult = []
 for prefix in markss:
 for suffix in cache[suc]:
-newss = _succs(prefix)
+newss = prefix.copy()
 for part in suffix:
 # do not duplicated entry in successors set
 # first entry wins.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D482: bundle2: fixed usage of an attribute that was removed in py3k

2017-08-23 Thread durin42 (Augie Fackler)
durin42 added a comment.


  In https://phab.mercurial-scm.org/D482#7640, @lothiraldan wrote:
  
  > Would it be possible to define `pycompat.bytestr(string.ascii_letters)` at 
the module level once and for all?
  
  
  I think I'd bias against this, just because it's only used in six or so 
places and pycompat is already getting kind of shaggy.

REPOSITORY
  rHG Mercurial

BRANCH
  py3k-stuff (bookmark) on default (branch)

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

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


Re: [PATCH 3 of 3] drawdag: port to python 3

2017-08-23 Thread Augie Fackler

> On Aug 23, 2017, at 10:57 AM, Augie Fackler  wrote:
> 
> # HG changeset patch
> # User Augie Fackler 
> # Date 1503465796 14400
> #  Wed Aug 23 01:23:16 2017 -0400
> # Node ID 4be5cef7bafa1d216668b2bbdd3d3b8074c30d26
> # Parent  de96681ea4cc716967307ccfdb7c4a1684c14f50
> drawdag: port to python 3

This is *almost* correct, but I can’t figure out what I’ve got wrong. The 
included doctests all pass on Python 2 and fail on Python 3, so you can see the 
failing example with

python3 -m doctest tests/drawdag.py

Jun, if you could take a glance at this it’d help a lot - I think it’s 
something simple that I’ve overlooked.

Thanks!

> 
> diff --git a/tests/drawdag.py b/tests/drawdag.py
> --- a/tests/drawdag.py
> +++ b/tests/drawdag.py
> @@ -92,6 +92,7 @@ from mercurial import (
> error,
> node,
> obsolete,
> +pycompat,
> registrar,
> scmutil,
> tags as tagsmod,
> @@ -100,9 +101,9 @@ from mercurial import (
> cmdtable = {}
> command = registrar.command(cmdtable)
> 
> -_pipechars = '\\/+-|'
> -_nonpipechars = ''.join(chr(i) for i in xrange(33, 127)
> -if chr(i) not in _pipechars)
> +_pipechars = b'\\/+-|'
> +_nonpipechars = b''.join(pycompat.bytechr(i) for i in range(33, 127)
> +if pycompat.bytechr(i) not in _pipechars)
> 
> def _isname(ch):
> """char -> bool. return True if ch looks like part of a name, False
> @@ -163,16 +164,16 @@ def _parseasciigraph(text):
> """(int, int) -> char. give a coordinate, return the char. return a
> space for anything out of range"""
> if x < 0 or y < 0:
> -return ' '
> +return b' '
> try:
> -return lines[y][x]
> +return lines[y][x:x + 1] or b' '
> except IndexError:
> -return ' '
> +return b' '
> 
> def getname(y, x):
> """(int, int) -> str. like get(y, x) but concatenate left and right
> parts. if name is an 'o', try to replace it to the right"""
> -result = ''
> +result = b''
> for i in itertools.count(0):
> ch = get(y, x - i)
> if not _isname(ch):
> @@ -183,17 +184,17 @@ def _parseasciigraph(text):
> if not _isname(ch):
> break
> result += ch
> -if result == 'o':
> +if result == b'o':
> # special handling, find the name to the right
> -result = ''
> +result = b''
> for i in itertools.count(2):
> ch = get(y, x + i)
> -if ch == ' ' or ch in _pipechars:
> +if ch == b' ' or ch in _pipechars:
> if result or x + i >= len(lines[y]):
> break
> else:
> result += ch
> -return result or 'o'
> +return result or b'o'
> return result
> 
> def parents(y, x):
> @@ -209,19 +210,19 @@ def _parseasciigraph(text):
> if '-' (or '+') is not in excepted, and get(y, x) is '-' (or '+'),
> the next line (y + 1, x) will be checked instead."""
> ch = get(y, x)
> -if any(ch == c and c not in expected for c in '-+'):
> +if any(ch == c and c not in expected for c in b'-+'):
> y += 1
> return follow(y + 1, x, expected)
> -if ch in expected or ('o' in expected and _isname(ch)):
> +if ch in expected or (b'o' in expected and _isname(ch)):
> visit.append((y, x))
> 
> #  -o-  # starting point:
> #  /|\ # follow '-' (horizontally), and '/|\' (to the bottom)
> -follow(y + 1, x, '|')
> -follow(y + 1, x - 1, '/')
> -follow(y + 1, x + 1, '\\')
> -follow(y, x - 1, '-')
> -follow(y, x + 1, '-')
> +follow(y + 1, x, b'|')
> +follow(y + 1, x - 1, b'/')
> +follow(y + 1, x + 1, b'\\')
> +follow(y, x - 1, b'-')
> +follow(y, x + 1, b'-')
> 
> while visit:
> y, x = visit.pop()
> @@ -232,28 +233,28 @@ def _parseasciigraph(text):
> if _isname(ch):
> result.append(getname(y, x))
> continue
> -elif ch == '|':
> -follow(y + 1, x, '/|o')
> -follow(y + 1, x - 1, '/')
> -follow(y + 1, x + 1, '\\')
> -elif ch == '+':
> -follow(y, x - 1, '-')
> -follow(y, x + 1, '-')
> -follow(y + 1, x - 1, '/')
> -follow(y + 1, x + 1, '\\')
> -follow(y + 1, x, '|')
> -elif ch == '\\':
> -follow(y + 1, x + 1, '\\|o')
> -elif ch == '/':
> -follow(y + 1, x - 1, '/|o')
> -elif ch == '-':
> -follow(y, x - 1, '-+o')
> -follow(y, x + 1, '-+o')
> +elif ch 

  1   2   >