D374: simplemerge: use contexts to read file data from, if passed

2017-08-19 Thread phillco (Phil Cohen)
phillco added inline comments.

INLINE COMMENTS

> martinvonz wrote in simplemerge.py:430
> What is this "post-filter data"? I didn't know hg had this feature. Something 
> like git' clean/smudge filters?

Yeah, exactly. I didn't know about it either. 
https://www.mercurial-scm.org/wiki/EncodeDecodeFilter?highlight=%28filter%29

Perhaps including that link in the comment, or in `wwritedata` (later, 
`decodeddata()`) might be a good idea.

REPOSITORY
  rHG Mercurial

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

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


D374: simplemerge: use contexts to read file data from, if passed

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

INLINE COMMENTS

> simplemerge.py:425
> +def readctx(ctx):
> +if not ctx:
> +return None

leftovers? doesn't seem to happen because you guard against it on lines 457-459

> simplemerge.py:430
> + 'using contexts')
> +# `wwritedata` is used to get the post-filter data from `ctx` (i.e.,
> +# what would have been in the working copy). Since merges were run in

What is this "post-filter data"? I didn't know hg had this feature. Something 
like git' clean/smudge filters?

REPOSITORY
  rHG Mercurial

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

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


D374: simplemerge: use contexts to read file data from, if passed

2017-08-15 Thread phillco (Phil Cohen)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8b91a4ff23ad: simplemerge: use contexts to read file data 
from, if passed (authored by phillco).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D374?vs=855=955

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

AFFECTED FILES
  mercurial/simplemerge.py
  tests/test-lfconvert.t

CHANGE DETAILS

diff --git a/tests/test-lfconvert.t b/tests/test-lfconvert.t
--- a/tests/test-lfconvert.t
+++ b/tests/test-lfconvert.t
@@ -128,7 +128,7 @@
   $ hg merge
   merging sub/maybelarge.dat and stuff/maybelarge.dat to stuff/maybelarge.dat
   merging sub/normal2 and stuff/normal2 to stuff/normal2
-  warning: $TESTTMP/bigfile-repo/stuff/maybelarge.dat looks like a binary 
file. (glob)
+  warning: stuff/maybelarge.dat looks like a binary file. (glob)
   warning: conflicts while merging stuff/maybelarge.dat! (edit, then use 'hg 
resolve --mark')
   0 files updated, 1 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to 
abandon
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -410,12 +410,30 @@
 
 def simplemerge(ui, localfile, basefile, otherfile,
 localctx=None, basectx=None, otherctx=None, repo=None, **opts):
+"""Performs the simplemerge algorithm.
+
+{local|base|other}ctx are optional. If passed, they (local/base/other) will
+be read from. You should pass explicit labels in this mode since the 
default
+is to use the file paths."""
 def readfile(filename):
 f = open(filename, "rb")
 text = f.read()
 f.close()
 return _verifytext(text, filename, ui, opts)
 
+def readctx(ctx):
+if not ctx:
+return None
+if not repo:
+raise error.ProgrammingError('simplemerge: repo must be passed if '
+ 'using contexts')
+# `wwritedata` is used to get the post-filter data from `ctx` (i.e.,
+# what would have been in the working copy). Since merges were run in
+# the working copy, and thus used post-filter data, we do the same to
+# maintain behavior.
+return repo.wwritedata(ctx.path(),
+   _verifytext(ctx.data(), ctx.path(), ui, opts))
+
 mode = opts.get('mode','merge')
 if mode == 'union':
 name_a = None
@@ -436,9 +454,9 @@
 raise error.Abort(_("can only specify three labels."))
 
 try:
-localtext = readfile(localfile)
-basetext = readfile(basefile)
-othertext = readfile(otherfile)
+localtext = readctx(localctx) if localctx else readfile(localfile)
+basetext = readctx(basectx) if basectx else readfile(basefile)
+othertext = readctx(otherctx) if otherctx else readfile(otherfile)
 except error.Abort:
 return 1
 



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


D374: simplemerge: use contexts to read file data from, if passed

2017-08-14 Thread phillco (Phil Cohen)
phillco created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/simplemerge.py
  tests/test-lfconvert.t

CHANGE DETAILS

diff --git a/tests/test-lfconvert.t b/tests/test-lfconvert.t
--- a/tests/test-lfconvert.t
+++ b/tests/test-lfconvert.t
@@ -128,7 +128,7 @@
   $ hg merge
   merging sub/maybelarge.dat and stuff/maybelarge.dat to stuff/maybelarge.dat
   merging sub/normal2 and stuff/normal2 to stuff/normal2
-  warning: $TESTTMP/bigfile-repo/stuff/maybelarge.dat looks like a binary 
file. (glob)
+  warning: stuff/maybelarge.dat looks like a binary file. (glob)
   warning: conflicts while merging stuff/maybelarge.dat! (edit, then use 'hg 
resolve --mark')
   0 files updated, 1 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to 
abandon
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -410,12 +410,30 @@
 
 def simplemerge(ui, localfile, basefile, otherfile,
 localctx=None, basectx=None, otherctx=None, repo=None, **opts):
+"""Performs the simplemerge algorithm.
+
+{local|base|other}ctx are optional. If passed, they (local/base/other) will
+be read from. You should pass explicit labels in this mode since the 
default
+is to use the file paths."""
 def readfile(filename):
 f = open(filename, "rb")
 text = f.read()
 f.close()
 return _verifytext(text, filename, ui, opts)
 
+def readctx(ctx):
+if not ctx:
+return None
+if not repo:
+raise error.ProgrammingError('simplemerge: repo must be passed if '
+ 'using contexts')
+# `wwritedata` is used to get the post-filter data from `ctx` (i.e.,
+# what would have been in the working copy). Since merges were run in
+# the working copy, and thus used post-filter data, we do the same to
+# maintain behavior.
+return repo.wwritedata(ctx.path(),
+   _verifytext(ctx.data(), ctx.path(), ui, opts))
+
 mode = opts.get('mode','merge')
 if mode == 'union':
 name_a = None
@@ -436,9 +454,9 @@
 raise error.Abort(_("can only specify three labels."))
 
 try:
-localtext = readfile(localfile)
-basetext = readfile(basefile)
-othertext = readfile(otherfile)
+localtext = readctx(localctx) if localctx else readfile(localfile)
+basetext = readctx(basectx) if basectx else readfile(basefile)
+othertext = readctx(otherctx) if otherctx else readfile(otherfile)
 except error.Abort:
 return 1
 



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