hgext/fetch.py
changeset 2814 0496cfb05243
parent 2813 f362222cb8f8
child 2816 2a0c599f7bb0
equal deleted inserted replaced
2813:f362222cb8f8 2814:0496cfb05243
    44         if not err:
    44         if not err:
    45             mod, add, rem = repo.status()[:3]
    45             mod, add, rem = repo.status()[:3]
    46             message = (commands.logmessage(opts) or
    46             message = (commands.logmessage(opts) or
    47                        (_('Automated merge with %s') % other.url()))
    47                        (_('Automated merge with %s') % other.url()))
    48             n = repo.commit(mod + add + rem, message,
    48             n = repo.commit(mod + add + rem, message,
    49                             opts['user'], opts['date'],
    49                             opts['user'], opts['date'], lock=lock,
    50                             force_editor=opts.get('force_editor'))
    50                             force_editor=opts.get('force_editor'))
    51             ui.status(_('new changeset %d:%s merges remote changes '
    51             ui.status(_('new changeset %d:%s merges remote changes '
    52                         'with local\n') % (repo.changelog.rev(n),
    52                         'with local\n') % (repo.changelog.rev(n),
    53                                            short(n)))
    53                                            short(n)))
    54     def pull():
    54     def pull():
    59         revs = None
    59         revs = None
    60         if opts['rev'] and not other.local():
    60         if opts['rev'] and not other.local():
    61             raise util.Abort(_("fetch -r doesn't work for remote repositories yet"))
    61             raise util.Abort(_("fetch -r doesn't work for remote repositories yet"))
    62         elif opts['rev']:
    62         elif opts['rev']:
    63             revs = [other.lookup(rev) for rev in opts['rev']]
    63             revs = [other.lookup(rev) for rev in opts['rev']]
    64         modheads = repo.pull(other, heads=revs)
    64         modheads = repo.pull(other, heads=revs, lock=lock)
    65         return postincoming(other, modheads)
    65         return postincoming(other, modheads)
    66         
    66         
    67     parent, p2 = repo.dirstate.parents()
    67     parent, p2 = repo.dirstate.parents()
    68     if parent != repo.changelog.tip():
    68     if parent != repo.changelog.tip():
    69         raise util.Abort(_('working dir not at tip '
    69         raise util.Abort(_('working dir not at tip '
    74     if mod or add or rem:
    74     if mod or add or rem:
    75         raise util.Abort(_('outstanding uncommitted changes'))
    75         raise util.Abort(_('outstanding uncommitted changes'))
    76     if len(repo.heads()) > 1:
    76     if len(repo.heads()) > 1:
    77         raise util.Abort(_('multiple heads in this repository '
    77         raise util.Abort(_('multiple heads in this repository '
    78                            '(use "hg heads" and "hg merge" to merge them)'))
    78                            '(use "hg heads" and "hg merge" to merge them)'))
    79     return pull()
    79     lock = repo.lock()
       
    80     try:
       
    81         return pull()
       
    82     finally:
       
    83         lock.release()
    80 
    84 
    81 cmdtable = {
    85 cmdtable = {
    82     'fetch':
    86     'fetch':
    83     (fetch,
    87     (fetch,
    84      [('e', 'ssh', '', _('specify ssh command to use')),
    88      [('e', 'ssh', '', _('specify ssh command to use')),