fetch: lock repo across pull and commit
authorVadim Gelfer <vadim.gelfer@gmail.com>
Tue, 08 Aug 2006 16:40:08 -0700
changeset 2825 0496cfb05243
parent 2824 f362222cb8f8
child 2826 bce6918b0474
fetch: lock repo across pull and commit
hgext/fetch.py
--- a/hgext/fetch.py	Tue Aug 08 16:37:41 2006 -0700
+++ b/hgext/fetch.py	Tue Aug 08 16:40:08 2006 -0700
@@ -46,7 +46,7 @@
             message = (commands.logmessage(opts) or
                        (_('Automated merge with %s') % other.url()))
             n = repo.commit(mod + add + rem, message,
-                            opts['user'], opts['date'],
+                            opts['user'], opts['date'], lock=lock,
                             force_editor=opts.get('force_editor'))
             ui.status(_('new changeset %d:%s merges remote changes '
                         'with local\n') % (repo.changelog.rev(n),
@@ -61,7 +61,7 @@
             raise util.Abort(_("fetch -r doesn't work for remote repositories yet"))
         elif opts['rev']:
             revs = [other.lookup(rev) for rev in opts['rev']]
-        modheads = repo.pull(other, heads=revs)
+        modheads = repo.pull(other, heads=revs, lock=lock)
         return postincoming(other, modheads)
         
     parent, p2 = repo.dirstate.parents()
@@ -76,7 +76,11 @@
     if len(repo.heads()) > 1:
         raise util.Abort(_('multiple heads in this repository '
                            '(use "hg heads" and "hg merge" to merge them)'))
-    return pull()
+    lock = repo.lock()
+    try:
+        return pull()
+    finally:
+        lock.release()
 
 cmdtable = {
     'fetch':