Commits

Fred Yankowski committed ff8af5b

Make changes per http://mercurial.selenic.com/wiki/ApiChanges to work with Mercurial 2.2.
Basic shelve and unshelve functions seem to be working fine. Not extensively tested.
Not backward compatible with older API.

Comments (0)

Files changed (1)

 """
 
 from mercurial.i18n import _
-from mercurial import commands, cmdutil, hg, patch, repair, util, error
+from mercurial import commands, cmdutil, hg, patch, repair, util, error, scmutil
 from mercurial import extensions, fancyopts, simplemerge
 from mercurial.node import hex, bin
 import cStringIO, os, re, errno, tempfile, sys
         """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 = scmutil.opener(self.path)
         self.ui = ui
         self.applied = ''
         self.appliedfile = '.applied'
 
     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))) != []
+        return list(patch.diff(repo, match = scmutil.match(repo[None], pats, opts), opts = self.diffopts(opts))) != []
 
     def available(self):
         '''reads all available patches from the attic dir
                 adopts['reverse'] = True
             return orig(*adargs, **adopts)
 
-        epo = extensions.wrapfunction(patch, 'externalpatch', epwrapper)
+        epo = extensions.wrapfunction(patch, '_externalpatch', epwrapper)
         ado = extensions.wrapfunction(patch, 'applydiff', adwrapper)
-        files, success = {}, True
+        files, success = set(), 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.)
+                fuzz = patch.patch(self.ui, repo, self.join(patchfile), strip = 1,
+                                   files = files)
             except Exception, inst:
                 self.ui.note(str(inst) + '\n')
                 if not self.ui.verbose:
             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')
+            files = set()
+            patch.patch(self.ui, repo, self.join(patchfile), strip=1, files=files)
+
+        opener = scmutil.opener('.hg/attic')
         smo = extensions.wrapfunction(simplemerge, 'simplemerge', smwrapper)
         quiet = self.ui.quiet
         self.ui.quiet = True
             if msg and msg[-1] != '\n':
                 msg += '\n'
             fp.write(msg)
-        m = cmdutil.match(repo, pats, opts)
+        m = scmutil.match(repo[None], pats, opts)
         chunks = patch.diff(repo, match = m, opts = self.diffopts(opts))
         for chunk in chunks:
             fp.write(chunk)
         there isn't a patch applied'''
 
         # find added files in the user's chosen set
-        m = cmdutil.match(repo, pats, opts)
+        m = scmutil.match(repo[None], pats, opts)
         added = repo.status(match=m)[1]
 
         revertopts = { 'include': opts.get('include'),
         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)
+    msg = cmdutil.logmessage(ui, opts)
     if not msg:
         msg = message
     if opts.get('edit'):
             changes = repo.status(match = match)[:3]
             modified, added, removed = changes
             files = modified + added + removed
-            match = cmdutil.matchfiles(repo, files)
+            match = scmutil.matchfiles(repo, files)
         diffopts = repo.attic.diffopts( {'git':True, 'nodates':True})
         chunks = patch.diff(repo, repo.dirstate.parents()[0], match = match,
                             changes = changes, opts = diffopts)