Commits

Charles Harley  committed 823c232

More changes to support the API changes introduced in hg 1.9

  • Participants
  • Parent commits e5b8777

Comments (0)

Files changed (1)

File hg-1.9-update

 
 diff -r 3ba1e5f03971 attic.py
 --- a/attic.py	Fri Dec 10 17:27:08 2010 -0500
-+++ b/attic.py	Tue Sep 20 22:34:30 2011 +0100
++++ b/attic.py	Thu Sep 29 23:14:49 2011 +0100
 @@ -38,12 +38,23 @@
      activate a patch to work on and merge its changes into the working copy
  """
  
      def available(self):
          '''reads all available patches from the attic dir
-@@ -215,7 +234,7 @@
-             for k in files.keys():
-                 files2[k.strip('\r')]=files[k]
-             updatedir(self.ui, repo, files2, similarity=sim/100.)
+@@ -170,21 +189,32 @@
+                 adopts['reverse'] = True
+             return orig(*adargs, **adopts)
+ 
+-        epo = extensions.wrapfunction(patch, 'externalpatch', epwrapper)
++        if not hasattr(patch, 'workingbackend'):
++            # hg <= 1.8
++            epo = extensions.wrapfunction(patch, 'externalpatch', epwrapper)
++
+         ado = extensions.wrapfunction(patch, 'applydiff', adwrapper)
+         files, success = {}, True
+         try:
+             try:
+-                fuzz = patch.patch(self.join(patchfile), self.ui, strip = 1,
+-                                   cwd = repo.root, files = files)
+-                updatedir(self.ui, repo, files, similarity = sim/100.)
++                if hasattr(patch, 'workingbackend'):
++                    # hg >= 1.9
++                    files = set()
++                    fuzz = patch.patch(self.ui, repo, self.join(patchfile), strip=1, files=files)
++                else:
++                    # hg <= 1.8
++                    fuzz = patch.patch(self.join(patchfile), self.ui, strip = 1,
++                                       cwd = repo.root, files = files)
++                    updatedir(self.ui, repo, files, similarity = sim/100.)
+             except Exception, inst:
+                 self.ui.note(str(inst) + '\n')
+                 if not self.ui.verbose:
+                     self.ui.warn('patch failed, unable to continue (try -v)\n')
+                 success = False
+         finally:
+-            patch.externalpatch = epo
++            if not hasattr(patch, 'workingbackend'):
++                # hg <= 1.8
++                patch.externalpatch = epo
+             patch.applydiff = ado
+         return success
+ 
+@@ -209,13 +239,23 @@
+             fp.close()
+ 
+         def applydiff(name):
+-            files = {}
+-            patch.patch(self.join(patchfile), self.ui, strip=1, files=files)
+-            files2 = {}
+-            for k in files.keys():
+-                files2[k.strip('\r')]=files[k]
+-            updatedir(self.ui, repo, files2, similarity=sim/100.)
 -        opener = util.opener('.hg/attic')
++            if hasattr(patch, 'workingbackend'):
++                # hg >= 1.9
++                files = set()
++                patch.patch(self.ui, repo, self.join(patchfile), strip=1, files=files)
++                files2 = {}
++                for item in files:
++                    files2[item.strip('\r')]=item
++            else:
++                # hg <= 1.8
++                files = {}
++                patch.patch(self.join(patchfile), self.ui, strip=1, files=files)
++                files2 = {}
++                for k in files.keys():
++                    files2[k.strip('\r')]=files[k]
++                updatedir(self.ui, repo, files2, similarity=sim/100.)
++
 +        opener = opener_init('.hg/attic')
          smo = extensions.wrapfunction(simplemerge, 'simplemerge', smwrapper)
          quiet = self.ui.quiet
          self.ui.quiet = True
-@@ -316,7 +335,14 @@
+@@ -316,7 +356,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 +355,13 @@
+@@ -329,7 +376,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 @@
+@@ -387,7 +440,15 @@
          data = patch.extract(ui, open(s.join(s.applied), 'r'))
          tmpname, message, user, date, branch, nodeid, p1, p2 = data
          os.unlink(tmpname)