1. Dan Villiom Podlaski Christiansen
  2. perfarce-hacked

Commits

Dan Villiom Podlaski Christiansen  committed d7b724e

add locking during pull

  • Participants
  • Parent commits d777c40
  • Branches default

Comments (0)

Files changed (1)

File perfarce.py

View file
  • Ignore whitespace
     tags = {}
 
     try:
+        lock = repo.lock()
+
         for i, c in enumerate(changes, start=1):
             ui.note(_('change %s\n') % c)
             cl = client.describe(c)
             ui.note(_('added changeset %d:%s\n') % (ctx.rev(), ctx))
 
     finally:
+        lock.release()
+        del lock
+
         if hasattr(ui, 'progress'):
             ui.progress('pull', None)
 
         if tags:
-            p4rev, p4id = client.find()
-            ctx = repo[p4rev]
+            try:
+                lock = repo.lock()
 
-            if '.hgtags' in ctx:
-                tagdata = [ctx.filectx('.hgtags').data()]
-            else:
-                tagdata = []
+                p4rev, p4id = client.find()
+                ctx = repo[p4rev]
 
-            desc = ['p4 tags']
-            for l in sorted(tags):
-                t = tags[l]
-                desc.append('   %s @ %d' % (l, t[0]))
-                tagdata.append('%s %s\n' % (t[1], l))
+                if '.hgtags' in ctx:
+                    tagdata = [ctx.filectx('.hgtags').data()]
+                else:
+                    tagdata = []
 
-            def getfilectx(repo, memctx, fn):
-                'callback to read file data'
-                assert fn=='.hgtags'
-                return context.memfilectx(fn, ''.join(tagdata), False, False, None)
+                desc = ['p4 tags']
+                for l in sorted(tags):
+                    t = tags[l]
+                    desc.append('   %s @ %d' % (l, t[0]))
+                    tagdata.append('%s %s\n' % (t[1], l))
 
-            ctx = context.memctx(repo, (p4rev, None), '\n'.join(desc),
-                                 ['.hgtags'], getfilectx)
-            p4rev = repo.commitctx(ctx)
-            ctx = repo[p4rev]
-            ui.note(_('added changeset %d:%s\n') % (ctx.rev(), ctx))
+                def getfilectx(repo, memctx, fn):
+                    'callback to read file data'
+                    assert fn=='.hgtags'
+                    return context.memfilectx(fn, ''.join(tagdata), False,
+                                              False, None)
+
+                ctx = context.memctx(repo, (p4rev, None), '\n'.join(desc),
+                                     ['.hgtags'], getfilectx)
+                p4rev = repo.commitctx(ctx)
+                ctx = repo[p4rev]
+                ui.note(_('added changeset %d:%s\n') % (ctx.rev(), ctx))
+
+            finally:
+                lock.release()
+                del lock
+
 
     if opts['update']:
         return hg.update(repo, 'tip')