D581: scmutil: add formatter a optional arg to cleanupnodes to show hash changes

2017-10-04 Thread pulkit (Pulkit Goyal)
pulkit abandoned this revision.
pulkit added a comment.


  Send an updated version as https://phab.mercurial-scm.org/D933 and 
https://phab.mercurial-scm.org/D934.

REPOSITORY
  rHG Mercurial

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

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


D581: scmutil: add formatter a optional arg to cleanupnodes to show hash changes

2017-08-31 Thread pulkit (Pulkit Goyal)
pulkit planned changes to this revision.
pulkit added a comment.


  As per discussion with @quark , "-T should be specifying the template 
content, instead of just the template type".

REPOSITORY
  rHG Mercurial

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

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


D581: scmutil: add formatter a optional arg to cleanupnodes to show hash changes

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


  In the previous version, I have suggested making `changes` part of template 
language instead of a flag, like `-T '{changes|json}'` instead of `--changes -T 
'json'`. That's generally more flexible because people can use the template 
language (ex. if they only want newnode, or they want colors, etc.). Have you 
considered that? Or does that have some technical difficulties?

REPOSITORY
  rHG Mercurial

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

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


D581: scmutil: add formatter a optional arg to cleanupnodes to show hash changes

2017-08-31 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 1474.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D581?vs=1473=1474

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

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -576,7 +576,7 @@
 def __contains__(self, node):
 return self._revcontains(self._torev(node))
 
-def cleanupnodes(repo, mapping, operation):
+def cleanupnodes(repo, mapping, operation, fm=None):
 """do common cleanups when old nodes are replaced by new nodes
 
 That includes writing obsmarkers or stripping nodes, and moving bookmarks.
@@ -646,6 +646,19 @@
 from . import repair # avoid import cycle
 repair.delayedstrip(repo.ui, repo, list(mapping), operation)
 
+# Display the hash changes if a formatter instance is passed.
+if fm:
+oldnodes = sorted(mapping.keys())
+hexfunc = fm.hexfunc
+label = 'cleanupnodes'
+for node in oldnodes:
+newnodes = mapping[node]
+if len(newnodes) == 1:
+newnode = newnodes[0]
+fm.startitem()
+fm.write('oldnode', '%s -> ', hexfunc(node), label=label)
+fm.write('newnode', '%s\n', hexfunc(newnode), label=label)
+
 def addremove(repo, matcher, prefix, opts=None, dry_run=None, similarity=None):
 if opts is None:
 opts = {}



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


D581: scmutil: add formatter a optional arg to cleanupnodes to show hash changes

2017-08-31 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 1473.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D581?vs=1471=1473

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

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -576,7 +576,7 @@
 def __contains__(self, node):
 return self._revcontains(self._torev(node))
 
-def cleanupnodes(repo, mapping, operation):
+def cleanupnodes(repo, mapping, operation, fm=None):
 """do common cleanups when old nodes are replaced by new nodes
 
 That includes writing obsmarkers or stripping nodes, and moving bookmarks.
@@ -646,6 +646,20 @@
 from . import repair # avoid import cycle
 repair.delayedstrip(repo.ui, repo, list(mapping), operation)
 
+# Display the hash changes if a formatter instance is passed.
+if fm:
+oldnodes = sorted(mapping.keys())
+hexfunc = fm.hexfunc
+label = 'cleanupnodes'
+for node in oldnodes:
+newnodes = mapping[node]
+if len(newnodes) == 1:
+newnode = newnodes[0]
+fm.startitem()
+fm.write('oldnode', '%s is changed to ', hexfunc(node),
+label=label)
+fm.write('newnode', '%s\n', hexfunc(newnode), label=label)
+
 def addremove(repo, matcher, prefix, opts=None, dry_run=None, similarity=None):
 if opts is None:
 opts = {}



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


D581: scmutil: add formatter a optional arg to cleanupnodes to show hash changes

2017-08-31 Thread akushner (Aaron Kushner)
akushner added inline comments.

INLINE COMMENTS

> scmutil.py:660
> +fm.startitem()
> +fm.write('oldnode', '%s is changed to ', hexfunc(node),
> +label=label)

Perhaps "is changed to" should be:

"became"

or even

"->"

REPOSITORY
  rHG Mercurial

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

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


D581: scmutil: add formatter a optional arg to cleanupnodes to show hash changes

2017-08-31 Thread pulkit (Pulkit Goyal)
pulkit planned changes to this revision.
pulkit added inline comments.

INLINE COMMENTS

> akushner wrote in scmutil.py:649-650
> Some typos in the comment. Is this what you meant?
> 
>   # If a formatter object is passed, display the hash changes
> 
> or was this a question for the reviewers?

Oops, yes I meant that. Was in a hurry and left that comment. Thanks for 
catching.

REPOSITORY
  rHG Mercurial

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

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


D581: scmutil: add formatter a optional arg to cleanupnodes to show hash changes

2017-08-31 Thread akushner (Aaron Kushner)
akushner added inline comments.

INLINE COMMENTS

> scmutil.py:649-650
>  
> +# Is a formatter object is paased? Do we want to display the hash
> +# changes also?
> +if fm:

Some typos in the comment. Is this what you meant?

  # If a formatter object is passed, display the hash changes

or was this a question for the reviewers?

REPOSITORY
  rHG Mercurial

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

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


D581: scmutil: add formatter a optional arg to cleanupnodes to show hash changes

2017-08-31 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  scmutil.cleanupnodes is used by rebase, histedit and amend to do create
  obsmarkers or strip nodes. This patch adds functionality to cleanupnodes to 
take
  a formatter and if a formatter is passed, it will show the hash changes also.
  
  The formatter is a optional argument, so if a command needs to show the hash
  changes it can pass a formatter and if not, things work.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -576,7 +576,7 @@
 def __contains__(self, node):
 return self._revcontains(self._torev(node))
 
-def cleanupnodes(repo, mapping, operation):
+def cleanupnodes(repo, mapping, operation, fm=None):
 """do common cleanups when old nodes are replaced by new nodes
 
 That includes writing obsmarkers or stripping nodes, and moving bookmarks.
@@ -646,6 +646,21 @@
 from . import repair # avoid import cycle
 repair.delayedstrip(repo.ui, repo, list(mapping), operation)
 
+# Is a formatter object is paased? Do we want to display the hash
+# changes also?
+if fm:
+oldnodes = sorted(mapping.keys())
+hexfunc = fm.hexfunc
+label = 'cleanupnodes'
+for node in oldnodes:
+newnodes = mapping[node]
+if len(newnodes) == 1:
+newnode = newnodes[0]
+fm.startitem()
+fm.write('oldnode', '%s is changed to ', hexfunc(node),
+label=label)
+fm.write('newnode', '%s\n', hexfunc(newnode), label=label)
+
 def addremove(repo, matcher, prefix, opts=None, dry_run=None, similarity=None):
 if opts is None:
 opts = {}



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