D913: test-globalopts: make the test compatible with chg

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


  `--traceback` turns on traceback printing. This means chg does not do what is 
expected.
  
  To unblock the test, we can explicitly document that chg is broken here:
  
#if chg
BROKEN: --traceback does not show --config errors.
   ...
#else
   ...
#endif

REPOSITORY
  rHG Mercurial

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

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


D915: test-devel-warnings: make the test compatible with chg

2017-10-02 Thread quark (Jun Wu)
quark added inline comments.

INLINE COMMENTS

> test-devel-warnings.t:119-150
> +   */mercurial/dispatch.py:81   in run (glob)
> +   */mercurial/dispatch.py:163  in dispatch (glob)
> +   */mercurial/dispatch.py:303  in _runcatch (glob)
> +   */mercurial/dispatch.py:311  in _callcatch (glob)
> +   */mercurial/scmutil.py:151   in callcatch (glob)
> +   */mercurial/dispatch.py:293  in _runcatchfunc (glob)
> +   */mercurial/dispatch.py:929  in _dispatch (glob)

Maybe use `*` so line numbers change won't cause the test to fail.

REPOSITORY
  rHG Mercurial

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

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


D918: test-revlog-mmapindex: be compatible with chg

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

REVISION SUMMARY
  The test misses an explicit flush().

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-revlog-mmapindex.t

CHANGE DETAILS

diff --git a/tests/test-revlog-mmapindex.t b/tests/test-revlog-mmapindex.t
--- a/tests/test-revlog-mmapindex.t
+++ b/tests/test-revlog-mmapindex.t
@@ -9,11 +9,12 @@
   > util,
   > )
   > 
-  > def mmapread(orig, fp):
-  > print "mmapping %s" % fp.name
-  > return orig(fp)
+  > def extsetup(ui):
+  > def mmapread(orig, fp):
+  > ui.write("mmapping %s\n" % fp.name)
+  > ui.flush()
+  > return orig(fp)
   > 
-  > def extsetup(ui):
   > extensions.wrapfunction(util, 'mmapread', mmapread)
   > EOF
 



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


D917: eol: make [eol] config section sensitive for chg confighash

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

REVISION SUMMARY
  The eol extension may mangle the [eol] config section and that means chg is
  unable to detect config file change (because it re-applies setconfig
  changes).
  
  This makes test-eol.t pass with chg.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/eol.py

CHANGE DETAILS

diff --git a/hgext/eol.py b/hgext/eol.py
--- a/hgext/eol.py
+++ b/hgext/eol.py
@@ -97,6 +97,7 @@
 import re
 from mercurial.i18n import _
 from mercurial import (
+chgserver,
 config,
 error as errormod,
 extensions,
@@ -295,7 +296,8 @@
   "win32text extension\n"))
 except KeyError:
 pass
-
+# make [eol] sensitive for chg confighash
+chgserver._configsections.append('eol')
 
 def reposetup(ui, repo):
 uisetup(repo.ui)



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


D915: test-devel-warnings: make the test compatible with chg

2017-10-02 Thread singhsrb (Saurabh Singh)
singhsrb added inline comments.

INLINE COMMENTS

> test-devel-warnings.t:102
>devel-warn: "wlock" acquired after "lock" at:
> -   */hg:* in * (glob)
> +   */hg:* in  (glob)
> */mercurial/dispatch.py:* in run (glob)

Fixed this to be consistent with the rest of the test

REPOSITORY
  rHG Mercurial

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

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


D915: test-devel-warnings: make the test compatible with chg

2017-10-02 Thread singhsrb (Saurabh Singh)
singhsrb created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The test fails when run with the "--chg" option. Therefore, this
  commit makes it compatible with chg.

TEST PLAN
  Ran the test "test-devel-warnings' with and without the "--chg"
  option

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-devel-warnings.t

CHANGE DETAILS

diff --git a/tests/test-devel-warnings.t b/tests/test-devel-warnings.t
--- a/tests/test-devel-warnings.t
+++ b/tests/test-devel-warnings.t
@@ -96,9 +96,10 @@
   > EOF
   $ hg buggylocking
   devel-warn: "wlock" acquired after "lock" at: $TESTTMP/buggylocking.py:* 
(buggylocking) (glob)
+#if no-chg
   $ hg buggylocking --traceback
   devel-warn: "wlock" acquired after "lock" at:
-   */hg:* in * (glob)
+   */hg:* in  (glob)
*/mercurial/dispatch.py:* in run (glob)
*/mercurial/dispatch.py:* in dispatch (glob)
*/mercurial/dispatch.py:* in _runcatch (glob)
@@ -111,6 +112,43 @@
*/mercurial/dispatch.py:* in  (glob)
*/mercurial/util.py:* in check (glob)
$TESTTMP/buggylocking.py:* in buggylocking (glob)
+#else
+  $ hg buggylocking --traceback
+  devel-warn: "wlock" acquired after "lock" at:
+   */hg:* in  (glob)
+   */mercurial/dispatch.py:81   in run (glob)
+   */mercurial/dispatch.py:163  in dispatch (glob)
+   */mercurial/dispatch.py:303  in _runcatch (glob)
+   */mercurial/dispatch.py:311  in _callcatch (glob)
+   */mercurial/scmutil.py:151   in callcatch (glob)
+   */mercurial/dispatch.py:293  in _runcatchfunc (glob)
+   */mercurial/dispatch.py:929  in _dispatch (glob)
+   */mercurial/dispatch.py:691  in runcommand (glob)
+   */mercurial/dispatch.py:937  in _runcommand (glob)
+   */mercurial/dispatch.py:926  in  (glob)
+   */mercurial/util.py:1180 in check (glob)
+   */mercurial/commands.py:4641 in serve (glob)
+   */mercurial/server.py:106in runservice (glob)
+   */mercurial/commandserver.py:470 in run (glob)
+   */mercurial/commandserver.py:511 in _mainloop (glob)
+   */mercurial/commandserver.py:547 in _runworker (glob)
+   */mercurial/commandserver.py:368 in _serverequest (glob)
+   */mercurial/commandserver.py:292 in serve (glob)
+   */mercurial/commandserver.py:267 in serveone (glob)
+   */mercurial/chgserver.py:439 in runcommand (glob)
+   */mercurial/commandserver.py:250 in runcommand (glob)
+   */mercurial/dispatch.py:163  in dispatch (glob)
+   */mercurial/dispatch.py:303  in _runcatch (glob)
+   */mercurial/dispatch.py:311  in _callcatch (glob)
+   */mercurial/scmutil.py:151   in callcatch (glob)
+   */mercurial/dispatch.py:293  in _runcatchfunc (glob)
+   */mercurial/dispatch.py:929  in _dispatch (glob)
+   */mercurial/dispatch.py:691  in runcommand (glob)
+   */mercurial/dispatch.py:937  in _runcommand (glob)
+   */mercurial/dispatch.py:926  in  (glob)
+   */mercurial/util.py:1180 in check (glob)
+   $TESTTMP/buggylocking.py:12   in buggylocking
+#endif
   $ hg properlocking
   $ hg nowaitlocking
 
@@ -135,6 +173,7 @@
   devel-warn: foorbar is deprecated, go shopping
   (compatibility will be dropped after Mercurial-42.1337, update your code.) 
at: $TESTTMP/buggylocking.py:* (oldanddeprecated) (glob)
 
+#if no-chg
   $ hg oldanddeprecated --traceback
   devel-warn: foorbar is deprecated, go shopping
   (compatibility will be dropped after Mercurial-42.1337, update your code.) 
at:
@@ -151,6 +190,47 @@
*/mercurial/dispatch.py:* in  (glob)
*/mercurial/util.py:* in check (glob)
$TESTTMP/buggylocking.py:* in oldanddeprecated (glob)
+#else
+  $ hg oldanddeprecated --traceback
+  devel-warn: foorbar is deprecated, go shopping
+  (compatibility will be dropped after Mercurial-42.1337, update your code.) 
at:
+   */hg:* in  (glob)
+   */mercurial/dispatch.py:81   in run (glob)
+   */mercurial/dispatch.py:163  in dispatch (glob)
+   */mercurial/dispatch.py:303  in _runcatch (glob)
+   */mercurial/dispatch.py:311  in _callcatch (glob)
+   */mercurial/scmutil.py:151   in callcatch (glob)
+   */mercurial/dispatch.py:293  in _runcatchfunc (glob)
+   */mercurial/dispatch.py:929  in _dispatch (glob)
+   */mercurial/dispatch.py:691  in runcommand (glob)
+   */mercurial/dispatch.py:937  in _runcommand (glob)
+   */mercurial/dispatch.py:926  in  (glob)
+   */mercurial/util.py:1180 in check (glob)
+   */mercurial/commands.py:4641 in serve (glob)
+   */mercurial/server.py:106in runservice (glob)
+   */mercurial/commandserver.py:470 in run (glob)
+   */mercurial/commandserver.py:511 in _mainloop (glob)
+   */mercurial/commandserver.py:547 in _runworker (glob)
+   */mercurial/commandserver.py:368 in _serverequest (glob)
+   */mercurial/commandserver.py:292 in serve (glob)
+   */mercurial/commandserver.py:267 in serveone (glob)
+   

D914: test-logtoprocess: make it chg compatible

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

REVISION SUMMARY
  chg runs more commands and outputs more lines. This patch matches them.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/run-tests.py
  tests/test-logtoprocess.t

CHANGE DETAILS

diff --git a/tests/test-logtoprocess.t b/tests/test-logtoprocess.t
--- a/tests/test-logtoprocess.t
+++ b/tests/test-logtoprocess.t
@@ -45,18 +45,23 @@
   
   
   
+   (chg !)
   0
   a message: spam
   command
+  command (chg !)
   commandfinish
   foo
   foo
   foo
   foo
   foo exited 0 after * seconds (glob)
   logtoprocess command output:
+  logtoprocess command output: (chg !)
   logtoprocess commandfinish output:
   logtoprocess foo output:
+  serve --cmdserver chgunix * (glob) (chg !)
+  serve --cmdserver chgunix * (glob) (chg !)
   spam
 
 Confirm that logging blocked time catches stdio properly:
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -595,7 +595,7 @@
 # list in group 2, and the preceeding line output in group 1:
 #
 #   output..output (feature !)\n
-optline = re.compile(b'(.+) \((.+?) !\)\n$')
+optline = re.compile(b'(.*) \((.+?) !\)\n$')
 
 def cdatasafe(data):
 """Make a string safe to include in a CDATA block.



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


D913: test-globalopts: make the test compatible with chg

2017-10-02 Thread singhsrb (Saurabh Singh)
singhsrb created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The test fails when run with the '--chg' option. Therefore, this
  commit modifies the test to make it compatible with chg.

TEST PLAN
  Ran 'test-globalopts.t' with and without the '--chg' option.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-globalopts.t

CHANGE DETAILS

diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -263,8 +263,10 @@
 
 Testing --traceback:
 
-  $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback'
-  Traceback (most recent call last):
+chg only outputs the line corresponding to the abort. Therefore, for
+compatibility with chg, only testing the last line.
+  $ hg --cwd c --config x --traceback id 2>&1 | tail -n 1
+  abort: malformed --config option: 'x' (use --config section.name=value)
 
 Testing --time:
 



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


D912: test-alias: make it compatible with chg

2017-10-02 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/rHGad1bdea43965ec3d14d6a343bbec4e289208949c 
(dispatch: defer environment variable resolution in alias commands
  (BC), 2016-05-06) made environment variables lazily resolved. But after
  https://phab.mercurial-scm.org/D805 (alias: make alias command lazily 
resolved 2017-09-23), alias
  resolution happened after uisetup, which breaks the test for chg.
  
  `uisetup` is known to behave different in chg. Let's add a condition to
  match chg's output.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-alias.t

CHANGE DETAILS

diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -541,7 +541,8 @@
   > EOF
 
   $ COUNT=1 hg showcount
-  2
+  1 (chg !)
+  2 (no-chg !)
 
 This should show id:
 



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


D911: test-pager: make it work with chg

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

REVISION SUMMARY
  chg's runpager implementation is different. It behaves differently for the
  "shell=False, command not found" case.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-pager.t

CHANGE DETAILS

diff --git a/tests/test-pager.t b/tests/test-pager.t
--- a/tests/test-pager.t
+++ b/tests/test-pager.t
@@ -195,6 +195,7 @@
   paged! 'summary: modify a 8\n'
   paged! '\n'
 
+#if no-chg
 An invalid pager command name is reported sensibly if we don't have to
 use shell=True in the subprocess call:
   $ hg log --limit 3 --config pager.pager=this-command-better-never-exist
@@ -215,6 +216,17 @@
   date:Thu Jan 01 00:00:00 1970 +
   summary: modify a 8
   
+#else
+Currently, chg has its own runpager implementation, which does not show the
+"missing pager" message. The error message is globed out since the shell could
+print different message.
+  $ hg log --limit 3 --config pager.pager=this-command-better-never-exist
+  /bin/sh: this-command-better-never-exist: command not found (?)
+  * (glob) (?)
+  killed!
+  [255]
+
+#endif
 
 A complicated pager command gets worse behavior. Bonus points if you can
 improve this.



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


D782: merge: improve error messages for path conflicts during update

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2359.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D782?vs=2218=2359

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

AFFECTED FILES
  mercurial/merge.py
  tests/test-merge1.t
  tests/test-pathconflicts-basic.t
  tests/test-update-names.t

CHANGE DETAILS

diff --git a/tests/test-update-names.t b/tests/test-update-names.t
--- a/tests/test-update-names.t
+++ b/tests/test-update-names.t
@@ -50,7 +50,7 @@
   $ hg st
   ? name/file
   $ hg up 1
-  name: untracked file differs
+  name: untracked directory conflicts with file
   abort: untracked files in working directory differ from files in requested 
revision
   [255]
   $ cd ..
diff --git a/tests/test-pathconflicts-basic.t b/tests/test-pathconflicts-basic.t
--- a/tests/test-pathconflicts-basic.t
+++ b/tests/test-pathconflicts-basic.t
@@ -37,7 +37,7 @@
   $ mkdir a
   $ echo 3 > a/b
   $ hg up file
-  a: untracked file differs
+  a: untracked directory conflicts with file
   abort: untracked files in working directory differ from files in requested 
revision
   [255]
   $ hg up --clean file
diff --git a/tests/test-merge1.t b/tests/test-merge1.t
--- a/tests/test-merge1.t
+++ b/tests/test-merge1.t
@@ -30,7 +30,7 @@
 
   $ mkdir b && touch b/nonempty
   $ hg up
-  b: untracked file differs
+  b: untracked directory conflicts with file
   abort: untracked files in working directory differ from files in requested 
revision
   [255]
   $ hg ci
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -741,13 +741,23 @@
 actions[f] = ('g', (fl2, True), "remote created")
 
 for f in sorted(abortconflicts):
-repo.ui.warn(_("%s: untracked file differs\n") % f)
+warn = repo.ui.warn
+if f in pathconflicts:
+if repo.wvfs.isfileorlink(f):
+warn(_("%s: untracked file conflicts with directory\n") % f)
+else:
+warn(_("%s: untracked directory conflicts with file\n") % f)
+else:
+warn(_("%s: untracked file differs\n") % f)
 if abortconflicts:
 raise error.Abort(_("untracked files in working directory "
 "differ from files in requested revision"))
 
 for f in sorted(warnconflicts):
-repo.ui.warn(_("%s: replacing untracked file\n") % f)
+if repo.wvfs.isfileorlink(f):
+repo.ui.warn(_("%s: replacing untracked file\n") % f)
+else:
+repo.ui.warn(_("%s: replacing untracked files in directory\n") % f)
 
 for f, (m, args, msg) in actions.iteritems():
 if m == 'c':



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


D785: context: also consider path conflicts when clearing unknown files

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2362.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D785?vs=2221=2362

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

AFFECTED FILES
  mercurial/context.py
  tests/test-pathconflicts-basic.t

CHANGE DETAILS

diff --git a/tests/test-pathconflicts-basic.t b/tests/test-pathconflicts-basic.t
--- a/tests/test-pathconflicts-basic.t
+++ b/tests/test-pathconflicts-basic.t
@@ -35,6 +35,7 @@
   [1]
   $ hg update --clean .
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ rm a~853701544ac3
 
 Basic update - local directory conflicts with remote file
 
@@ -46,13 +47,19 @@
   abort: untracked files in working directory differ from files in requested 
revision
   [255]
   $ hg up --clean file
-  abort: *: '$TESTTMP/repo/a' (glob)
-  [255]
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark file)
+
+Repo state is ok
 
-Repo is in a very bad state now - recover manually
-
-  $ rm -r a
-  $ hg up -q --clean 0
+  $ hg sum
+  parent: 1:853701544ac3 
+   file
+  branch: default
+  bookmarks: *file
+  commit: (clean)
+  update: 2 new changesets (update)
+  phases: 4 draft
 
 Basic update - untracked file conflicts with remote directory
 
@@ -62,6 +69,9 @@
   a: replacing untracked file
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (activating bookmark dir)
+  $ cat a.orig
+  untracked
+  $ rm -f a.orig
 
 Basic clean update - local directory conflicts with changed remote file
 
@@ -73,11 +83,17 @@
   abort: *: '$TESTTMP/repo/a' (glob)
   [255]
   $ hg up --clean file2
-  abort: *: '$TESTTMP/repo/a' (glob)
-  [255]
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark file2)
+
+Repo state is ok
 
-Repo is in a very bad state now - recover manually
+  $ hg sum
+  parent: 2:f64e09fac717 
+   file2
+  branch: default
+  bookmarks: *file2
+  commit: (clean)
+  update: 1 new changesets, 2 branch heads (merge)
+  phases: 4 draft
 
-  $ rm -r a
-  $ hg up -q --clean 0
-
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1971,8 +1971,13 @@
 ``write()`` can be called successfully.
 """
 wvfs = self._repo.wvfs
-if wvfs.isdir(self._path) and not wvfs.islink(self._path):
-wvfs.removedirs(self._path)
+f = self._path
+if wvfs.isdir(f) and not wvfs.islink(f):
+wvfs.rmtree(f, forcibly=True)
+for p in reversed(list(util.finddirs(f))):
+if wvfs.isfileorlink(p):
+wvfs.unlink(p)
+break
 
 def setflags(self, l, x):
 self._repo.wvfs.setflags(self._path, l, x)



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


D861: commands: tidy up merge state decoding in resolve

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2365.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D861?vs=2223=2365

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4268,23 +4268,26 @@
 fm = ui.formatter('resolve', opts)
 ms = mergemod.mergestate.read(repo)
 m = scmutil.match(repo[None], pats, opts)
+
+# Labels and keys based on merge state.  Unresolved path conflicts show
+# as 'P'.  Resolved path conflicts show as 'R', the same as normal
+# resolved conflicts.
+mergestateinfo = {
+'u': ('resolve.unresolved', 'U'),
+'r': ('resolve.resolved', 'R'),
+'pu': ('resolve.unresolved', 'P'),
+'pr': ('resolve.resolved', 'R'),
+'d': ('resolve.driverresolved', 'D'),
+}
+
 for f in ms:
 if not m(f):
 continue
 
-# Set label based on merge state.
-l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved',
-  'pu': 'unresolved', 'pr': 'resolved',
-  'd': 'driverresolved'}[ms[f]]
-
-# Set key based on merge state.  Unresolved path conflicts show
-# as 'P'.  Resolved path conflicts show as 'R', the same as normal
-# resolved conflicts.
-key = {'pu': 'P', 'pr': 'R'}.get(ms[f], ms[f].upper())
-
+label, key = mergestateinfo[ms[f]]
 fm.startitem()
-fm.condwrite(not nostatus, 'status', '%s ', key, label=l)
-fm.write('path', '%s\n', f, label=l)
+fm.condwrite(not nostatus, 'status', '%s ', key, label=label)
+fm.write('path', '%s\n', f, label=label)
 fm.end()
 return 0
 



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


D787: tests: add test for path conflicts during merge

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2364.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D787?vs=2005=2364

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

AFFECTED FILES
  tests/test-pathconflicts-merge.t

CHANGE DETAILS

diff --git a/tests/test-pathconflicts-merge.t b/tests/test-pathconflicts-merge.t
new file mode 100644
--- /dev/null
+++ b/tests/test-pathconflicts-merge.t
@@ -0,0 +1,128 @@
+  $ hg init repo
+  $ cd repo
+  $ echo base > base
+  $ hg add base
+  $ hg commit -m "base"
+  $ hg bookmark -i base
+  $ mkdir a
+  $ echo 1 > a/b
+  $ hg add a/b
+  $ hg commit -m "file"
+  $ hg bookmark -i file
+  $ echo 2 > a/b
+  $ hg commit -m "file2"
+  $ hg bookmark -i file2
+  $ hg up 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mkdir a
+  $ ln -s c a/b
+  $ hg add a/b
+  $ hg commit -m "link"
+  created new head
+  $ hg bookmark -i link
+  $ hg up 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mkdir -p a/b/c
+  $ echo 2 > a/b/c/d
+  $ hg add a/b/c/d
+  $ hg commit -m "dir"
+  created new head
+  $ hg bookmark -i dir
+
+Merge - local file conflicts with remote directory
+
+  $ hg up file
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  (activating bookmark file)
+  $ hg bookmark -i
+  $ hg merge --verbose dir
+  resolving manifests
+  a/b: path conflict - a file or link has the same name as a directory
+  the local file has been renamed to a/b~0ed027b96f31
+  resolve manually then use 'hg resolve --mark a/b'
+  moving a/b to a/b~0ed027b96f31 (glob)
+  getting a/b/c/d
+  1 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to 
abandon
+  [1]
+  $ hg status
+  M a/b/c/d
+  A a/b~0ed027b96f31
+  R a/b
+  $ hg resolve --all
+  a/b: path conflict must be resolved manually
+  $ hg forget a/b~0ed027b96f31 && rm a/b~0ed027b96f31
+  $ hg resolve --mark a/b
+  (no more unresolved files)
+  $ hg commit -m "merge file and dir (deleted file)"
+
+Merge - local symlink conflicts with remote directory
+
+  $ hg up link
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  (activating bookmark link)
+  $ hg bookmark -i
+  $ hg merge dir
+  a/b: path conflict - a file or link has the same name as a directory
+  the local file has been renamed to a/b~2ea68033e3be
+  resolve manually then use 'hg resolve --mark a/b'
+  1 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to 
abandon
+  [1]
+  $ hg status
+  M a/b/c/d
+  A a/b~2ea68033e3be
+  R a/b
+  $ hg resolve --list
+  P a/b
+  $ hg resolve --all
+  a/b: path conflict must be resolved manually
+  $ hg mv a/b~2ea68033e3be a/b.old
+  $ hg resolve --mark a/b
+  (no more unresolved files)
+  $ hg resolve --list
+  R a/b
+  $ hg commit -m "merge link and dir (renamed link)"
+
+Merge - local directory conflicts with remote file or link
+
+  $ hg up dir
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  (activating bookmark dir)
+  $ hg bookmark -i
+  $ hg merge file
+  a/b: path conflict - a file or link has the same name as a directory
+  the remote file has been renamed to a/b~0ed027b96f31
+  resolve manually then use 'hg resolve --mark a/b'
+  1 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to 
abandon
+  [1]
+  $ hg status
+  A a/b~0ed027b96f31
+  $ hg resolve --all
+  a/b: path conflict must be resolved manually
+  $ hg mv a/b~0ed027b96f31 a/b/old-b
+  $ hg resolve --mark a/b
+  (no more unresolved files)
+  $ hg commit -m "merge dir and file (move file into dir)"
+  created new head
+  $ hg merge file2
+  merging a/b/old-b and a/b to a/b/old-b
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ cat a/b/old-b
+  2
+  $ hg commit -m "merge file2 (copytrace tracked rename)"
+  $ hg merge link
+  a/b: path conflict - a file or link has the same name as a directory
+  the remote file has been renamed to a/b~2ea68033e3be
+  resolve manually then use 'hg resolve --mark a/b'
+  1 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to 
abandon
+  [1]
+  $ hg mv a/b~2ea68033e3be a/b.old
+  $ readlink a/b.old
+  c
+  $ hg resolve --mark a/b
+  (no more unresolved files)
+  $ hg commit -m "merge link (rename link)"



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


D781: merge: check for path conflicts when updating (issue5628)

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2358.
mbthomas retitled this revision from "merge: check for path conflicts when 
updating" to "merge: check for path conflicts when updating (issue5628)".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D781?vs=2217=2358

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

AFFECTED FILES
  mercurial/merge.py
  tests/test-merge1.t
  tests/test-pathconflicts-basic.t
  tests/test-update-names.t

CHANGE DETAILS

diff --git a/tests/test-update-names.t b/tests/test-update-names.t
--- a/tests/test-update-names.t
+++ b/tests/test-update-names.t
@@ -50,7 +50,8 @@
   $ hg st
   ? name/file
   $ hg up 1
-  abort: *: '$TESTTMP/r1/r2/name' (glob)
+  name: untracked file differs
+  abort: untracked files in working directory differ from files in requested 
revision
   [255]
   $ cd ..
 
diff --git a/tests/test-pathconflicts-basic.t b/tests/test-pathconflicts-basic.t
--- a/tests/test-pathconflicts-basic.t
+++ b/tests/test-pathconflicts-basic.t
@@ -37,7 +37,8 @@
   $ mkdir a
   $ echo 3 > a/b
   $ hg up file
-  abort: *: '$TESTTMP/repo/a' (glob)
+  a: untracked file differs
+  abort: untracked files in working directory differ from files in requested 
revision
   [255]
   $ hg up --clean file
   abort: *: '$TESTTMP/repo/a' (glob)
@@ -53,13 +54,9 @@
   $ hg up -q 0
   $ echo untracked > a
   $ hg up --config merge.checkunknown=warn dir
-  abort: *: '$TESTTMP/repo/a/b' (glob)
-  [255]
-
-Repo is in a very bad state now - recover manually
-
-  $ rm -f a
-  $ hg up -q --clean 0
+  a: replacing untracked file
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark dir)
 
 Basic clean update - local directory conflicts with changed remote file
 
diff --git a/tests/test-merge1.t b/tests/test-merge1.t
--- a/tests/test-merge1.t
+++ b/tests/test-merge1.t
@@ -30,17 +30,17 @@
 
   $ mkdir b && touch b/nonempty
   $ hg up
-  abort: *: '$TESTTMP/t/b' (glob)
+  b: untracked file differs
+  abort: untracked files in working directory differ from files in requested 
revision
   [255]
   $ hg ci
-  abort: last update was interrupted
-  (use 'hg update' to get a consistent checkout)
-  [255]
+  nothing changed
+  [1]
   $ hg sum
   parent: 0:538afb845929 
commit #0
   branch: default
-  commit: 1 unknown (interrupted update)
+  commit: 1 unknown (clean)
   update: 1 new changesets (update)
   phases: 2 draft
   $ rm b/nonempty
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -676,6 +676,7 @@
 choose a different action.
 """
 fileconflicts = set()
+pathconflicts = set()
 warnconflicts = set()
 abortconflicts = set()
 unknownconfig = _getcheckunknownconfig(repo, 'merge', 'checkunknown')
@@ -691,11 +692,15 @@
 if m in ('c', 'dc'):
 if _checkunknownfile(repo, wctx, mctx, f):
 fileconflicts.add(f)
+elif f not in wctx:
+path = _checkunknowndirs(repo, f)
+if path is not None:
+pathconflicts.add(path)
 elif m == 'dg':
 if _checkunknownfile(repo, wctx, mctx, f, args[0]):
 fileconflicts.add(f)
 
-allconflicts = fileconflicts
+allconflicts = fileconflicts | pathconflicts
 ignoredconflicts = set([c for c in allconflicts
 if repo.dirstate._ignore(c)])
 unknownconflicts = allconflicts - ignoredconflicts
@@ -745,8 +750,9 @@
 repo.ui.warn(_("%s: replacing untracked file\n") % f)
 
 for f, (m, args, msg) in actions.iteritems():
-backup = f in fileconflicts
 if m == 'c':
+backup = (f in fileconflicts or f in pathconflicts or
+  any(p in pathconflicts for p in util.finddirs(f)))
 flags, = args
 actions[f] = ('g', (flags, backup), msg)
 



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


D784: merge: check for path conflicts when merging (issue5628)

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2361.
mbthomas retitled this revision from "merge: check for path conflicts when 
merging" to "merge: check for path conflicts when merging (issue5628)".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D784?vs=2220=2361

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

AFFECTED FILES
  mercurial/merge.py
  tests/test-audit-path.t
  tests/test-commandserver.t
  tests/test-pathconflicts-basic.t

CHANGE DETAILS

diff --git a/tests/test-pathconflicts-basic.t b/tests/test-pathconflicts-basic.t
--- a/tests/test-pathconflicts-basic.t
+++ b/tests/test-pathconflicts-basic.t
@@ -25,11 +25,16 @@
   $ hg bookmark -i
   $ hg merge --verbose dir
   resolving manifests
+  a: path conflict - a file or link has the same name as a directory
+  the local file has been renamed to a~853701544ac3
+  resolve manually then use 'hg resolve --mark a'
+  moving a to a~853701544ac3
   getting a/b
-  abort: *: '$TESTTMP/repo/a/b' (glob)
-  [255]
+  1 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to 
abandon
+  [1]
   $ hg update --clean .
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
 Basic update - local directory conflicts with remote file
 
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -966,8 +966,12 @@
   *** runcommand up -qC 2
   *** runcommand up -qC 1
   *** runcommand merge 2
-  abort: path 'a/poisoned' traverses symbolic link 'a'
-   [255]
+  a: path conflict - a file or link has the same name as a directory
+  the local file has been renamed to a~aa04623eb0c3
+  resolve manually then use 'hg resolve --mark a'
+  1 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to 
abandon
+   [1]
   $ ls ../merge-symlink-out
 
 cache of repo.auditor should be discarded, so matcher would never traverse
diff --git a/tests/test-audit-path.t b/tests/test-audit-path.t
--- a/tests/test-audit-path.t
+++ b/tests/test-audit-path.t
@@ -103,7 +103,8 @@
   back/test
 #if symlink
   $ hg update -Cr2
-  abort: path 'back/test' traverses symbolic link 'back'
+  back: is both a file and a directory
+  abort: destination manifest contains path conflicts
   [255]
 #else
 ('back' will be a file and cause some other system specific error)
@@ -160,17 +161,24 @@
 
   $ hg up -qC 1
   $ hg merge 2
-  abort: path 'a/poisoned' traverses symbolic link 'a'
-  [255]
+  a: path conflict - a file or link has the same name as a directory
+  the local file has been renamed to a~aa04623eb0c3
+  resolve manually then use 'hg resolve --mark a'
+  1 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to 
abandon
+  [1]
 
 try rebase onto other revision: cache of audited paths should be discarded,
 and the rebase should fail (issue5628)
 
   $ hg up -qC 2
   $ hg rebase -s 2 -d 1 --config extensions.rebase=
   rebasing 2:e73c21d6b244 "file a/poisoned" (tip)
-  abort: path 'a/poisoned' traverses symbolic link 'a'
-  [255]
+  a: path conflict - a file or link has the same name as a directory
+  the local file has been renamed to a~aa04623eb0c3
+  resolve manually then use 'hg resolve --mark a'
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
   $ ls ../merge-symlink-out
 
   $ cd ..
@@ -202,16 +210,18 @@
 
   $ hg up -qC 0
   $ hg up 1
-  abort: path 'a/b' traverses symbolic link 'a'
+  a: is both a file and a directory
+  abort: destination manifest contains path conflicts
   [255]
 
 try linear update including symlinked directory and its content: paths are
 audited first by calculateupdates(), where no symlink is created so both
 'a' and 'a/b' are taken as good paths. still applyupdates() should fail.
 
   $ hg up -qC null
   $ hg up 1
-  abort: path 'a/b' traverses symbolic link 'a'
+  a: is both a file and a directory
+  abort: destination manifest contains path conflicts
   [255]
   $ ls ../update-symlink-out
 
@@ -222,7 +232,8 @@
   $ rm -f a
   $ hg up -qC 2
   $ hg up 1
-  abort: path 'a/b' traverses symbolic link 'a'
+  a: is both a file and a directory
+  abort: destination manifest contains path conflicts
   [255]
   $ ls ../update-symlink-out
 
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -851,6 +851,107 @@
 This is currently not implemented -- it's an extension point."""
 return True
 
+def _filesindirs(repo, manifest, dirs):
+"""
+Generator that yields pairs of all the files in the manifest that are found
+inside the directories listed in dirs, and which directory they are found
+in.
+"""
+for f in manifest:

D786: tests: add test for path conflicts during update

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2363.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D786?vs==2363

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

AFFECTED FILES
  tests/test-pathconflicts-update.t

CHANGE DETAILS

diff --git a/tests/test-pathconflicts-update.t 
b/tests/test-pathconflicts-update.t
new file mode 100644
--- /dev/null
+++ b/tests/test-pathconflicts-update.t
@@ -0,0 +1,141 @@
+  $ hg init repo
+  $ cd repo
+  $ echo base > base
+  $ hg add base
+  $ hg commit -m "base"
+  $ hg bookmark -i base
+  $ mkdir a
+  $ echo 1 > a/b
+  $ hg add a/b
+  $ hg commit -m "file"
+  $ hg bookmark -i file
+  $ echo 2 > a/b
+  $ hg commit -m "file2"
+  $ hg bookmark -i file2
+  $ hg up 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mkdir a
+  $ ln -s c a/b
+  $ hg add a/b
+  $ hg commit -m "link"
+  created new head
+  $ hg bookmark -i link
+  $ hg up 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mkdir -p a/b/c
+  $ echo 2 > a/b/c/d
+  $ hg add a/b/c/d
+  $ hg commit -m "dir"
+  created new head
+  $ hg bookmark -i dir
+
+Update - local file conflicts with remote directory:
+
+  $ hg up -q 0
+  $ mkdir a
+  $ echo 9 > a/b
+  $ hg up dir
+  a/b: untracked file conflicts with directory
+  abort: untracked files in working directory differ from files in requested 
revision
+  [255]
+  $ hg up dir --config merge.checkunknown=warn
+  a/b: replacing untracked file
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark dir)
+  $ cat a/b.orig
+  9
+  $ rm a/b.orig
+
+Update - local symlink conflicts with remote directory:
+
+  $ hg up -q 0
+  $ mkdir a
+  $ ln -s x a/b
+  $ hg up dir
+  a/b: untracked file conflicts with directory
+  abort: untracked files in working directory differ from files in requested 
revision
+  [255]
+  $ hg up dir --config merge.checkunknown=warn
+  a/b: replacing untracked file
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark dir)
+  $ readlink a/b.orig
+  x
+  $ rm a/b.orig
+
+Update - local directory conflicts with remote file
+
+  $ hg up -q 0
+  $ mkdir -p a/b/c
+  $ echo 9 > a/b/c/d
+  $ hg up file
+  a/b: untracked directory conflicts with file
+  abort: untracked files in working directory differ from files in requested 
revision
+  [255]
+  $ hg up file --config merge.checkunknown=warn
+  a/b: replacing untracked files in directory
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark file)
+  $ cat a/b
+  1
+  $ test -d a/b.orig
+  $ rm -rf a/b.orig
+
+Update - local directory conflicts with remote symlink
+
+  $ hg up -q 0
+  $ mkdir -p a/b/c
+  $ echo 9 > a/b/c/d
+  $ hg up link
+  a/b: untracked directory conflicts with file
+  abort: untracked files in working directory differ from files in requested 
revision
+  [255]
+  $ hg up link --config merge.checkunknown=warn
+  a/b: replacing untracked files in directory
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark link)
+  $ readlink a/b
+  c
+  $ test -d a/b.orig
+  $ rm -rf a/b.orig
+
+Update - local renamed file conflicts with remote directory
+
+  $ hg up -q 0
+  $ hg mv base a
+  $ hg status -C
+  A a
+base
+  R base
+  $ hg up --check dir
+  abort: uncommitted changes
+  [255]
+  $ hg up dir
+  a: path conflict - a file or link has the same name as a directory
+  the local file has been renamed to a~d20a80d4def3
+  resolve manually then use 'hg resolve --mark a'
+  1 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  (activating bookmark dir)
+  [1]
+  $ hg status -C
+  A a~d20a80d4def3
+base
+  R base
+  $ hg resolve --list
+  P a
+  $ hg up --clean -q 0
+
+Update clean - local directory conflicts with changed remote file
+
+  $ hg up -q file
+  $ rm a/b
+  $ mkdir a/b
+  $ echo 9 > a/b/c
+  $ hg up file2 --check --config merge.checkunknown=warn
+  abort: uncommitted changes
+  [255]
+  $ hg up file2 --clean
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark file2)
+



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


D783: util: add safename function for generating safe names to rename to

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2360.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D783?vs=2219=2360

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -26,6 +26,7 @@
 import gc
 import hashlib
 import imp
+import itertools
 import mmap
 import os
 import platform as pyplatform
@@ -3831,3 +3832,26 @@
 
 # convenient shortcut
 dst = debugstacktrace
+
+def safename(f, tag, ctx, others=None):
+"""
+Generate a name that it is safe to rename f to in the given context.
+
+f:  filename to rename
+tag:a string tag that will be included in the new name
+ctx:a context, in which the new name must not exist
+others: a set of other filenames that the new name must not be in
+
+Returns a file name of the form oldname~tag[~number] which does not exist
+in the provided context and is not in the set of other names.
+"""
+if others is None:
+others = set()
+
+fn = '%s~%s' % (f, tag)
+if fn not in ctx and fn not in others:
+return fn
+for n in itertools.count(1):
+fn = '%s~%s~%s' % (f, tag, n)
+if fn not in ctx and fn not in others:
+return fn



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


D779: merge: add _checkunknowndirs function for detecting path conflicts

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2356.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D779?vs=2215=2356

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -641,6 +641,34 @@
 and repo.dirstate.normalize(f) not in repo.dirstate
 and mctx[f2].cmp(wctx[f]))
 
+def _checkunknowndirs(repo, f):
+"""
+Look for any unknown files or directories that may have a path conflict
+with a file.  If any path prefix of the file exists as a file or link,
+then it conflicts.  If the file itself is a directory that contains any
+file that is not tracked, then it conflicts.
+
+Returns the shortest path at which a conflict occurs, or None if there is
+no conflict.
+"""
+
+# Check for path prefixes that exist as unknown files.
+for p in reversed(list(util.finddirs(f))):
+if (repo.wvfs.audit.check(p)
+and repo.wvfs.isfileorlink(p)
+and repo.dirstate.normalize(p) not in repo.dirstate):
+return p
+
+# Check if the file conflicts with a directory containing unknown files.
+if repo.wvfs.audit.check(f) and repo.wvfs.isdir(f):
+# Does the directory contain any files that are not in the dirstate?
+for p, dirs, files in repo.wvfs.walk(f):
+for fn in files:
+relf = repo.dirstate.normalize(repo.wvfs.reljoin(p, fn))
+if relf not in repo.dirstate:
+return f
+return None
+
 def _checkunknownfiles(repo, wctx, mctx, force, actions, mergeforce):
 """
 Considers any actions that care about the presence of conflicting unknown



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


D780: merge: rename conflicts to fileconflicts in _checkunknownfiles

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2357.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D780?vs=2216=2357

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -675,7 +675,7 @@
 files. For some actions, the result is to abort; for others, it is to
 choose a different action.
 """
-conflicts = set()
+fileconflicts = set()
 warnconflicts = set()
 abortconflicts = set()
 unknownconfig = _getcheckunknownconfig(repo, 'merge', 'checkunknown')
@@ -690,14 +690,15 @@
 for f, (m, args, msg) in actions.iteritems():
 if m in ('c', 'dc'):
 if _checkunknownfile(repo, wctx, mctx, f):
-conflicts.add(f)
+fileconflicts.add(f)
 elif m == 'dg':
 if _checkunknownfile(repo, wctx, mctx, f, args[0]):
-conflicts.add(f)
+fileconflicts.add(f)
 
-ignoredconflicts = set([c for c in conflicts
+allconflicts = fileconflicts
+ignoredconflicts = set([c for c in allconflicts
 if repo.dirstate._ignore(c)])
-unknownconflicts = conflicts - ignoredconflicts
+unknownconflicts = allconflicts - ignoredconflicts
 collectconflicts(ignoredconflicts, ignoredconfig)
 collectconflicts(unknownconflicts, unknownconfig)
 else:
@@ -744,7 +745,7 @@
 repo.ui.warn(_("%s: replacing untracked file\n") % f)
 
 for f, (m, args, msg) in actions.iteritems():
-backup = f in conflicts
+backup = f in fileconflicts
 if m == 'c':
 flags, = args
 actions[f] = ('g', (flags, backup), msg)



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


D775: commands: update the resolve command to handle path conflicts

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2352.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D775?vs=2211=2352

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4271,10 +4271,19 @@
 for f in ms:
 if not m(f):
 continue
+
+# Set label based on merge state.
 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved',
+  'pu': 'unresolved', 'pr': 'resolved',
   'd': 'driverresolved'}[ms[f]]
+
+# Set key based on merge state.  Unresolved path conflicts show
+# as 'P'.  Resolved path conflicts show as 'R', the same as normal
+# resolved conflicts.
+key = {'pu': 'P', 'pr': 'R'}.get(ms[f], ms[f].upper())
+
 fm.startitem()
-fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
+fm.condwrite(not nostatus, 'status', '%s ', key, label=l)
 fm.write('path', '%s\n', f, label=l)
 fm.end()
 return 0
@@ -4323,6 +4332,17 @@
 runconclude = True
 continue
 
+# path conflicts must be resolved manually
+if ms[f] in ("pu", "pr"):
+if mark:
+ms.mark(f, "pr")
+elif unmark:
+ms.mark(f, "pu")
+elif ms[f] == "pu":
+ui.warn(_('%s: path conflict must be resolved manually\n')
+% f)
+continue
+
 if mark:
 ms.mark(f, "r")
 elif unmark:



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


D778: merge: backup conflicting directories when getting files

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2355.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D778?vs=2214=2355

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1167,14 +1167,18 @@
 repo.ui.note(_("getting %s\n") % f)
 
 if backup:
+# If a file or directory exists with the same name, back that
+# up.  Otherwise, look to see if there is a file that conflicts
+# with a directory this file is in, and if so, back that up.
 absf = repo.wjoin(f)
+if not repo.wvfs.lexists(f):
+for p in util.finddirs(f):
+if repo.wvfs.isfileorlink(p):
+absf = repo.wjoin(p)
+break
 orig = scmutil.origpath(ui, repo, absf)
-try:
-if repo.wvfs.isfileorlink(f):
-util.rename(absf, orig)
-except OSError as e:
-if e.errno != errno.ENOENT:
-raise
+if repo.wvfs.lexists(absf):
+util.rename(absf, orig)
 wctx[f].clearunknown()
 wctx[f].write(fctx(f).data(), flags, backgroundclose=True)
 if i == 100:



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


D777: merge: add merge action 'pr' to rename files during update

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2354.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D777?vs=2213=2354

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

AFFECTED FILES
  mercurial/merge.py
  mercurial/sparse.py

CHANGE DETAILS

diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -487,7 +487,7 @@
 
 # Apply changes to disk
 typeactions = dict((m, [])
-   for m in 'a f g am cd dc r dm dg m e k p'.split())
+   for m in 'a f g am cd dc r dm dg m e k p pr'.split())
 for f, (m, args, msg) in actions.iteritems():
 if m not in typeactions:
 typeactions[m] = []
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1263,14 +1263,26 @@
 z += 1
 progress(_updating, z, item=f, total=numupdates, unit=_files)
 
-# remove in parallel (must come before getting)
+# remove in parallel (must come before resolving path conflicts and 
getting)
 prog = worker.worker(repo.ui, 0.001, batchremove, (repo, wctx),
  actions['r'])
 for i, item in prog:
 z += i
 progress(_updating, z, item=item, total=numupdates, unit=_files)
 removed = len(actions['r'])
 
+# resolve path conflicts (must come before getting)
+for f, args, msg in actions['pr']:
+repo.ui.debug(" %s: %s -> pr\n" % (f, msg))
+f0, = args
+if wctx[f0].lexists():
+repo.ui.note(_("moving %s to %s\n") % (f0, f))
+wctx[f].audit()
+wctx[f].write(wctx.filectx(f0).data(), wctx.filectx(f0).flags())
+wctx[f0].remove()
+z += 1
+progress(_updating, z, item=f, total=numupdates, unit=_files)
+
 # We should flush before forking into worker processes, since those workers
 # flush when they complete, and we don't want to duplicate work.
 wctx.flushall()
@@ -1443,6 +1455,17 @@
 for f, args, msg in actions.get('f', []):
 repo.dirstate.drop(f)
 
+# resolve path conflicts
+for f, args, msg in actions.get('pr', []):
+f0, = args
+origf0 = repo.dirstate.copied(f0) or f0
+repo.dirstate.add(f)
+repo.dirstate.copy(origf0, f)
+if f0 == origf0:
+repo.dirstate.remove(f0)
+else:
+repo.dirstate.drop(f0)
+
 # re-add
 for f, args, msg in actions.get('a', []):
 repo.dirstate.add(f)
@@ -1678,7 +1701,7 @@
 
 if updatecheck == 'noconflict':
 for f, (m, args, msg) in actionbyfile.iteritems():
-if m not in ('g', 'k', 'e', 'r'):
+if m not in ('g', 'k', 'e', 'r', 'pr'):
 msg = _("conflicting changes")
 hint = _("commit or update --clean to discard changes")
 raise error.Abort(msg, hint=hint)
@@ -1714,7 +1737,7 @@
 
 # Convert to dictionary-of-lists format
 actions = dict((m, [])
-   for m in 'a am f g cd dc r dm dg m e k p'.split())
+   for m in 'a am f g cd dc r dm dg m e k p pr'.split())
 for f, (m, args, msg) in actionbyfile.iteritems():
 if m not in actions:
 actions[m] = []



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


D776: merge: add merge action 'p' to record path conflicts during update

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2353.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D776?vs=2212=2353

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

AFFECTED FILES
  mercurial/merge.py
  mercurial/sparse.py

CHANGE DETAILS

diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -486,7 +486,8 @@
 dropped.append(file)
 
 # Apply changes to disk
-typeactions = dict((m, []) for m in 'a f g am cd dc r dm dg m e k'.split())
+typeactions = dict((m, [])
+   for m in 'a f g am cd dc r dm dg m e k p'.split())
 for f, (m, args, msg) in actions.iteritems():
 if m not in typeactions:
 typeactions[m] = []
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1243,12 +1243,27 @@
 wctx[f].remove()
 
 numupdates = sum(len(l) for m, l in actions.items() if m != 'k')
+z = 0
 
 if [a for a in actions['r'] if a[0] == '.hgsubstate']:
 subrepo.submerge(repo, wctx, mctx, wctx, overwrite, labels)
 
-# remove in parallel (must come first)
-z = 0
+# record path conflicts
+for f, args, msg in actions['p']:
+f1, fo = args
+s = repo.ui.status
+s(_("%s: path conflict - a file or link has the same name as a "
+"directory\n") % f)
+if fo == 'l':
+s(_("the local file has been renamed to %s\n") % f1)
+else:
+s(_("the remote file has been renamed to %s\n") % f1)
+s(_("resolve manually then use 'hg resolve --mark %s'\n") % f)
+ms.addpath(f, f1, fo)
+z += 1
+progress(_updating, z, item=f, total=numupdates, unit=_files)
+
+# remove in parallel (must come before getting)
 prog = worker.worker(repo.ui, 0.001, batchremove, (repo, wctx),
  actions['r'])
 for i, item in prog:
@@ -1698,7 +1713,8 @@
 del actionbyfile[f]
 
 # Convert to dictionary-of-lists format
-actions = dict((m, []) for m in 'a am f g cd dc r dm dg m e k'.split())
+actions = dict((m, [])
+   for m in 'a am f g cd dc r dm dg m e k p'.split())
 for f, (m, args, msg) in actionbyfile.iteritems():
 if m not in actions:
 actions[m] = []



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


D774: merge: add pathconflict merge state

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2351.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D774?vs=2210=2351

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -66,6 +66,7 @@
 C: a change/delete or delete/change conflict
 D: a file that the external merge driver will merge internally
(experimental)
+P: a path conflict (file vs directory)
 m: the external merge driver defined for this merge plus its run state
(experimental)
 f: a (filename, dictionary) tuple of optional values for a given file
@@ -79,6 +80,15 @@
 m: driver-resolved files marked -- only needs to be run before commit
 s: success/skipped -- does not need to be run any more
 
+Merge record states (stored in self._state, indexed by filename):
+u: unresolved conflict
+r: resolved conflict
+pu: unresolved path conflict (file conflicts with directory)
+pr: resolved path conflict
+d: driver-resolved conflict
+
+The resolve command transitions between 'u' and 'r' for conflicts and
+'pu' and 'pr' for path conflicts.
 '''
 statepathv1 = 'merge/state'
 statepathv2 = 'merge/state2'
@@ -158,7 +168,7 @@
 
 self._readmergedriver = bits[0]
 self._mdstate = mdstate
-elif rtype in 'FDC':
+elif rtype in 'FDCP':
 bits = record.split('\0')
 self._state[bits[0]] = bits[1:]
 elif rtype == 'f':
@@ -354,6 +364,8 @@
 for d, v in self._state.iteritems():
 if v[0] == 'd':
 records.append(('D', '\0'.join([d] + v)))
+elif v[0] in ('pu', 'pr'):
+records.append(('P', '\0'.join([d] + v)))
 # v[1] == local ('cd'), v[6] == other ('dc') -- not supported by
 # older versions of Mercurial
 elif v[1] == nullhex or v[6] == nullhex:
@@ -422,6 +434,15 @@
 self._stateextras[fd] = { 'ancestorlinknode' : hex(fca.node()) }
 self._dirty = True
 
+def addpath(self, path, frename, forigin):
+"""add a new conflicting path to the merge state
+path:the path that conflicts
+frename: the filename the conflicting file was renamed to
+forigin: origin of the file ('l' or 'r' for local/remote)
+"""
+self._state[path] = ['pu', frename, forigin]
+self._dirty = True
+
 def __contains__(self, dfile):
 return dfile in self._state
 
@@ -445,7 +466,7 @@
 """Obtain the paths of unresolved files."""
 
 for f, entry in self._state.iteritems():
-if entry[0] == 'u':
+if entry[0] in ('u', 'pu'):
 yield f
 
 def driverresolved(self):



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


D680: scmutil: handle conflicting files and dirs in origbackuppath

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas updated this revision to Diff 2350.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D680?vs=2208=2350

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

AFFECTED FILES
  mercurial/scmutil.py
  tests/test-origbackup-conflict.t

CHANGE DETAILS

diff --git a/tests/test-origbackup-conflict.t b/tests/test-origbackup-conflict.t
new file mode 100644
--- /dev/null
+++ b/tests/test-origbackup-conflict.t
@@ -0,0 +1,118 @@
+Set up repo
+
+  $ cat << EOF >> $HGRCPATH
+  > [ui]
+  > origbackuppath=.hg/origbackups
+  > [merge]
+  > checkunknown=warn
+  > EOF
+  $ hg init repo
+  $ cd repo
+  $ echo base > base
+  $ hg add base
+  $ hg commit -m "base"
+
+Make a dir named b that contains a file
+
+  $ mkdir -p b
+  $ echo c1 > b/c
+  $ hg add b/c
+  $ hg commit -m "c1"
+  $ hg bookmark c1
+
+Peform an update that causes b/c to be backed up
+
+  $ hg up -q 0
+  $ mkdir -p b
+  $ echo c2 > b/c
+  $ hg up --verbose c1
+  resolving manifests
+  b/c: replacing untracked file
+  getting b/c
+  creating directory: $TESTTMP/repo/.hg/origbackups/b
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark c1)
+  $ test -f .hg/origbackups/b/c
+
+Make a file named b
+
+  $ hg up -q 0
+  $ echo b1 > b
+  $ hg add b
+  $ hg commit -m b1
+  created new head
+  $ hg bookmark b1
+
+Perform an update that causes b to be backed up - it should replace the backup 
b dir
+
+  $ hg up -q 0
+  $ echo b2 > b
+  $ hg up --verbose b1
+  resolving manifests
+  b: replacing untracked file
+  getting b
+  removing conflicting directory: $TESTTMP/repo/.hg/origbackups/b
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark b1)
+  $ test -f .hg/origbackups/b
+
+Perform an update the causes b/c to be backed up again - it should replace the 
backup b file
+
+  $ hg up -q 0
+  $ mkdir b
+  $ echo c3 > b/c
+  $ hg up --verbose c1
+  resolving manifests
+  b/c: replacing untracked file
+  getting b/c
+  creating directory: $TESTTMP/repo/.hg/origbackups/b
+  removing conflicting file: $TESTTMP/repo/.hg/origbackups/b
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark c1)
+  $ test -d .hg/origbackups/b
+
+Cause a symlink to be backed up that points to a valid location from the 
backup dir
+
+  $ hg up -q 0
+  $ mkdir ../sym-link-target
+  $ ln -s ../../../sym-link-target b
+  $ hg up b1
+  b: replacing untracked file
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark b1)
+  $ readlink .hg/origbackups/b
+  ../../../sym-link-target
+
+Perform an update that causes b/c to be backed up again - it should not go 
into the target dir
+
+  $ hg up -q 0
+  $ mkdir b
+  $ echo c4 > b/c
+  $ hg up --verbose c1
+  resolving manifests
+  b/c: replacing untracked file
+  getting b/c
+  creating directory: $TESTTMP/repo/.hg/origbackups/b
+  removing conflicting file: $TESTTMP/repo/.hg/origbackups/b
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark c1)
+  $ cat .hg/origbackups/b/c
+  c4
+  $ ls ../sym-link-target
+
+Incorrectly configure origbackuppath to be under a file
+
+  $ echo data > .hg/badorigbackups
+  $ hg up -q 0
+  $ mkdir b
+  $ echo c5 > b/c
+  $ hg up --verbose c1 --config ui.origbackuppath=.hg/badorigbackups
+  resolving manifests
+  b/c: replacing untracked file
+  getting b/c
+  creating directory: $TESTTMP/repo/.hg/badorigbackups/b
+  abort: Not a directory: '$TESTTMP/repo/.hg/badorigbackups/b'
+  [255]
+  $ cat .hg/badorigbackups
+  data
+
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -36,6 +36,7 @@
 revsetlang,
 similar,
 util,
+vfs,
 )
 
 if pycompat.osname == 'nt':
@@ -571,18 +572,34 @@
 Fall back to default (filepath with .orig suffix) if not specified
 '''
 origbackuppath = ui.config('ui', 'origbackuppath')
-if origbackuppath is None:
+if not origbackuppath:
 return filepath + ".orig"
 
-filepathfromroot = os.path.relpath(filepath, start=repo.root)
-fullorigpath = repo.wjoin(origbackuppath, filepathfromroot)
+# Convert filepath from an absolute path into a path inside the repo.
+filepathfromroot = util.normpath(os.path.relpath(filepath,
+ start=repo.root))
+
+origvfs = vfs.vfs(repo.wjoin(origbackuppath))
+origbackupdir = origvfs.dirname(filepathfromroot)
+if not origvfs.isdir(origbackupdir) or origvfs.islink(origbackupdir):
+ui.note(_('creating directory: %s\n') % origvfs.join(origbackupdir))
 
-origbackupdir = repo.vfs.dirname(fullorigpath)
-if not repo.vfs.exists(origbackupdir):
-ui.note(_('creating directory: %s\n') % origbackupdir)
-util.makedirs(origbackupdir)
+# Remove any files that conflict with the backup file's path
+for f in 

D785: context: also consider path conflicts when clearing unknown files

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas added inline comments.

INLINE COMMENTS

> kiilerix wrote in test-pathconflicts-basic.t:38
> I don't know about these `~hash` files, but including the `+` in the name 
> definitely seems wrong.

I will strip the `+` characters.  I didn't know these caused problems on 
Windows.

REPOSITORY
  rHG Mercurial

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

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


D778: merge: backup conflicting directories when getting files

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas added inline comments.

INLINE COMMENTS

> kiilerix wrote in merge.py:1175
> This seems quite a bit slower. But I guess it never will happen in tight 
> loops? If we have to backup a lot of files, then we have lost anyway?

It will happen in `batchget`, which is for each file that is being created in 
the update.  The new loop is O(path-length), which should be small.  We should 
also only be touching things the OS needed to look at anyway to answer the 
original question, and which we looked at when we audited the path earlier on.

REPOSITORY
  rHG Mercurial

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

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


D680: scmutil: handle conflicting files and dirs in origbackuppath

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas added a comment.


  With `ui.origbackuppath` set to some value, backup should be completely 
reliable.  The file at `$origbackuppath/path/to/file` will be the most recent 
version of that file that was backed up.  It will be overwritten/deleted if a 
backup of any file named `$origbackuppath/path/to/file`, 
`$origbackuppath/path/to` or `$origbackuppath/path` is subsequently made.  This 
seems reasonable to me.
  
  If `ui.origbackuppath` not set, then behaviour is still unreliable in the 
presence of files also named `something.orig`, but that is not changed 
behaviour.  We discussed this at the sprint and decided that we didn't want to 
change the default behaviour of creating `.orig` files.

INLINE COMMENTS

> kiilerix wrote in scmutil.py:576
> Now, this seems like a separate trivial change, fixing the problem that 
> origbackuppath couldn't be overridden.

Happy to split this out, but this stack is already pretty tall.

REPOSITORY
  rHG Mercurial

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

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


D894: fsmonitor: warn when fsmonitor could be used

2017-10-02 Thread mbthomas (Mark Thomas)
mbthomas accepted this revision.
mbthomas added a comment.


  LGTM

INLINE COMMENTS

> merge.py:1739-1743
> +if fsmonitorwarning \
> +and not fsmonitorenabled \
> +and p1.node() == nullid \
> +and len(actions['g']) >= fsmonitorthreshold \
> +and pycompat.sysplatform.startswith(('linux', 'darwin')):

I'm not sure if we're planning to work towards PEP8, but it (and I) prefer 
using parentheses to break long if conditionals, rather than backslashes.

REPOSITORY
  rHG Mercurial

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

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


D907: cext: move braces for control statements to same line

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg added a comment.


  FWIW, this series stemmed from me hacking on a `.clang-format` file. I want 
the big patch where we run clang-format on the repo to be as simple as 
possible. This series (so far) is all about introducing consistency in our C 
code.

REPOSITORY
  rHG Mercurial

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

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


D910: cext: wrap before brace for functions

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is our prevailing style.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cext/manifest.c
  mercurial/cext/parsers.c
  mercurial/cext/revlog.c

CHANGE DETAILS

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -407,7 +407,8 @@
return newlist;
 }
 
-static int check_filter(PyObject *filter, Py_ssize_t arg) {
+static int check_filter(PyObject *filter, Py_ssize_t arg)
+{
if (filter) {
PyObject *arglist, *result;
int isfiltered;
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -321,7 +321,8 @@
 /*
  * Build a set of non-normal and other parent entries from the dirstate dmap
 */
-static PyObject *nonnormalotherparententries(PyObject *self, PyObject *args) {
+static PyObject *nonnormalotherparententries(PyObject *self, PyObject *args)
+{
PyObject *dmap, *fname, *v;
PyObject *nonnset = NULL, *otherpset = NULL, *result = NULL;
Py_ssize_t pos;
@@ -645,7 +646,8 @@
 }
 
 
-static PyObject *fm1readmarkers(PyObject *self, PyObject *args) {
+static PyObject *fm1readmarkers(PyObject *self, PyObject *args)
+{
const char *data, *dataend;
int datalen;
Py_ssize_t offset, stop;
diff --git a/mercurial/cext/manifest.c b/mercurial/cext/manifest.c
--- a/mercurial/cext/manifest.c
+++ b/mercurial/cext/manifest.c
@@ -40,12 +40,14 @@
 #define MANIFEST_MALFORMED -3
 
 /* get the length of the path for a line */
-static size_t pathlen(line *l) {
+static size_t pathlen(line *l)
+{
return strlen(l->start);
 }
 
 /* get the node value of a single line */
-static PyObject *nodeof(line *l) {
+static PyObject *nodeof(line *l)
+{
char *s = l->start;
ssize_t llen = pathlen(l);
PyObject *hash = unhexlify(s + llen + 1, 40);
@@ -434,7 +436,8 @@
 
 /* Do a binary search for the insertion point for new, creating the
  * new entry if needed. */
-static int internalsetitem(lazymanifest *self, line *new) {
+static int internalsetitem(lazymanifest *self, line *new)
+{
int start = 0, end = self->numlines;
while (start < end) {
int pos = start + (end - start) / 2;
@@ -602,7 +605,8 @@
 static PyTypeObject lazymanifestType;
 
 /* If the manifest has changes, build the new manifest text and reindex it. */
-static int compact(lazymanifest *self) {
+static int compact(lazymanifest *self)
+{
int i;
ssize_t need = 0;
char *data;



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


D908: cext: reorder #include

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We mostly abide by this style.
  
  In one case, a blank line was inserted to prevent a local
  `#include "file"` from coming before a `#include `.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cext/bdiff.c
  mercurial/cext/dirs.c
  mercurial/cext/manifest.c
  mercurial/cext/mpatch.c
  mercurial/cext/osutil.c
  mercurial/cext/parsers.c
  mercurial/cext/revlog.c

CHANGE DETAILS

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -13,9 +13,9 @@
 #include 
 #include 
 
+#include "bitmanipulation.h"
 #include "charencode.h"
 #include "util.h"
-#include "bitmanipulation.h"
 
 #ifdef IS_PY3K
 /* The mapping of Python types is meant to be temporary to get Python
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -12,9 +12,9 @@
 #include 
 #include 
 
+#include "bitmanipulation.h"
 #include "charencode.h"
 #include "util.h"
-#include "bitmanipulation.h"
 
 #ifdef IS_PY3K
 /* The mapping of Python types is meant to be temporary to get Python
diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c
--- a/mercurial/cext/osutil.c
+++ b/mercurial/cext/osutil.c
@@ -9,15 +9,15 @@
 
 #define _ATFILE_SOURCE
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #ifdef _WIN32
+#include 
 #include 
-#include 
 #else
 #include 
 #include 
diff --git a/mercurial/cext/mpatch.c b/mercurial/cext/mpatch.c
--- a/mercurial/cext/mpatch.c
+++ b/mercurial/cext/mpatch.c
@@ -25,10 +25,10 @@
 #include 
 #include 
 
-#include "util.h"
 #include "bitmanipulation.h"
 #include "compat.h"
 #include "mpatch.h"
+#include "util.h"
 
 static char mpatch_doc[] = "Efficient binary patching.";
 static PyObject *mpatch_Error;
diff --git a/mercurial/cext/manifest.c b/mercurial/cext/manifest.c
--- a/mercurial/cext/manifest.c
+++ b/mercurial/cext/manifest.c
@@ -9,8 +9,8 @@
 #include 
 
 #include 
+#include 
 #include 
-#include 
 
 #include "charencode.h"
 #include "util.h"
diff --git a/mercurial/cext/dirs.c b/mercurial/cext/dirs.c
--- a/mercurial/cext/dirs.c
+++ b/mercurial/cext/dirs.c
@@ -9,6 +9,7 @@
 
 #define PY_SSIZE_T_CLEAN
 #include 
+
 #include "util.h"
 
 #ifdef IS_PY3K
diff --git a/mercurial/cext/bdiff.c b/mercurial/cext/bdiff.c
--- a/mercurial/cext/bdiff.c
+++ b/mercurial/cext/bdiff.c
@@ -11,9 +11,9 @@
 
 #define PY_SSIZE_T_CLEAN
 #include 
+#include 
 #include 
 #include 
-#include 
 
 #include "bdiff.h"
 #include "bitmanipulation.h"



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


D907: cext: move braces for control statements to same line

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This seems to be the prevailing style in the code by a wide margin.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cext/base85.c
  mercurial/cext/revlog.c

CHANGE DETAILS

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -445,8 +445,7 @@
iter = PyObject_GetIter(list);
if (iter == NULL)
return -2;
-   while ((iter_item = PyIter_Next(iter)))
-   {
+   while ((iter_item = PyIter_Next(iter))) {
iter_item_long = PyInt_AS_LONG(iter_item);
Py_DECREF(iter_item);
if (iter_item_long < min_idx)
diff --git a/mercurial/cext/base85.c b/mercurial/cext/base85.c
--- a/mercurial/cext/base85.c
+++ b/mercurial/cext/base85.c
@@ -96,24 +96,21 @@
dst = PyBytes_AsString(out);
 
i = 0;
-   while (i < len)
-   {
+   while (i < len) {
acc = 0;
cap = len - i - 1;
if (cap > 4)
cap = 4;
-   for (j = 0; j < cap; i++, j++)
-   {
+   for (j = 0; j < cap; i++, j++) {
c = b85dec[(int)*text++] - 1;
if (c < 0)
return PyErr_Format(
PyExc_ValueError,
"bad base85 character at position %d",
(int)i);
acc = acc * 85 + c;
}
-   if (i++ < len)
-   {
+   if (i++ < len) {
c = b85dec[(int)*text++] - 1;
if (c < 0)
return PyErr_Format(
@@ -136,8 +133,7 @@
acc *= 85;
if (cap && cap < 4)
acc += 0xff >> (cap - 1) * 8;
-   for (j = 0; j < cap; j++)
-   {
+   for (j = 0; j < cap; j++) {
acc = (acc << 8) | (acc >> 24);
*dst++ = acc;
}



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


D909: cext: put case statements on separate line

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This seems to be the prevailing style, even though it is a bit more
  verbose for very simple switch statements.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cext/charencode.c

CHANGE DETAILS

diff --git a/mercurial/cext/charencode.c b/mercurial/cext/charencode.c
--- a/mercurial/cext/charencode.c
+++ b/mercurial/cext/charencode.c
@@ -319,13 +319,20 @@
 static char jsonescapechar2(char c)
 {
switch (c) {
-   case '\b': return 'b';
-   case '\t': return 't';
-   case '\n': return 'n';
-   case '\f': return 'f';
-   case '\r': return 'r';
-   case '"':  return '"';
-   case '\\': return '\\';
+   case '\b':
+   return 'b';
+   case '\t':
+   return 't';
+   case '\n':
+   return 'n';
+   case '\f':
+   return 'f';
+   case '\r':
+   return 'r';
+   case '"':
+   return '"';
+   case '\\':
+   return '\\';
}
return '\0';  /* should not happen */
 }



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


D906: registrar: fixing typo in comment

2017-10-02 Thread singhsrb (Saurabh Singh)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc1fe66e89f57: registrar: fixing typo in comment (authored 
by singhsrb, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D906?vs=2344=2345

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

AFFECTED FILES
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -347,7 +347,7 @@
 fullmerge   ooo
 ==   =
 
-Optional argument 'onfalure' is the format of warning message
+Optional argument 'onfailure' is the format of warning message
 to be used at failure of merging (target filename is specified
 at formatting). Or, None or so, if warning message should be
 suppressed.



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


D906: registrar: fixing typo in comment

2017-10-02 Thread singhsrb (Saurabh Singh)
singhsrb created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I was just going through the module and noticed the typo. This commit
  fixes 'onfalure' -> 'onfailure'.

TEST PLAN
  Read it again :)

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -347,7 +347,7 @@
 fullmerge   ooo
 ==   =
 
-Optional argument 'onfalure' is the format of warning message
+Optional argument 'onfailure' is the format of warning message
 to be used at failure of merging (target filename is specified
 at formatting). Or, None or so, if warning message should be
 suppressed.



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


D905: style: never put multiple statements on one line

2017-10-02 Thread alex_gaynor (Alex Gaynor)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5326e4ef1dab: style: never put multiple statements on one 
line (authored by alex_gaynor, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D905?vs=2327=2343

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

AFFECTED FILES
  mercurial/keepalive.py
  mercurial/pure/bdiff.py
  mercurial/pure/mpatch.py
  mercurial/sshserver.py
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1605,8 +1605,10 @@
 ifp.close()
 ofp.close()
 except: # re-raises
-try: os.unlink(temp)
-except OSError: pass
+try:
+os.unlink(temp)
+except OSError:
+pass
 raise
 return temp
 
diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py
--- a/mercurial/sshserver.py
+++ b/mercurial/sshserver.py
@@ -127,7 +127,8 @@
 r = impl()
 if r is not None:
 self.sendresponse(r)
-else: self.sendresponse("")
+else:
+self.sendresponse("")
 return cmd != ''
 
 def _client(self):
diff --git a/mercurial/pure/mpatch.py b/mercurial/pure/mpatch.py
--- a/mercurial/pure/mpatch.py
+++ b/mercurial/pure/mpatch.py
@@ -75,7 +75,8 @@
 # copy all the patches into our segment so we can memmove from them
 pos = b2 + bl
 m.seek(pos)
-for p in bins: m.write(p)
+for p in bins:
+m.write(p)
 
 for plen in plens:
 # if our list gets too long, execute it
diff --git a/mercurial/pure/bdiff.py b/mercurial/pure/bdiff.py
--- a/mercurial/pure/bdiff.py
+++ b/mercurial/pure/bdiff.py
@@ -60,7 +60,8 @@
 
 bin = []
 p = [0]
-for i in a: p.append(p[-1] + len(i))
+for i in a:
+p.append(p[-1] + len(i))
 
 d = difflib.SequenceMatcher(None, a, b).get_matching_blocks()
 d = _normalizeblocks(a, b, d)
diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -135,7 +135,8 @@
 del self._connmap[connection]
 del self._readymap[connection]
 self._hostmap[host].remove(connection)
-if not self._hostmap[host]: del self._hostmap[host]
+if not self._hostmap[host]:
+del self._hostmap[host]
 finally:
 self._lock.release()
 
@@ -621,7 +622,8 @@
 f = fo.readline()
 if f:
 foo = foo + f
-else: break
+else:
+break
 fo.close()
 m = md5(foo)
 print(format % ('keepalive readline', m.hexdigest()))



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


D905: style: never put multiple statements on one line

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg added subscribers: sid0, indygreg.
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  Since you weren't at the Sprint, I think the decision for style is that we'd 
check the existing wiki page for the style guide into the repo (possibly along 
with profiles/configs for various linting/reformatting tools). Then, future 
changes to style would be handled via code review.
  
  @sid0's annotation revision skipping feature is maturing and combined with 
@yuya's patches to resolve a revset from a file will allow us to check in a 
file containing a list of "reformatting" revisions to automatically/easily skip 
when doing annotate. So we should be more willing to mass rewrite code.

REPOSITORY
  rHG Mercurial

BRANCH
  style-fixes (bookmark) on default (branch)

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

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


D899: annotate: track whether a particular annotation was the result of a skip

2017-10-02 Thread sid0 (Siddharth Agarwal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG2f5a135b2b04: annotate: track whether a particular 
annotation was the result of a skip (authored by sid0, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D899?vs=2331=2341

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

AFFECTED FILES
  mercurial/context.py
  tests/test-annotate.py

CHANGE DETAILS

diff --git a/tests/test-annotate.py b/tests/test-annotate.py
--- a/tests/test-annotate.py
+++ b/tests/test-annotate.py
@@ -80,20 +80,22 @@
  diffopts)
 self.assertEqual(childann[0], [
 annotateline('old', 1),
-annotateline('old', 2),
+annotateline('old', 2, True),
+# note that this line was carried over from earlier so it is *not*
+# marked skipped
 annotateline('p2', 2),
-annotateline('p2', 2),
+annotateline('p2', 2, True),
 annotateline('p2', 3),
 ])
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p2ann, p1ann], childfctx, childann, True,
  diffopts)
 self.assertEqual(childann[0], [
 annotateline('old', 1),
-annotateline('old', 2),
+annotateline('old', 2, True),
 annotateline('p1', 3),
-annotateline('p1', 3),
+annotateline('p1', 3, True),
 annotateline('p2', 3),
 ])
 
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -,6 +,8 @@
 class annotateline(object):
 fctx = attr.ib()
 lineno = attr.ib(default=False)
+# Whether this annotation was the result of a skip-annotate.
+skip = attr.ib(default=False)
 
 def _annotatepair(parents, childfctx, child, skipchild, diffopts):
 r'''
@@ -1159,7 +1161,7 @@
 for bk in xrange(b1, b2):
 if child[0][bk].fctx == childfctx:
 ak = min(a1 + (bk - b1), a2 - 1)
-child[0][bk] = parent[0][ak]
+child[0][bk] = attr.evolve(parent[0][ak], 
skip=True)
 else:
 remaining[idx][1].append((a1, a2, b1, b2))
 
@@ -1170,7 +1172,7 @@
 for bk in xrange(b1, b2):
 if child[0][bk].fctx == childfctx:
 ak = min(a1 + (bk - b1), a2 - 1)
-child[0][bk] = parent[0][ak]
+child[0][bk] = attr.evolve(parent[0][ak], skip=True)
 return child
 
 class filectx(basefilectx):



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


D897: context: rename local 'attr' to 'attr_'

2017-10-02 Thread sid0 (Siddharth Agarwal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG52e9310626a8: context: rename local attr to 
attr_ (authored by sid0, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D897?vs=2318=2339

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

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
@@ -2420,9 +2420,9 @@
 if reusable:
 # copy extra fields from originalfctx
 attrs = ['rawdata', 'rawflags', '_filenode', '_filerev']
-for attr in attrs:
-if util.safehasattr(originalfctx, attr):
-setattr(self, attr, getattr(originalfctx, attr))
+for attr_ in attrs:
+if util.safehasattr(originalfctx, attr_):
+setattr(self, attr_, getattr(originalfctx, attr_))
 
 def data(self):
 return self._datafunc()



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


D896: annotate: move annotatepair unit tests to a separate file

2017-10-02 Thread sid0 (Siddharth Agarwal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG80215865d154: annotate: move annotatepair unit tests to a 
separate file (authored by sid0, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D896?vs=2317=2338

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

AFFECTED FILES
  mercurial/context.py
  tests/test-annotate.py

CHANGE DETAILS

diff --git a/tests/test-annotate.py b/tests/test-annotate.py
new file mode 100644
--- /dev/null
+++ b/tests/test-annotate.py
@@ -0,0 +1,75 @@
+from __future__ import absolute_import
+from __future__ import print_function
+
+import unittest
+
+from mercurial import (
+mdiff,
+)
+from mercurial.context import (
+_annotatepair,
+)
+
+class AnnotateTests(unittest.TestCase):
+"""Unit tests for annotate code."""
+
+def testannotatepair(self):
+self.maxDiff = None # camelcase-required
+
+oldfctx = b'old'
+p1fctx, p2fctx, childfctx = b'p1', b'p2', b'c'
+olddata = b'a\nb\n'
+p1data = b'a\nb\nc\n'
+p2data = b'a\nc\nd\n'
+childdata = b'a\nb2\nc\nc2\nd\n'
+diffopts = mdiff.diffopts()
+
+def decorate(text, rev):
+return ([(rev, i) for i in xrange(1, text.count(b'\n') + 1)], text)
+
+# Basic usage
+
+oldann = decorate(olddata, oldfctx)
+p1ann = decorate(p1data, p1fctx)
+p1ann = _annotatepair([oldann], p1fctx, p1ann, False, diffopts)
+self.assertEqual(p1ann[0], [('old', 1), ('old', 2), ('p1', 3)])
+
+p2ann = decorate(p2data, p2fctx)
+p2ann = _annotatepair([oldann], p2fctx, p2ann, False, diffopts)
+self.assertEqual(p2ann[0], [('old', 1), ('p2', 2), ('p2', 3)])
+
+# Test with multiple parents (note the difference caused by ordering)
+
+childann = decorate(childdata, childfctx)
+childann = _annotatepair([p1ann, p2ann], childfctx, childann, False,
+ diffopts)
+self.assertEqual(childann[0],
+[('old', 1), ('c', 2), ('p2', 2), ('c', 4), ('p2', 3)]
+)
+
+childann = decorate(childdata, childfctx)
+childann = _annotatepair([p2ann, p1ann], childfctx, childann, False,
+ diffopts)
+self.assertEqual(childann[0],
+[('old', 1), ('c', 2), ('p1', 3), ('c', 4), ('p2', 3)]
+)
+
+# Test with skipchild (note the difference caused by ordering)
+
+childann = decorate(childdata, childfctx)
+childann = _annotatepair([p1ann, p2ann], childfctx, childann, True,
+ diffopts)
+self.assertEqual(childann[0],
+[('old', 1), ('old', 2), ('p2', 2), ('p2', 2), ('p2', 3)]
+)
+
+childann = decorate(childdata, childfctx)
+childann = _annotatepair([p2ann, p1ann], childfctx, childann, True,
+ diffopts)
+self.assertEqual(childann[0],
+[('old', 1), ('old', 2), ('p1', 3), ('p1', 3), ('p2', 3)]
+)
+
+if __name__ == '__main__':
+import silenttestrunner
+silenttestrunner.main(__name__)
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1112,56 +1112,7 @@
 Additionally, if `skipchild` is True, replace all other lines with parent
 annotate data as well such that child is never blamed for any lines.
 
->>> oldfctx = b'old'
->>> p1fctx, p2fctx, childfctx = b'p1', b'p2', b'c'
->>> olddata = b'a\nb\n'
->>> p1data = b'a\nb\nc\n'
->>> p2data = b'a\nc\nd\n'
->>> childdata = b'a\nb2\nc\nc2\nd\n'
->>> diffopts = mdiff.diffopts()
-
->>> def decorate(text, rev):
-... return ([(rev, i) for i in xrange(1, text.count(b'\n') + 1)], text)
-
-Basic usage:
-
->>> oldann = decorate(olddata, oldfctx)
->>> p1ann = decorate(p1data, p1fctx)
->>> p1ann = _annotatepair([oldann], p1fctx, p1ann, False, diffopts)
->>> p1ann[0]
-[('old', 1), ('old', 2), ('p1', 3)]
->>> p2ann = decorate(p2data, p2fctx)
->>> p2ann = _annotatepair([oldann], p2fctx, p2ann, False, diffopts)
->>> p2ann[0]
-[('old', 1), ('p2', 2), ('p2', 3)]
-
-Test with multiple parents (note the difference caused by ordering):
-
->>> childann = decorate(childdata, childfctx)
->>> childann = _annotatepair([p1ann, p2ann], childfctx, childann, False,
-...  diffopts)
->>> childann[0]
-[('old', 1), ('c', 2), ('p2', 2), ('c', 4), ('p2', 3)]
-
->>> childann = decorate(childdata, childfctx)
->>> childann = _annotatepair([p2ann, p1ann], childfctx, childann, False,
-...  diffopts)
->>> childann[0]
-[('old', 1), ('c', 2), ('p1', 3), ('c', 4), ('p2', 3)]
-
-Test with skipchild (note the difference caused by ordering):
-
->>> childann = decorate(childdata, childfctx)
->>> childann 

D895: check-code: allow an exception for camelcase where required

2017-10-02 Thread sid0 (Siddharth Agarwal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb332c01247d8: check-code: allow an exception for camelcase 
where required (authored by sid0, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D895?vs=2316=2337

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

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -273,7 +273,7 @@
 #(r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=',
 # "don't use underbars in identifiers"),
 (r'^\s+(self\.)?[A-Za-z][a-z0-9]+[A-Z]\w* = ',
- "don't use camelcase in identifiers"),
+ "don't use camelcase in identifiers", r'#.*camelcase-required'),
 (r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+',
  "linebreak after :"),
 (r'class\s[^( \n]+:', "old-style class, use class foo(object)",



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


D901: changelog: use a Factory for default value for files

2017-10-02 Thread lothiraldan (Boris Feld)
lothiraldan accepted this revision.
lothiraldan added a comment.


  Looks good to me and seems coherent with what attr documentation recommends.

REPOSITORY
  rHG Mercurial

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

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


D905: style: never put multiple statements on one line

2017-10-02 Thread alex_gaynor (Alex Gaynor)
alex_gaynor added a comment.


  This, and the other style things I've sent PRs for, were discovered with 
`flake8 --select=E714,E701,E203 mercurial/`.

REPOSITORY
  rHG Mercurial

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

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


D905: style: never put multiple statements on one line

2017-10-02 Thread lothiraldan (Boris Feld)
lothiraldan added a comment.


  If the Style Czar or Style Committee agree with this change, could we add 
pylint check? The msg id for these errors is "multiple-statements (C0321)"

REPOSITORY
  rHG Mercurial

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

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


D905: style: never put multiple statements on one line

2017-10-02 Thread ryanmce (Ryan McElroy)
ryanmce accepted this revision.
ryanmce added a comment.


  This seems like a straightforward win.
  
  Is there any way we can add a check-code for this if we don't already have 
one?

REPOSITORY
  rHG Mercurial

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

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


D899: annotate: track whether a particular annotation was the result of a skip

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  Immutability is a magical property, isn't it ;)

REPOSITORY
  rHG Mercurial

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

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


D789: merge: add option to abort merge process on failure

2017-10-02 Thread ryanmce (Ryan McElroy)
ryanmce planned changes to this revision.
ryanmce added a comment.


  This doesn't actually lead to merge conflicts in the repo -- the error.Abort 
is "too strong". I need deeper surgery here.

REPOSITORY
  rHG Mercurial

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

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


D889: url: use native strings for header values

2017-10-02 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0ee9cf8d054a: url: use native strings for header values 
(authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D889?vs=2301=2336

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

AFFECTED FILES
  mercurial/url.py

CHANGE DETAILS

diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -19,6 +19,7 @@
 error,
 httpconnection as httpconnectionmod,
 keepalive,
+pycompat,
 sslutil,
 util,
 )
@@ -495,13 +496,13 @@
 # agent string for anything, clients should be able to define whatever
 # user agent they deem appropriate.
 agent = 'mercurial/proto-1.0 (Mercurial %s)' % util.version()
-opener.addheaders = [('User-agent', agent)]
+opener.addheaders = [(r'User-agent', pycompat.sysstr(agent))]
 
 # This header should only be needed by wire protocol requests. But it has
 # been sent on all requests since forever. We keep sending it for backwards
 # compatibility reasons. Modern versions of the wire protocol use
 # X-HgProto- for advertising client support.
-opener.addheaders.append(('Accept', 'application/mercurial-0.1'))
+opener.addheaders.append((r'Accept', r'application/mercurial-0.1'))
 return opener
 
 def open(ui, url_, data=None):



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


D885: httppasswordmgrdbproxy: specify exact arguments

2017-10-02 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGae2fcf7af409: httppasswordmgrdbproxy: specify exact 
arguments (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D885?vs=2297=2334

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

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -146,11 +146,11 @@
 self._mgr = urlreq.httppasswordmgrwithdefaultrealm()
 return self._mgr
 
-def add_password(self, *args, **kwargs):
-return self._get_mgr().add_password(*args, **kwargs)
+def add_password(self, realm, uris, user, passwd):
+return self._get_mgr().add_password(realm, uris, user, passwd)
 
-def find_user_password(self, *args, **kwargs):
-return self._get_mgr().find_user_password(*args, **kwargs)
+def find_user_password(self, realm, uri):
+return self._get_mgr().find_user_password(realm, uri)
 
 def _catchterm(*args):
 raise error.SignalInterrupt



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


D888: keepalive: python 3 portability tweaks

2017-10-02 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa454123f5d94: keepalive: python 3 portability tweaks 
(authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D888?vs=2300=2335

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

AFFECTED FILES
  mercurial/keepalive.py

CHANGE DETAILS

diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -92,6 +92,7 @@
 
 from .i18n import _
 from . import (
+pycompat,
 util,
 )
 
@@ -235,7 +236,8 @@
 # The string form of BadStatusLine is the status line. Add some context
 # to make the error message slightly more useful.
 except httplib.BadStatusLine as err:
-raise urlerr.urlerror(_('bad HTTP status line: %s') % err.line)
+raise urlerr.urlerror(
+_('bad HTTP status line: %s') % pycompat.sysbytes(err.line))
 except (socket.error, httplib.HTTPException) as err:
 raise urlerr.urlerror(err)
 
@@ -358,9 +360,12 @@
 
 
 def __init__(self, sock, debuglevel=0, strict=0, method=None):
+extrakw = {}
+if not pycompat.ispy3:
+extrakw['strict'] = True
+extrakw['buffering'] = True
 httplib.HTTPResponse.__init__(self, sock, debuglevel=debuglevel,
-  strict=True, method=method,
-  buffering=True)
+  method=method, **extrakw)
 self.fileno = sock.fileno
 self.code = None
 self._rbuf = ''



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


D891: cleanup: use urllibcompat for renamed methods on urllib request objects

2017-10-02 Thread yuja (Yuya Nishihara)
yuja accepted this revision.
yuja added a comment.
This revision is now accepted and ready to land.


  Maybe we'll have to work around unicode/bytes dance in urllibcompat.py, but
  this patch looks good as itself.

REPOSITORY
  rHG Mercurial

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

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


D890: urllibcompat: new library to help abstract out some python3 urllib2 stuff

2017-10-02 Thread yuja (Yuya Nishihara)
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  Please add GPL boilerplate.
  
  FWIW, we might want to move some urllib-related hacks from pycompat.py.

REPOSITORY
  rHG Mercurial

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

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


D887: httppeer: use native strings for headers

2017-10-02 Thread yuja (Yuya Nishihara)
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> httppeer.py:233
>  encargs = urlreq.urlencode(sorted(args.items()))
> -for header, value in encodevalueinheaders(encargs, 'X-HgArg',
> +for header, value in encodevalueinheaders(encargs, 
> r'X-HgArg',
>headersize):

Appears that encodevalueinheaders() takes bytes.

I don't know which would be better to pass unicodes around or convert them
at one place.

> httppeer.py:240
> +qs = '?%s' % urlreq.urlencode([
> +(pycompat.strurl(qq[0]), pycompat.strurl(qq[1])) for qq in q])
> +cu = r"%s%s" % (pycompat.strurl(self._url), qs)

Perhaps this should be handled in urlencode() because it converts the output
from str to bytes.

REPOSITORY
  rHG Mercurial

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

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


D886: ui: convert to/from Optional[bytes] to Optional[str] in password manager

2017-10-02 Thread yuja (Yuya Nishihara)
yuja added inline comments.

INLINE COMMENTS

> durin42 wrote in ui.py:141
> Experimentally not true: if I don't do the ispy3 check, tests fail.

No idea why. strurl() should just return the input on Py2.

REPOSITORY
  rHG Mercurial

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

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


D789: merge: add option to abort merge process on failure

2017-10-02 Thread ryanmce (Ryan McElroy)
ryanmce updated this revision to Diff 2333.
ryanmce added a comment.


  fix check-code -- whoops

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D789?vs=2332=2333

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/filemerge.py
  mercurial/help/config.txt
  tests/test-merge-tool-abort.t

CHANGE DETAILS

diff --git a/tests/test-merge-tool-abort.t b/tests/test-merge-tool-abort.t
new file mode 100644
--- /dev/null
+++ b/tests/test-merge-tool-abort.t
@@ -0,0 +1,70 @@
+  $ cat >> $HGRCPATH < [extensions]
+  > rebase=
+  > [phases]
+  > publish=False
+  > [merge]
+  > abortonfailure=True
+  > EOF
+
+  $ hg init repo
+  $ cd repo
+  $ echo a > a
+  $ echo b > b
+  $ hg commit -qAm ab
+  $ echo c >> a
+  $ echo c >> b
+  $ hg commit -qAm c
+  $ hg up -q ".^"
+  $ echo d >> a
+  $ echo d >> b
+  $ hg commit -qAm d
+
+Check that failing external tool aborts the merge
+  $ hg rebase -s 1 -d 2 --tool false
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+Check that successful tool with failed post-check aborts the merge
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=changed
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+   output file a appears unchanged
+  was merge successful (yn)? n
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=conflicts 
--config merge-tools.true.premerge=keep
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=prompt
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  was merge of 'a' successful (yn)? n
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+Check that successful tool otherwise allows the merge to continue
+  $ hg rebase -s 1 -d 2 --tool echo --keep --config 
merge-tools.echo.premerge=keep
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  $TESTTMP/repo/a *a~base* *a~other* (glob)
+  $TESTTMP/repo/b *b~base* *b~other* (glob)
+
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1239,6 +1239,14 @@
different contents. Similar to ``merge.checkignored``, except for files that
are not ignored. (default: ``abort``)
 
+``abortonfailure``
+   Traditionally, the merge process attempts to merge all unresolved files
+   using the merge tool of choice, regardless of whether previous file merge
+   attempts succeeded or failed. Setting the ``merge.abortonfailure`` option to
+   True changes this behavior so that a failed merge will immediately abort
+   the merge operation, leaving the user in a normal unresolved merge state.
+   (default: ``False``)
+
 ``merge-patterns``
 --
 
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -521,6 +521,14 @@
 util.unlink(b)
 util.unlink(c)
 
+def getmergeerrorhandler(repo):
+onerr = None
+if repo.ui.configbool('merge', 'abortonfailure'):
+def onerr(*args):
+msg = _('merge aborted due to nonzero mergetool return code')
+return error.Abort(msg)
+return onerr
+
 def _formatconflictmarker(repo, ctx, template, label, pad):
 """Applies the given template to the ctx, prefixed by the label.
 
@@ -713,6 +721,9 @@
 r = _check(repo, r, ui, tool, fcd, files)
 
 if r:
+if repo.ui.configbool('merge', 'abortonfailure'):
+msg = _('merge aborted due to merge tool failure')
+raise error.Abort(msg)
 if onfailure:
 ui.warn(onfailure % fd)
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -299,6 +299,9 @@
 coreconfigitem('merge', 'followcopies',
 default=True,
 )
+coreconfigitem('merge', 'abortonfailure',
+default=False,
+)
 coreconfigitem('pager', 'ignore',
 default=list,
 )



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


D789: merge: add option to abort merge process on failure

2017-10-02 Thread ryanmce (Ryan McElroy)
ryanmce updated this revision to Diff 2332.
ryanmce marked an inline comment as done.
ryanmce added a comment.


  Followed yuja's advice and moved the abort later.
  
  This has many advantages as shown in the updated test, which shows this abort
  also helps with merge tool post-checks, which are also tested.
  
  It also gives me ideas for the prompts that we can improve to allow this to
  be an option at runtime rather than only a config-time option as it is now.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D789?vs=2007=2332

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/filemerge.py
  mercurial/help/config.txt
  tests/test-merge-tool-abort.t

CHANGE DETAILS

diff --git a/tests/test-merge-tool-abort.t b/tests/test-merge-tool-abort.t
new file mode 100644
--- /dev/null
+++ b/tests/test-merge-tool-abort.t
@@ -0,0 +1,70 @@
+  $ cat >> $HGRCPATH < [extensions]
+  > rebase=
+  > [phases]
+  > publish=False
+  > [merge]
+  > abortonfailure=True
+  > EOF
+
+  $ hg init repo
+  $ cd repo
+  $ echo a > a
+  $ echo b > b
+  $ hg commit -qAm ab
+  $ echo c >> a
+  $ echo c >> b
+  $ hg commit -qAm c
+  $ hg up -q .^
+  $ echo d >> a
+  $ echo d >> b
+  $ hg commit -qAm d
+
+Check that failing external tool aborts the merge
+  $ hg rebase -s 1 -d 2 --tool false
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+Check that successful tool with failed post-check aborts the merge
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=changed
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+   output file a appears unchanged
+  was merge successful (yn)? n
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=conflicts 
--config merge-tools.true.premerge=keep
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=prompt
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  was merge of 'a' successful (yn)? n
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+Check that successful tool otherwise allows the merge to continue
+  $ hg rebase -s 1 -d 2 --tool echo --keep --config 
merge-tools.echo.premerge=keep
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  $TESTTMP/repo/a *a~base* *a~other* (glob)
+  $TESTTMP/repo/b *b~base* *b~other* (glob)
+
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1239,6 +1239,14 @@
different contents. Similar to ``merge.checkignored``, except for files that
are not ignored. (default: ``abort``)
 
+``abortonfailure``
+   Traditionally, the merge process attempts to merge all unresolved files
+   using the merge tool of choice, regardless of whether previous file merge
+   attempts succeeded or failed. Setting the ``merge.abortonfailure`` option to
+   True changes this behavior so that a failed merge will immediately abort
+   the merge operation, leaving the user in a normal unresolved merge state.
+   (default: ``False``)
+
 ``merge-patterns``
 --
 
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -521,6 +521,14 @@
 util.unlink(b)
 util.unlink(c)
 
+def getmergeerrorhandler(repo):
+onerr = None
+if repo.ui.configbool('merge', 'abortonfailure'):
+def onerr(*args):
+msg = _('merge aborted due to nonzero mergetool return code')
+return error.Abort(msg)
+return onerr
+
 def _formatconflictmarker(repo, ctx, template, label, pad):
 """Applies the given template to the ctx, prefixed by the label.
 
@@ -713,6 +721,9 @@
 r = _check(repo, r, ui, tool, fcd, files)
 
 if r:
+if repo.ui.configbool('merge', 'abortonfailure'):
+msg = _('merge aborted due to merge tool failure')
+raise error.Abort(msg)
 if onfailure:
 ui.warn(onfailure % fd)
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -299,6 +299,9 @@
 coreconfigitem('merge', 'followcopies',
 default=True,
 )
+coreconfigitem('merge', 'abortonfailure',
+default=False,
+)
 coreconfigitem('pager', 'ignore',
 default=list,
 )



To: ryanmce, #hg-reviewers, quark, yuja, mbthomas
Cc: mbthomas, yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D899: annotate: track whether a particular annotation was the result of a skip

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 added a comment.


  Turns out it actually was buggy. Thanks for catching it!
  
  I switched to using `attrs.evolve` (and in the earlier diff setting 
`frozen=True` to make the attr immutable)

REPOSITORY
  rHG Mercurial

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

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


D899: annotate: track whether a particular annotation was the result of a skip

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 updated this revision to Diff 2331.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D899?vs=2329=2331

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

AFFECTED FILES
  mercurial/context.py
  tests/test-annotate.py

CHANGE DETAILS

diff --git a/tests/test-annotate.py b/tests/test-annotate.py
--- a/tests/test-annotate.py
+++ b/tests/test-annotate.py
@@ -80,20 +80,22 @@
  diffopts)
 self.assertEqual(childann[0], [
 annotateline('old', 1),
-annotateline('old', 2),
+annotateline('old', 2, True),
+# note that this line was carried over from earlier so it is *not*
+# marked skipped
 annotateline('p2', 2),
-annotateline('p2', 2),
+annotateline('p2', 2, True),
 annotateline('p2', 3),
 ])
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p2ann, p1ann], childfctx, childann, True,
  diffopts)
 self.assertEqual(childann[0], [
 annotateline('old', 1),
-annotateline('old', 2),
+annotateline('old', 2, True),
 annotateline('p1', 3),
-annotateline('p1', 3),
+annotateline('p1', 3, True),
 annotateline('p2', 3),
 ])
 
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -,6 +,8 @@
 class annotateline(object):
 fctx = attr.ib()
 lineno = attr.ib(default=False)
+# Whether this annotation was the result of a skip-annotate.
+skip = attr.ib(default=False)
 
 def _annotatepair(parents, childfctx, child, skipchild, diffopts):
 r'''
@@ -1159,7 +1161,7 @@
 for bk in xrange(b1, b2):
 if child[0][bk].fctx == childfctx:
 ak = min(a1 + (bk - b1), a2 - 1)
-child[0][bk] = parent[0][ak]
+child[0][bk] = attr.evolve(parent[0][ak], 
skip=True)
 else:
 remaining[idx][1].append((a1, a2, b1, b2))
 
@@ -1170,7 +1172,7 @@
 for bk in xrange(b1, b2):
 if child[0][bk].fctx == childfctx:
 ak = min(a1 + (bk - b1), a2 - 1)
-child[0][bk] = parent[0][ak]
+child[0][bk] = attr.evolve(parent[0][ak], skip=True)
 return child
 
 class filectx(basefilectx):



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


D898: annotate: introduce attr for storing per-line annotate data

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 updated this revision to Diff 2328.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D898?vs=2319=2328

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/context.py
  mercurial/hgweb/webcommands.py
  tests/test-annotate.py

CHANGE DETAILS

diff --git a/tests/test-annotate.py b/tests/test-annotate.py
--- a/tests/test-annotate.py
+++ b/tests/test-annotate.py
@@ -7,6 +7,7 @@
 mdiff,
 )
 from mercurial.context import (
+annotateline,
 _annotatepair,
 )
 
@@ -25,50 +26,76 @@
 diffopts = mdiff.diffopts()
 
 def decorate(text, rev):
-return ([(rev, i) for i in xrange(1, text.count(b'\n') + 1)], text)
+return ([annotateline(fctx=rev, lineno=i)
+ for i in xrange(1, text.count(b'\n') + 1)],
+text)
 
 # Basic usage
 
 oldann = decorate(olddata, oldfctx)
 p1ann = decorate(p1data, p1fctx)
 p1ann = _annotatepair([oldann], p1fctx, p1ann, False, diffopts)
-self.assertEqual(p1ann[0], [('old', 1), ('old', 2), ('p1', 3)])
+self.assertEqual(p1ann[0], [
+annotateline('old', 1),
+annotateline('old', 2),
+annotateline('p1', 3),
+])
 
 p2ann = decorate(p2data, p2fctx)
 p2ann = _annotatepair([oldann], p2fctx, p2ann, False, diffopts)
-self.assertEqual(p2ann[0], [('old', 1), ('p2', 2), ('p2', 3)])
+self.assertEqual(p2ann[0], [
+annotateline('old', 1),
+annotateline('p2', 2),
+annotateline('p2', 3),
+])
 
 # Test with multiple parents (note the difference caused by ordering)
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p1ann, p2ann], childfctx, childann, False,
  diffopts)
-self.assertEqual(childann[0],
-[('old', 1), ('c', 2), ('p2', 2), ('c', 4), ('p2', 3)]
-)
+self.assertEqual(childann[0], [
+annotateline('old', 1),
+annotateline('c', 2),
+annotateline('p2', 2),
+annotateline('c', 4),
+annotateline('p2', 3),
+])
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p2ann, p1ann], childfctx, childann, False,
  diffopts)
-self.assertEqual(childann[0],
-[('old', 1), ('c', 2), ('p1', 3), ('c', 4), ('p2', 3)]
-)
+self.assertEqual(childann[0], [
+annotateline('old', 1),
+annotateline('c', 2),
+annotateline('p1', 3),
+annotateline('c', 4),
+annotateline('p2', 3),
+])
 
 # Test with skipchild (note the difference caused by ordering)
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p1ann, p2ann], childfctx, childann, True,
  diffopts)
-self.assertEqual(childann[0],
-[('old', 1), ('old', 2), ('p2', 2), ('p2', 2), ('p2', 3)]
-)
+self.assertEqual(childann[0], [
+annotateline('old', 1),
+annotateline('old', 2),
+annotateline('p2', 2),
+annotateline('p2', 2),
+annotateline('p2', 3),
+])
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p2ann, p1ann], childfctx, childann, True,
  diffopts)
-self.assertEqual(childann[0],
-[('old', 1), ('old', 2), ('p1', 3), ('p1', 3), ('p2', 3)]
-)
+self.assertEqual(childann[0], [
+annotateline('old', 1),
+annotateline('old', 2),
+annotateline('p1', 3),
+annotateline('p1', 3),
+annotateline('p2', 3),
+])
 
 if __name__ == '__main__':
 import silenttestrunner
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -906,7 +906,8 @@
 
 previousrev = None
 blockparitygen = paritygen(1)
-for lineno, ((f, targetline), l) in enumerate(lines):
+for lineno, (aline, l) in enumerate(lines):
+f = aline.fctx
 rev = f.rev()
 if rev != previousrev:
 blockhead = True
@@ -924,7 +925,7 @@
"file": f.path(),
"blockhead": blockhead,
"blockparity": blockparity,
-   "targetline": targetline,
+   "targetline": aline.lineno,
"line": l,
"lineno": lineno + 1,
"lineid": "l%d" % (lineno + 1),
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -25,6 +25,9 @@
 wdirnodes,
 wdirrev,
 )
+from 

D900: annotate: mark lines affected by skip-annotate with *

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 updated this revision to Diff 2330.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D900?vs=2321=2330

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-annotate.t

CHANGE DETAILS

diff --git a/tests/test-annotate.t b/tests/test-annotate.t
--- a/tests/test-annotate.t
+++ b/tests/test-annotate.t
@@ -261,8 +261,8 @@
 
   $ hg annotate -nlf b --skip 6
   0 a:1: a
-  1 a:2: z (no-pure !)
   0 a:1: z (pure !)
+  1 a:2* z
   1 a:3: a
   3 b:4: b4
   4 b:5: c
@@ -275,27 +275,27 @@
   0 a:1: a
   6 b:2: z
   1 a:3: a
-  1 a:3: b4
+  1 a:3* b4
   4 b:5: c
-  1 a:3: b5
+  1 a:3* b5
   7 b:7: d
 
   $ hg annotate -nlf b --skip 4
   0 a:1: a
   6 b:2: z
   1 a:3: a
   3 b:4: b4
-  1 a:3: c
+  1 a:3* c
   3 b:5: b5
   7 b:7: d
 
   $ hg annotate -nlf b --skip 3 --skip 4
   0 a:1: a
   6 b:2: z
   1 a:3: a
-  1 a:3: b4
-  1 a:3: c
-  1 a:3: b5
+  1 a:3* b4
+  1 a:3* c
+  1 a:3* b5
   7 b:7: d
 
   $ hg annotate -nlf b --skip 'merge()'
@@ -305,18 +305,18 @@
   3 b:4: b4
   4 b:5: c
   3 b:5: b5
-  3 b:5: d
+  3 b:5* d
 
 --skip everything -- use the revision the file was introduced in
 
   $ hg annotate -nlf b --skip 'all()'
   0 a:1: a
-  0 a:1: z
-  0 a:1: a
-  0 a:1: b4
-  0 a:1: c
-  0 a:1: b5
-  0 a:1: d
+  0 a:1* z
+  0 a:1* a
+  0 a:1* b4
+  0 a:1* c
+  0 a:1* b5
+  0 a:1* d
 
 Issue2807: alignment of line numbers with -l
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -400,7 +400,11 @@
 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
 fm.startitem()
 fm.write(fields, "".join(f), *p)
-fm.write('line', ": %s", l[1])
+if l[0].skip:
+fmt = "* %s"
+else:
+fmt = ": %s"
+fm.write('line', fmt, l[1])
 
 if not lines[-1][1].endswith('\n'):
 fm.plain('\n')



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


D899: annotate: track whether a particular annotation was the result of a skip

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 updated this revision to Diff 2329.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D899?vs=2320=2329

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

AFFECTED FILES
  mercurial/context.py
  tests/test-annotate.py

CHANGE DETAILS

diff --git a/tests/test-annotate.py b/tests/test-annotate.py
--- a/tests/test-annotate.py
+++ b/tests/test-annotate.py
@@ -80,20 +80,22 @@
  diffopts)
 self.assertEqual(childann[0], [
 annotateline('old', 1),
-annotateline('old', 2),
+annotateline('old', 2, True),
+# note that this line was carried over from earlier so it is *not*
+# marked skipped
 annotateline('p2', 2),
-annotateline('p2', 2),
+annotateline('p2', 2, True),
 annotateline('p2', 3),
 ])
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p2ann, p1ann], childfctx, childann, True,
  diffopts)
 self.assertEqual(childann[0], [
 annotateline('old', 1),
-annotateline('old', 2),
-annotateline('p1', 3),
-annotateline('p1', 3),
+annotateline('old', 2, True),
+annotateline('p1', 3, True),
+annotateline('p1', 3, True),
 annotateline('p2', 3),
 ])
 
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -,6 +,8 @@
 class annotateline(object):
 fctx = attr.ib()
 lineno = attr.ib(default=False)
+# Whether this annotation was the result of a skip-annotate.
+skip = attr.ib(default=False)
 
 def _annotatepair(parents, childfctx, child, skipchild, diffopts):
 r'''
@@ -1159,7 +1161,7 @@
 for bk in xrange(b1, b2):
 if child[0][bk].fctx == childfctx:
 ak = min(a1 + (bk - b1), a2 - 1)
-child[0][bk] = parent[0][ak]
+child[0][bk] = attr.evolve(parent[0][ak], 
skip=True)
 else:
 remaining[idx][1].append((a1, a2, b1, b2))
 
@@ -1170,7 +1172,7 @@
 for bk in xrange(b1, b2):
 if child[0][bk].fctx == childfctx:
 ak = min(a1 + (bk - b1), a2 - 1)
-child[0][bk] = parent[0][ak]
+child[0][bk] = attr.evolve(parent[0][ak], skip=True)
 return child
 
 class filectx(basefilectx):



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


D899: annotate: track whether a particular annotation was the result of a skip

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 added inline comments.

INLINE COMMENTS

> sid0 wrote in context.py:1164-1165
> Good question! Not in this case, because a particular annotation can never go 
> from skip=True to skip=False. If we decide to overwrite the annotation 
> afterwards, the whole object is replaced, not just fctx and lineno.

Actually -- hmm, you're right, this is a bit risky to code changes in the 
future -- especially if the same object gets shared between skipped and 
not-skipped lines. I'll create a new one to be safe.

REPOSITORY
  rHG Mercurial

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

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


D899: annotate: track whether a particular annotation was the result of a skip

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 added a comment.


  I'll add a comment explaining that.

REPOSITORY
  rHG Mercurial

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

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


D899: annotate: track whether a particular annotation was the result of a skip

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 added inline comments.

INLINE COMMENTS

> indygreg wrote in context.py:1164-1165
> I see that we're copying a ref to the object instead of making an object 
> copy. When we had tuples, that was fine because tuples are immutable. But 
> with attr, instances can be modified.
> 
> Will this pose any problems?

Good question! Not in this case, because a particular annotation can never go 
from skip=True to skip=False. If we decide to overwrite the annotation 
afterwards, the whole object is replaced, not just fctx and lineno.

REPOSITORY
  rHG Mercurial

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

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


D900: annotate: mark lines affected by skip-annotate with *

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 added a comment.


  Yeah, I plan to do all of those before marking the option un-experimental.

REPOSITORY
  rHG Mercurial

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

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


D789: merge: add option to abort merge process on failure

2017-10-02 Thread ryanmce (Ryan McElroy)
ryanmce marked 4 inline comments as done.
ryanmce added inline comments.

INLINE COMMENTS

> yuja wrote in filemerge.py:734
> Perhaps it's better to abort here, not in _xmerge().
> 
> Several merge tools do not return non-zero status on error, so
> we have extra _check() to detect merge error.

I looked through the code and you're right -- this is a better place. This also 
makes this change smaller overall. Thanks for the excellent suggestion!

REPOSITORY
  rHG Mercurial

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

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


D905: style: never put multiple statements on one line

2017-10-02 Thread alex_gaynor (Alex Gaynor)
alex_gaynor created this revision.
alex_gaynor added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  style-fixes (bookmark) on default (branch)

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

AFFECTED FILES
  mercurial/keepalive.py
  mercurial/pure/bdiff.py
  mercurial/pure/mpatch.py
  mercurial/sshserver.py
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1605,8 +1605,10 @@
 ifp.close()
 ofp.close()
 except: # re-raises
-try: os.unlink(temp)
-except OSError: pass
+try:
+os.unlink(temp)
+except OSError:
+pass
 raise
 return temp
 
diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py
--- a/mercurial/sshserver.py
+++ b/mercurial/sshserver.py
@@ -127,7 +127,8 @@
 r = impl()
 if r is not None:
 self.sendresponse(r)
-else: self.sendresponse("")
+else:
+self.sendresponse("")
 return cmd != ''
 
 def _client(self):
diff --git a/mercurial/pure/mpatch.py b/mercurial/pure/mpatch.py
--- a/mercurial/pure/mpatch.py
+++ b/mercurial/pure/mpatch.py
@@ -75,7 +75,8 @@
 # copy all the patches into our segment so we can memmove from them
 pos = b2 + bl
 m.seek(pos)
-for p in bins: m.write(p)
+for p in bins:
+m.write(p)
 
 for plen in plens:
 # if our list gets too long, execute it
diff --git a/mercurial/pure/bdiff.py b/mercurial/pure/bdiff.py
--- a/mercurial/pure/bdiff.py
+++ b/mercurial/pure/bdiff.py
@@ -60,7 +60,8 @@
 
 bin = []
 p = [0]
-for i in a: p.append(p[-1] + len(i))
+for i in a:
+p.append(p[-1] + len(i))
 
 d = difflib.SequenceMatcher(None, a, b).get_matching_blocks()
 d = _normalizeblocks(a, b, d)
diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -134,7 +134,8 @@
 del self._connmap[connection]
 del self._readymap[connection]
 self._hostmap[host].remove(connection)
-if not self._hostmap[host]: del self._hostmap[host]
+if not self._hostmap[host]:
+del self._hostmap[host]
 finally:
 self._lock.release()
 
@@ -616,7 +617,8 @@
 f = fo.readline()
 if f:
 foo = foo + f
-else: break
+else:
+break
 fo.close()
 m = md5(foo)
 print(format % ('keepalive readline', m.hexdigest()))



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


[Bug 5698] New: test-status-color.t test failure

2017-10-02 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5698

Bug ID: 5698
   Summary: test-status-color.t test failure
   Product: Mercurial
   Version: 4.3.3
  Hardware: PC
OS: NetBSD
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: t...@giga.or.at
CC: mercurial-devel@mercurial-scm.org

On NetBSD, I see the following test failure:

--- /scratch/devel/py-mercurial/work/mercurial-4.3.3/tests/test-status-color.t
+++
/scratch/devel/py-mercurial/work/mercurial-4.3.3/tests/test-status-color.t.err
@@ -227,15 +227,15 @@
   $ mkdir "$TESTTMP/terminfo"
   $ TERMINFO="$TESTTMP/terminfo" tic "$TESTDIR/hgterm.ti"
   $ TERM=hgterm TERMINFO="$TESTTMP/terminfo" hg status --config
color.mode=terminfo -A
-  \x1b[30m\x1b[32m\x1b[1mA \x1b[30m\x1b[30m\x1b[32m\x1b[1madded\x1b[30m (esc)
-  \x1b[30m\x1b[32m\x1b[1mA \x1b[30m\x1b[30m\x1b[32m\x1b[1mcopied\x1b[30m (esc)
-  \x1b[30m\x1b[30m  modified\x1b[30m (esc)
-  \x1b[30m\x1b[31m\x1b[1mR \x1b[30m\x1b[30m\x1b[31m\x1b[1mremoved\x1b[30m
(esc)
-  \x1b[30m\x1b[36m\x1b[1m\x1b[4m!
\x1b[30m\x1b[30m\x1b[36m\x1b[1m\x1b[4mdeleted\x1b[30m (esc)
-  \x1b[30m\x1b[35m\x1b[1m\x1b[4m?
\x1b[30m\x1b[30m\x1b[35m\x1b[1m\x1b[4munknown\x1b[30m (esc)
-  \x1b[30m\x1b[30m\x1b[1mI \x1b[30m\x1b[30m\x1b[30m\x1b[1mignored\x1b[30m
(esc)
-  \x1b[30m\x1b[30mC \x1b[30m\x1b[30m\x1b[30m.hgignore\x1b[30m (esc)
-  \x1b[30m\x1b[30mC \x1b[30m\x1b[30m\x1b[30mmodified\x1b[30m (esc)
+  \x1b[0;32;1mA \x1b[0m\x1b[0;32;1madded\x1b[0m (esc)
+  \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mcopied\x1b[0m (esc)
+  \x1b[0;0m  modified\x1b[0m (esc)
+  \x1b[0;31;1mR \x1b[0m\x1b[0;31;1mremoved\x1b[0m (esc)
+  \x1b[0;36;1;4m! \x1b[0m\x1b[0;36;1;4mdeleted\x1b[0m (esc)
+  \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4munknown\x1b[0m (esc)
+  \x1b[0;30;1mI \x1b[0m\x1b[0;30;1mignored\x1b[0m (esc)
+  \x1b[0;0mC \x1b[0m\x1b[0;0m.hgignore\x1b[0m (esc)
+  \x1b[0;0mC \x1b[0m\x1b[0;0mmodified\x1b[0m (esc)

 The user can define effects with raw terminfo codes:

@@ -246,15 +246,15 @@
   > terminfo.bold = \E[2m
   > EOF
   $ TERM=hgterm TERMINFO="$TESTTMP/terminfo" hg status --config
color.mode=terminfo --config color.status.clean=dim -A
-  \x1b[30m\x1b[32m\x1b[2mA \x1b[30m\x1b[30m\x1b[32m\x1b[2madded\x1b[30m (esc)
-  \x1b[30m\x1b[32m\x1b[2mA \x1b[30m\x1b[30m\x1b[32m\x1b[2mcopied\x1b[30m (esc)
-  \x1b[30m\x1b[30m  modified\x1b[30m (esc)
-  \x1b[30m\x1b[31m\x1b[2mR \x1b[30m\x1b[30m\x1b[31m\x1b[2mremoved\x1b[30m
(esc)
-  \x1b[30m\x1b[36m\x1b[2m\x1b[4m!
\x1b[30m\x1b[30m\x1b[36m\x1b[2m\x1b[4mdeleted\x1b[30m (esc)
-  \x1b[30m\x1b[35m\x1b[2m\x1b[4m?
\x1b[30m\x1b[30m\x1b[35m\x1b[2m\x1b[4munknown\x1b[30m (esc)
-  \x1b[30m\x1b[30m\x1b[2mI \x1b[30m\x1b[30m\x1b[30m\x1b[2mignored\x1b[30m
(esc)
-  \x1b[30m\x1b[88mC \x1b[30m\x1b[30m\x1b[88m.hgignore\x1b[30m (esc)
-  \x1b[30m\x1b[88mC \x1b[30m\x1b[30m\x1b[88mmodified\x1b[30m (esc)
+  \x1b[0;32;1mA \x1b[0m\x1b[0;32;1madded\x1b[0m (esc)
+  \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mcopied\x1b[0m (esc)
+  \x1b[0;0m  modified\x1b[0m (esc)
+  \x1b[0;31;1mR \x1b[0m\x1b[0;31;1mremoved\x1b[0m (esc)
+  \x1b[0;36;1;4m! \x1b[0m\x1b[0;36;1;4mdeleted\x1b[0m (esc)
+  \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4munknown\x1b[0m (esc)
+  \x1b[0;30;1mI \x1b[0m\x1b[0;30;1mignored\x1b[0m (esc)
+  \x1b[0;2mC \x1b[0m\x1b[0;2m.hgignore\x1b[0m (esc)
+  \x1b[0;2mC \x1b[0m\x1b[0;2mmodified\x1b[0m (esc)

 #endif


ERROR: test-status-color.t output changed

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


[Bug 5697] New: test-hghave.t test failure

2017-10-02 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5697

Bug ID: 5697
   Summary: test-hghave.t test failure
   Product: Mercurial
   Version: 4.3.3
  Hardware: PC
OS: NetBSD
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: t...@giga.or.at
CC: mercurial-devel@mercurial-scm.org

In 4.3.2 and 4.3.3 I see a new test failure:

--- /scratch/devel/py-mercurial/work/mercurial-4.3.3/tests/test-hghave.t
+++ /scratch/devel/py-mercurial/work/mercurial-4.3.3/tests/test-hghave.t.err
@@ -24,8 +24,8 @@
   > testrepohgenv; \
   > $TESTDIR/run-tests.py $HGTEST_RUN_TESTS_PURE test-hghaveaddon.t \
   > )
-  .
-  # Ran 1 tests, 0 skipped, 0 failed.
+  env: python: No such file or directory
+  [127]

 (invocation via command line)


ERROR: test-hghave.t output changed

pkgsrc on NetBSD only provides versioned python binaries (i.e., "python2.7")
but this test (or a script it calls) just uses "python". ${PYTHON} is set to
the real python binary name, which seems to suffice for all other tests.

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


D900: annotate: mark lines affected by skip-annotate with *

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  This seems reasonable.
  
  Potential follow-ups:
  
  1. Documentation in help output.
  2. Inline output saying * denotes skip?
  3. Support in templater for indicating skip (maybe test JSON output)?

REPOSITORY
  rHG Mercurial

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

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


D899: annotate: track whether a particular annotation was the result of a skip

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg added a comment.


  Before I stamp this I'd like an answer to the mutability concerns.

INLINE COMMENTS

> context.py:1164-1165
>  ak = min(a1 + (bk - b1), a2 - 1)
>  child[0][bk] = parent[0][ak]
> +child[0][bk].skip = True
>  else:

I see that we're copying a ref to the object instead of making an object copy. 
When we had tuples, that was fine because tuples are immutable. But with attr, 
instances can be modified.

Will this pose any problems?

> context.py:1177
>  child[0][bk] = parent[0][ak]
> +child[0][bk].skip = True
>  return child

Ditto.

REPOSITORY
  rHG Mercurial

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

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


D898: annotate: introduce attr for storing per-line annotate data

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  The new code is so much easier to read!

REPOSITORY
  rHG Mercurial

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

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


D897: context: rename local 'attr' to 'attr_'

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  I could bikeshed the naming. But if there isn't automated style checking to 
flag it as bad, then it's good.

REPOSITORY
  rHG Mercurial

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

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


D901: changelog: use a Factory for default value for files

2017-10-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The default value is compiled into the generated type. This means
  that default values are shared between instances. For immutable types
  like bool, str, int, and tuple, this is fine. But for mutable types
  like list and dict, we need to use attr.Factory()  to instantiate a
  new instance of the default for each object.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/changelog.py

CHANGE DETAILS

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -151,7 +151,7 @@
 manifest = attr.ib(default=nullid)
 user = attr.ib(default='')
 date = attr.ib(default=(0, 0))
-files = attr.ib(default=[])
+files = attr.ib(default=attr.Factory(list))
 description = attr.ib(default='')
 
 class changelogrevision(object):



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


D886: ui: convert to/from Optional[bytes] to Optional[str] in password manager

2017-10-02 Thread durin42 (Augie Fackler)
durin42 added inline comments.

INLINE COMMENTS

> yuja wrote in ui.py:141
> Nit: no need to check if ispy3.

Experimentally not true: if I don't do the ispy3 check, tests fail.

> yuja wrote in ui.py:169
> No idea how user and passwd are encoded, but encoding.strfromlocal() might
> be better because strurl() can raise unicode exception if non-ascii string is 
> passed.

I think the password can come from either a URL or explicit end-user input. 
I'll have to look more closely.

REPOSITORY
  rHG Mercurial

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

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


D886: ui: convert to/from Optional[bytes] to Optional[str] in password manager

2017-10-02 Thread yuja (Yuya Nishihara)
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> ui.py:141
> +return None
> +if pycompat.ispy3:
> +return pycompat.strurl(maybebytes)

Nit: no need to check if ispy3.

> ui.py:169
> +_maybestrurl(realm), uris,
> +_maybestrurl(user), _maybestrurl(passwd))
>  

No idea how user and passwd are encoded, but encoding.strfromlocal() might
be better because strurl() can raise unicode exception if non-ascii string is 
passed.

REPOSITORY
  rHG Mercurial

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

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


D898: annotate: introduce attr for storing per-line annotate data

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We're going to extend this a bit -- at first by simply adding whether this was
  a skipped child. We're well on our way to outgrowing tuples, though -- adding
  more and more fields to tuples becomes annoying very quickly.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/context.py
  mercurial/hgweb/webcommands.py
  tests/test-annotate.py

CHANGE DETAILS

diff --git a/tests/test-annotate.py b/tests/test-annotate.py
--- a/tests/test-annotate.py
+++ b/tests/test-annotate.py
@@ -7,6 +7,7 @@
 mdiff,
 )
 from mercurial.context import (
+annotateline,
 _annotatepair,
 )
 
@@ -25,50 +26,76 @@
 diffopts = mdiff.diffopts()
 
 def decorate(text, rev):
-return ([(rev, i) for i in xrange(1, text.count(b'\n') + 1)], text)
+return ([annotateline(fctx=rev, lineno=i)
+ for i in xrange(1, text.count(b'\n') + 1)],
+text)
 
 # Basic usage
 
 oldann = decorate(olddata, oldfctx)
 p1ann = decorate(p1data, p1fctx)
 p1ann = _annotatepair([oldann], p1fctx, p1ann, False, diffopts)
-self.assertEqual(p1ann[0], [('old', 1), ('old', 2), ('p1', 3)])
+self.assertEqual(p1ann[0], [
+annotateline('old', 1),
+annotateline('old', 2),
+annotateline('p1', 3),
+])
 
 p2ann = decorate(p2data, p2fctx)
 p2ann = _annotatepair([oldann], p2fctx, p2ann, False, diffopts)
-self.assertEqual(p2ann[0], [('old', 1), ('p2', 2), ('p2', 3)])
+self.assertEqual(p2ann[0], [
+annotateline('old', 1),
+annotateline('p2', 2),
+annotateline('p2', 3),
+])
 
 # Test with multiple parents (note the difference caused by ordering)
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p1ann, p2ann], childfctx, childann, False,
  diffopts)
-self.assertEqual(childann[0],
-[('old', 1), ('c', 2), ('p2', 2), ('c', 4), ('p2', 3)]
-)
+self.assertEqual(childann[0], [
+annotateline('old', 1),
+annotateline('c', 2),
+annotateline('p2', 2),
+annotateline('c', 4),
+annotateline('p2', 3),
+])
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p2ann, p1ann], childfctx, childann, False,
  diffopts)
-self.assertEqual(childann[0],
-[('old', 1), ('c', 2), ('p1', 3), ('c', 4), ('p2', 3)]
-)
+self.assertEqual(childann[0], [
+annotateline('old', 1),
+annotateline('c', 2),
+annotateline('p1', 3),
+annotateline('c', 4),
+annotateline('p2', 3),
+])
 
 # Test with skipchild (note the difference caused by ordering)
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p1ann, p2ann], childfctx, childann, True,
  diffopts)
-self.assertEqual(childann[0],
-[('old', 1), ('old', 2), ('p2', 2), ('p2', 2), ('p2', 3)]
-)
+self.assertEqual(childann[0], [
+annotateline('old', 1),
+annotateline('old', 2),
+annotateline('p2', 2),
+annotateline('p2', 2),
+annotateline('p2', 3),
+])
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p2ann, p1ann], childfctx, childann, True,
  diffopts)
-self.assertEqual(childann[0],
-[('old', 1), ('old', 2), ('p1', 3), ('p1', 3), ('p2', 3)]
-)
+self.assertEqual(childann[0], [
+annotateline('old', 1),
+annotateline('old', 2),
+annotateline('p1', 3),
+annotateline('p1', 3),
+annotateline('p2', 3),
+])
 
 if __name__ == '__main__':
 import silenttestrunner
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -906,7 +906,8 @@
 
 previousrev = None
 blockparitygen = paritygen(1)
-for lineno, ((f, targetline), l) in enumerate(lines):
+for lineno, (aline, l) in enumerate(lines):
+f = aline.fctx
 rev = f.rev()
 if rev != previousrev:
 blockhead = True
@@ -924,7 +925,7 @@
"file": f.path(),
"blockhead": blockhead,
"blockparity": blockparity,
-   "targetline": targetline,
+   "targetline": aline.lineno,
"line": l,

D900: annotate: mark lines affected by skip-annotate with *

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is to prevent weird surprises from happening with skips being attributed
  to the wrong changeset.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-annotate.t

CHANGE DETAILS

diff --git a/tests/test-annotate.t b/tests/test-annotate.t
--- a/tests/test-annotate.t
+++ b/tests/test-annotate.t
@@ -261,8 +261,8 @@
 
   $ hg annotate -nlf b --skip 6
   0 a:1: a
-  1 a:2: z (no-pure !)
   0 a:1: z (pure !)
+  1 a:2* z
   1 a:3: a
   3 b:4: b4
   4 b:5: c
@@ -274,49 +274,49 @@
   $ hg annotate -nlf b --skip 3
   0 a:1: a
   6 b:2: z
-  1 a:3: a
-  1 a:3: b4
+  1 a:3* a
+  1 a:3* b4
   4 b:5: c
-  1 a:3: b5
+  1 a:3* b5
   7 b:7: d
 
   $ hg annotate -nlf b --skip 4
   0 a:1: a
   6 b:2: z
-  1 a:3: a
+  1 a:3* a
   3 b:4: b4
-  1 a:3: c
+  1 a:3* c
   3 b:5: b5
   7 b:7: d
 
   $ hg annotate -nlf b --skip 3 --skip 4
   0 a:1: a
   6 b:2: z
-  1 a:3: a
-  1 a:3: b4
-  1 a:3: c
-  1 a:3: b5
+  1 a:3* a
+  1 a:3* b4
+  1 a:3* c
+  1 a:3* b5
   7 b:7: d
 
   $ hg annotate -nlf b --skip 'merge()'
   0 a:1: a
   6 b:2: z
   1 a:3: a
   3 b:4: b4
   4 b:5: c
-  3 b:5: b5
-  3 b:5: d
+  3 b:5* b5
+  3 b:5* d
 
 --skip everything -- use the revision the file was introduced in
 
   $ hg annotate -nlf b --skip 'all()'
-  0 a:1: a
-  0 a:1: z
-  0 a:1: a
-  0 a:1: b4
-  0 a:1: c
-  0 a:1: b5
-  0 a:1: d
+  0 a:1* a
+  0 a:1* z
+  0 a:1* a
+  0 a:1* b4
+  0 a:1* c
+  0 a:1* b5
+  0 a:1* d
 
 Issue2807: alignment of line numbers with -l
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -400,7 +400,11 @@
 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
 fm.startitem()
 fm.write(fields, "".join(f), *p)
-fm.write('line', ": %s", l[1])
+if l[0].skip:
+fmt = "* %s"
+else:
+fmt = ": %s"
+fm.write('line', fmt, l[1])
 
 if not lines[-1][1].endswith('\n'):
 fm.plain('\n')



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


D896: annotate: move annotatepair unit tests to a separate file

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  In upcoming patches the output is going to be significantly longer than it is
  today, and doctests don't allow wrapping the output.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/context.py
  tests/test-annotate.py

CHANGE DETAILS

diff --git a/tests/test-annotate.py b/tests/test-annotate.py
new file mode 100644
--- /dev/null
+++ b/tests/test-annotate.py
@@ -0,0 +1,75 @@
+from __future__ import absolute_import
+from __future__ import print_function
+
+import unittest
+
+from mercurial import (
+mdiff,
+)
+from mercurial.context import (
+_annotatepair,
+)
+
+class AnnotateTests(unittest.TestCase):
+"""Unit tests for annotate code."""
+
+def testannotatepair(self):
+self.maxDiff = None # camelcase-required
+
+oldfctx = b'old'
+p1fctx, p2fctx, childfctx = b'p1', b'p2', b'c'
+olddata = b'a\nb\n'
+p1data = b'a\nb\nc\n'
+p2data = b'a\nc\nd\n'
+childdata = b'a\nb2\nc\nc2\nd\n'
+diffopts = mdiff.diffopts()
+
+def decorate(text, rev):
+return ([(rev, i) for i in xrange(1, text.count(b'\n') + 1)], text)
+
+# Basic usage
+
+oldann = decorate(olddata, oldfctx)
+p1ann = decorate(p1data, p1fctx)
+p1ann = _annotatepair([oldann], p1fctx, p1ann, False, diffopts)
+self.assertEqual(p1ann[0], [('old', 1), ('old', 2), ('p1', 3)])
+
+p2ann = decorate(p2data, p2fctx)
+p2ann = _annotatepair([oldann], p2fctx, p2ann, False, diffopts)
+self.assertEqual(p2ann[0], [('old', 1), ('p2', 2), ('p2', 3)])
+
+# Test with multiple parents (note the difference caused by ordering)
+
+childann = decorate(childdata, childfctx)
+childann = _annotatepair([p1ann, p2ann], childfctx, childann, False,
+ diffopts)
+self.assertEqual(childann[0],
+[('old', 1), ('c', 2), ('p2', 2), ('c', 4), ('p2', 3)]
+)
+
+childann = decorate(childdata, childfctx)
+childann = _annotatepair([p2ann, p1ann], childfctx, childann, False,
+ diffopts)
+self.assertEqual(childann[0],
+[('old', 1), ('c', 2), ('p1', 3), ('c', 4), ('p2', 3)]
+)
+
+# Test with skipchild (note the difference caused by ordering)
+
+childann = decorate(childdata, childfctx)
+childann = _annotatepair([p1ann, p2ann], childfctx, childann, True,
+ diffopts)
+self.assertEqual(childann[0],
+[('old', 1), ('old', 2), ('p2', 2), ('p2', 2), ('p2', 3)]
+)
+
+childann = decorate(childdata, childfctx)
+childann = _annotatepair([p2ann, p1ann], childfctx, childann, True,
+ diffopts)
+self.assertEqual(childann[0],
+[('old', 1), ('old', 2), ('p1', 3), ('p1', 3), ('p2', 3)]
+)
+
+if __name__ == '__main__':
+import silenttestrunner
+silenttestrunner.main(__name__)
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1112,56 +1112,7 @@
 Additionally, if `skipchild` is True, replace all other lines with parent
 annotate data as well such that child is never blamed for any lines.
 
->>> oldfctx = b'old'
->>> p1fctx, p2fctx, childfctx = b'p1', b'p2', b'c'
->>> olddata = b'a\nb\n'
->>> p1data = b'a\nb\nc\n'
->>> p2data = b'a\nc\nd\n'
->>> childdata = b'a\nb2\nc\nc2\nd\n'
->>> diffopts = mdiff.diffopts()
-
->>> def decorate(text, rev):
-... return ([(rev, i) for i in xrange(1, text.count(b'\n') + 1)], text)
-
-Basic usage:
-
->>> oldann = decorate(olddata, oldfctx)
->>> p1ann = decorate(p1data, p1fctx)
->>> p1ann = _annotatepair([oldann], p1fctx, p1ann, False, diffopts)
->>> p1ann[0]
-[('old', 1), ('old', 2), ('p1', 3)]
->>> p2ann = decorate(p2data, p2fctx)
->>> p2ann = _annotatepair([oldann], p2fctx, p2ann, False, diffopts)
->>> p2ann[0]
-[('old', 1), ('p2', 2), ('p2', 3)]
-
-Test with multiple parents (note the difference caused by ordering):
-
->>> childann = decorate(childdata, childfctx)
->>> childann = _annotatepair([p1ann, p2ann], childfctx, childann, False,
-...  diffopts)
->>> childann[0]
-[('old', 1), ('c', 2), ('p2', 2), ('c', 4), ('p2', 3)]
-
->>> childann = decorate(childdata, childfctx)
->>> childann = _annotatepair([p2ann, p1ann], childfctx, childann, False,
-...  diffopts)
->>> childann[0]
-[('old', 1), ('c', 2), ('p1', 3), ('c', 4), ('p2', 3)]
-
-Test with skipchild (note the difference caused by ordering):
-
->>> childann = decorate(childdata, childfctx)
->>> childann = 

D899: annotate: track whether a particular annotation was the result of a skip

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We're going to expose this information in the UI in an upcoming patch.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/context.py
  tests/test-annotate.py

CHANGE DETAILS

diff --git a/tests/test-annotate.py b/tests/test-annotate.py
--- a/tests/test-annotate.py
+++ b/tests/test-annotate.py
@@ -80,20 +80,20 @@
  diffopts)
 self.assertEqual(childann[0], [
 annotateline('old', 1),
-annotateline('old', 2),
-annotateline('p2', 2),
-annotateline('p2', 2),
+annotateline('old', 2, True),
+annotateline('p2', 2, True),
+annotateline('p2', 2, True),
 annotateline('p2', 3),
 ])
 
 childann = decorate(childdata, childfctx)
 childann = _annotatepair([p2ann, p1ann], childfctx, childann, True,
  diffopts)
 self.assertEqual(childann[0], [
 annotateline('old', 1),
-annotateline('old', 2),
-annotateline('p1', 3),
-annotateline('p1', 3),
+annotateline('old', 2, True),
+annotateline('p1', 3, True),
+annotateline('p1', 3, True),
 annotateline('p2', 3),
 ])
 
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -,6 +,8 @@
 class annotateline(object):
 fctx = attr.ib()
 lineno = attr.ib(default=False)
+# Whether this annotation was the result of a skip-annotate.
+skip = attr.ib(default=False)
 
 def _annotatepair(parents, childfctx, child, skipchild, diffopts):
 r'''
@@ -1160,6 +1162,7 @@
 if child[0][bk].fctx == childfctx:
 ak = min(a1 + (bk - b1), a2 - 1)
 child[0][bk] = parent[0][ak]
+child[0][bk].skip = True
 else:
 remaining[idx][1].append((a1, a2, b1, b2))
 
@@ -1171,6 +1174,7 @@
 if child[0][bk].fctx == childfctx:
 ak = min(a1 + (bk - b1), a2 - 1)
 child[0][bk] = parent[0][ak]
+child[0][bk].skip = True
 return child
 
 class filectx(basefilectx):



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


D895: check-code: allow an exception for camelcase where required

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  unittest has a `maxDiff` parameter which has to be set to `None` in order for
  large enough failure diffs to be displayed. Add a comment to disable the
  camelcase check for `self.maxDiff = None` lines.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -273,7 +273,7 @@
 #(r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=',
 # "don't use underbars in identifiers"),
 (r'^\s+(self\.)?[A-Za-z][a-z0-9]+[A-Z]\w* = ',
- "don't use camelcase in identifiers"),
+ "don't use camelcase in identifiers", r'#.*camelcase-required'),
 (r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+',
  "linebreak after :"),
 (r'class\s[^( \n]+:', "old-style class, use class foo(object)",



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


D897: context: rename local 'attr' to 'attr_'

2017-10-02 Thread sid0 (Siddharth Agarwal)
sid0 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  In the next diff we're going to import mercurial.thirdparty.attr, and pyflakes
  complains about this if this rename isn't done.

REPOSITORY
  rHG Mercurial

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

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
@@ -2420,9 +2420,9 @@
 if reusable:
 # copy extra fields from originalfctx
 attrs = ['rawdata', 'rawflags', '_filenode', '_filerev']
-for attr in attrs:
-if util.safehasattr(originalfctx, attr):
-setattr(self, attr, getattr(originalfctx, attr))
+for attr_ in attrs:
+if util.safehasattr(originalfctx, attr_):
+setattr(self, attr_, getattr(originalfctx, attr_))
 
 def data(self):
 return self._datafunc()



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