Charles Harley avatar Charles Harley committed ab84fae

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 21:37:11 2011 +0100
-@@ -39,11 +39,20 @@
++++ b/attic.py	Tue Sep 20 22:12:19 2011 +0100
+@@ -39,11 +39,21 @@
  """
  
  from mercurial.i18n import _
 +
 +# Opener init wrapper function to handle hg API changes.
 +def opener(*args, **kwargs):
-+    # util.opener was moved to scmutil in hg 1.9
 +    if hasattr(scmutil, 'opener'):
++        # hg >= 1.9
 +        return scmutil.opener(*args, **kwargs)
 +    else:
++        # hg <= 1.8
 +        return util.opener(*args, **kwargs)
 +
  def updatedir(*args, **kwargs):
      # updatedir moved from patch to cmdutil in hg 1.7
      if hasattr(patch, 'updatedir'):
-@@ -57,7 +66,7 @@
+@@ -57,7 +67,7 @@
          """initializes everything, this was copied from mq"""
          self.basepath = path
          self.path = patchdir or os.path.join(path, 'attic')
          self.ui = ui
          self.applied = ''
          self.appliedfile = '.applied'
-@@ -215,7 +224,7 @@
+@@ -95,7 +105,15 @@
+ 
+     def haschanges (self, repo, pats=[], opts={}):
+         """checks if repository has changes or not"""
+-        return list(patch.diff(repo, match = cmdutil.match(repo, pats, opts), opts = self.diffopts(opts))) != []
++
++        try:
++            # hg >= 1.9
++            m = scmutil.match(repo[None], pats, opts)
++        except ImportError:
++            # hg <= 1.8
++            m = cmdutil.match(repo, pats, opts)
++
++        return list(patch.diff(repo, match = m, opts = self.diffopts(opts))) != []
+ 
+     def available(self):
+         '''reads all available patches from the attic dir
+@@ -215,7 +233,7 @@
              for k in files.keys():
                  files2[k.strip('\r')]=files[k]
              updatedir(self.ui, repo, files2, similarity=sim/100.)
          smo = extensions.wrapfunction(simplemerge, 'simplemerge', smwrapper)
          quiet = self.ui.quiet
          self.ui.quiet = True
+@@ -316,7 +334,14 @@
+             if msg and msg[-1] != '\n':
+                 msg += '\n'
+             fp.write(msg)
+-        m = cmdutil.match(repo, pats, opts)
++
++        try:
++            # hg >= 1.9
++            m = scmutil.match(repo[None], pats, opts)
++        except ImportError:
++            # hg <= 1.8
++            m = cmdutil.match(repo, pats, opts)
++
+         chunks = patch.diff(repo, match = m, opts = self.diffopts(opts))
+         for chunk in chunks:
+             fp.write(chunk)
+@@ -329,7 +354,13 @@
+         there isn't a patch applied'''
+ 
+         # find added files in the user's chosen set
+-        m = cmdutil.match(repo, pats, opts)
++        try:
++            # hg >= 1.9
++            m = scmutil.match(repo[None], pats, opts)
++        except ImportError:
++            # hg <= 1.8
++            m = cmdutil.match(repo, pats, opts)
++
+         added = repo.status(match=m)[1]
+ 
+         revertopts = { 'include': opts.get('include'),
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.