--- a/mercurial/commands.py Thu Jan 11 18:20:08 2018 +0800
+++ b/mercurial/commands.py Thu Jan 11 11:57:59 2018 +0000
@@ -4007,36 +4007,40 @@
"so a rev cannot be specified.")
raise error.Abort(err)
- pullopargs.update(opts.get('opargs', {}))
- modheads = exchange.pull(repo, other, heads=revs,
- force=opts.get('force'),
- bookmarks=opts.get('bookmark', ()),
- opargs=pullopargs).cgresult
-
- # brev is a name, which might be a bookmark to be activated at
- # the end of the update. In other words, it is an explicit
- # destination of the update
- brev = None
-
- if checkout:
- checkout = str(repo.changelog.rev(checkout))
-
- # order below depends on implementation of
- # hg.addbranchrevs(). opts['bookmark'] is ignored,
- # because 'checkout' is determined without it.
- if opts.get('rev'):
- brev = opts['rev'][0]
- elif opts.get('branch'):
- brev = opts['branch'][0]
- else:
- brev = branches[0]
- repo._subtoppath = source
- try:
- ret = postincoming(ui, repo, modheads, opts.get('update'),
- checkout, brev)
-
- finally:
- del repo._subtoppath
+ wlock = util.nullcontextmanager()
+ if opts.get('update'):
+ wlock = repo.wlock()
+ with wlock:
+ pullopargs.update(opts.get('opargs', {}))
+ modheads = exchange.pull(repo, other, heads=revs,
+ force=opts.get('force'),
+ bookmarks=opts.get('bookmark', ()),
+ opargs=pullopargs).cgresult
+
+ # brev is a name, which might be a bookmark to be activated at
+ # the end of the update. In other words, it is an explicit
+ # destination of the update
+ brev = None
+
+ if checkout:
+ checkout = str(repo.changelog.rev(checkout))
+
+ # order below depends on implementation of
+ # hg.addbranchrevs(). opts['bookmark'] is ignored,
+ # because 'checkout' is determined without it.
+ if opts.get('rev'):
+ brev = opts['rev'][0]
+ elif opts.get('branch'):
+ brev = opts['branch'][0]
+ else:
+ brev = branches[0]
+ repo._subtoppath = source
+ try:
+ ret = postincoming(ui, repo, modheads, opts.get('update'),
+ checkout, brev)
+
+ finally:
+ del repo._subtoppath
finally:
other.close()