D1827: scmutil: add warnmessage argument to unhidehashlikerevs function

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sat Jan 6 06:48:25 UTC 2018


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  While adding support for unhiding revs for commands which are not just read
  only, a need for showing custom messages for different command is found. This
  patch adds a new optional argument to unhidehashlikerevs() function which if
  passed will be the warning message displayed to user provided the function is
  called in "warn" mode.

REPOSITORY
  rHG Mercurial

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

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
@@ -1306,7 +1306,7 @@
     """
     return sink
 
-def unhidehashlikerevs(repo, specs, hiddentype):
+def unhidehashlikerevs(repo, specs, hiddentype, warnmessage=None):
     """parse the user specs and unhide changesets whose hash or revision number
     is passed.
 
@@ -1342,8 +1342,12 @@
     if hiddentype == 'warn':
         unfi = repo.unfiltered()
         revstr = ", ".join([pycompat.bytestr(unfi[l]) for l in revs])
-        repo.ui.warn(_("warning: accessing hidden changesets for write "
-                       "operation: %s\n") % revstr)
+        if warnmessage is None:
+            repo.ui.warn(_("warning: accessing hidden changesets for write "
+                           "operation: %s\n") % revstr)
+        else:
+            warnmessage += " %s\n"
+            repo.ui.warn(_(warnmessage) % revstr)
 
     # we have to use new filtername to separate branch/tags cache until we can
     # disbale these cache when revisions are dynamically pinned.



To: pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list