Patchwork D1827: scmutil: add warnmessage argument to unhidehashlikerevs function

login
register
mail settings
Submitter phabricator
Date Jan. 6, 2018, 6:48 a.m.
Message ID <differential-rev-PHID-DREV-v5hgrnrhk5ezpbdcmqcm-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26580/
State Superseded
Headers show

Comments

phabricator - Jan. 6, 2018, 6:48 a.m.
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




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 10, 2018, 12:52 p.m.
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> scmutil.py:1350
> +            warnmessage += " %s\n"
> +            repo.ui.warn(_(warnmessage) % revstr)
>  

`_()` must wrap a string literal.

FWIW, `hiddentype == 'warn'` might not be that useful. See the
comment on the next patch.

REPOSITORY
  rHG Mercurial

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

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

Patch

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.