Commits

Paul McLanahan committed 5d0d7b5

Upgraded hgshelve hg extension for hg 1.9 compat.
Added Sublimetext 2 project file ignore to global hg ignore file.

  • Participants
  • Parent commits 65765a5

Comments (0)

Files changed (2)

File dotfiles/.hgext/hgshelve.py

 
 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
 
-def internalpatch(patchobj, ui, strip, cwd, reverse=False, files={}):
-    """use builtin patch to apply <patchobj> to the working directory.
-    returns whether patch was applied with fuzz factor.
-    
-    Adapted from patch.internalpatch() to support reverse patching.
-    """
-
-    eolmode = ui.config('patch', 'eol', 'strict')
-
-    if eolmode.lower() not in patch.eolmodes:
-        raise util.Abort(_('Unsupported line endings type: %s') % eolmode)
-    
-    try:
-        fp = file(patchobj, 'rb')
-    except TypeError:
-        fp = patchobj
-    if cwd:
-        curdir = os.getcwd()
-        os.chdir(cwd)
-    try:
-        ret = patch.applydiff(ui, fp, files, strip=strip, eolmode=eolmode)
-    finally:
-        if cwd:
-            os.chdir(curdir)
-    if ret < 0:
-        raise PatchError
-    return ret > 0
-
 def scanpatch(fp):
     lr = patch.linereader(fp)
 
                 if dopatch:
                     ui.debug('applying patch\n')
                     ui.debug(fp.getvalue())
-                    patch.internalpatch(fp, ui, 1, repo.root)
+                    patch.internalpatch(ui, repo, fp, 1)
                 del fp
 
                 # 3c. apply filtered patch to clean repo (shelve)
     # wrap ui.write so diff output can be labeled/colorized
     def wrapwrite(orig, *args, **kw):
         label = kw.pop('label', '')
+        if label: label += ' '
         for chunk, l in patch.difflabel(lambda: args):
             orig(chunk, label=label + l)
     oldwrite = ui.write
         patch_diff = repo.opener(shelfpath).read()
         fp = cStringIO.StringIO(patch_diff)
         if opts['inspect']:
-            ui.status(fp.getvalue())
+            # wrap ui.write so diff output can be labeled/colorized
+            def wrapwrite(orig, *args, **kw):
+                label = kw.pop('label', '')
+                if label: label += ' '
+                for chunk, l in patch.difflabel(lambda: args):
+                    orig(chunk, label=label + l)
+            oldwrite = ui.write
+            extensions.wrapfunction(ui, 'write', wrapwrite)
+            try:
+                ui.status(fp.getvalue())
+            finally:
+                ui.write = oldwrite
         else:
             files = []
             ac = parsepatch(fp)
             try:
                 try:
                     fp.seek(0)
-                    internalpatch(fp, ui, 1, repo.root)
+                    patch.internalpatch(ui, repo, fp, 1)
                     patchdone = 1
                 except:
                     if opts['force']:

File dotfiles/.hgignore

 .tox
 Vagrantfile
 *.chproj
+*.sublime-workspace