Charles Harley avatar Charles Harley committed e5b8777

Changes to support the API changes introduced in hg 1.9

Comments (0)

Files changed (1)

 
 diff -r 3ba1e5f03971 attic.py
 --- a/attic.py	Fri Dec 10 17:27:08 2010 -0500
-+++ b/attic.py	Tue Sep 20 22:12:19 2011 +0100
-@@ -39,11 +39,21 @@
++++ b/attic.py	Tue Sep 20 22:34:30 2011 +0100
+@@ -38,12 +38,23 @@
+     activate a patch to work on and merge its changes into the working copy
  """
  
++from inspect import getargspec
  from mercurial.i18n import _
 -from mercurial import commands, cmdutil, hg, patch, repair, util, error
 +from mercurial import commands, scmutil, cmdutil, hg, patch, repair, util, error
  normname = util.normpath
 +
 +# Opener init wrapper function to handle hg API changes.
-+def opener(*args, **kwargs):
++def opener_init(*args, **kwargs):
 +    if hasattr(scmutil, 'opener'):
 +        # hg >= 1.9
 +        return scmutil.opener(*args, **kwargs)
  def updatedir(*args, **kwargs):
      # updatedir moved from patch to cmdutil in hg 1.7
      if hasattr(patch, 'updatedir'):
-@@ -57,7 +67,7 @@
+@@ -57,7 +68,7 @@
          """initializes everything, this was copied from mq"""
          self.basepath = path
          self.path = patchdir or os.path.join(path, 'attic')
 -        self.opener = util.opener(self.path)
-+        self.opener = opener(self.path)
++        self.opener = opener_init(self.path)
          self.ui = ui
          self.applied = ''
          self.appliedfile = '.applied'
-@@ -95,7 +105,15 @@
+@@ -95,7 +106,15 @@
  
      def haschanges (self, repo, pats=[], opts={}):
          """checks if repository has changes or not"""
  
      def available(self):
          '''reads all available patches from the attic dir
-@@ -215,7 +233,7 @@
+@@ -215,7 +234,7 @@
              for k in files.keys():
                  files2[k.strip('\r')]=files[k]
              updatedir(self.ui, repo, files2, similarity=sim/100.)
 -        opener = util.opener('.hg/attic')
-+        opener = opener('.hg/attic')
++        opener = opener_init('.hg/attic')
          smo = extensions.wrapfunction(simplemerge, 'simplemerge', smwrapper)
          quiet = self.ui.quiet
          self.ui.quiet = True
-@@ -316,7 +334,14 @@
+@@ -316,7 +335,14 @@
              if msg and msg[-1] != '\n':
                  msg += '\n'
              fp.write(msg)
          chunks = patch.diff(repo, match = m, opts = self.diffopts(opts))
          for chunk in chunks:
              fp.write(chunk)
-@@ -329,7 +354,13 @@
+@@ -329,7 +355,13 @@
          there isn't a patch applied'''
  
          # find added files in the user's chosen set
          added = repo.status(match=m)[1]
  
          revertopts = { 'include': opts.get('include'),
+@@ -387,7 +419,15 @@
+         data = patch.extract(ui, open(s.join(s.applied), 'r'))
+         tmpname, message, user, date, branch, nodeid, p1, p2 = data
+         os.unlink(tmpname)
+-    msg = cmdutil.logmessage(opts)
++
++    args, _, _, _ = getargspec(cmdutil.logmessage)
++    if len(args) > 1:
++        # hg >= 1.9
++        msg = cmdutil.logmessage(ui, opts)
++    else:
++        # hg <= 1.8
++        msg = cmdutil.logmessage(opts)
++
+     if not msg:
+         msg = message
+     if opts.get('edit'):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.