Show More
@@ -24,29 +24,30 b" def fetch(ui, repo, source='default', **" | |||
|
24 | 24 | if modheads == 0: |
|
25 | 25 | return 0 |
|
26 | 26 | if modheads == 1: |
|
27 | return hg.update(repo, repo.changelog.tip()) | |
|
27 | return hg.update(repo, repo.changelog.tip(), wlock=wlock) | |
|
28 | 28 | newheads = repo.heads(parent) |
|
29 | 29 | newchildren = [n for n in repo.heads(parent) if n != parent] |
|
30 | 30 | newparent = parent |
|
31 | 31 | if newchildren: |
|
32 | 32 | newparent = newchildren[0] |
|
33 | hg.update(repo, newparent) | |
|
33 | hg.update(repo, newparent, wlock=wlock) | |
|
34 | 34 | newheads = [n for n in repo.heads() if n != newparent] |
|
35 | 35 | err = False |
|
36 | 36 | if newheads: |
|
37 | 37 | ui.status(_('merging with new head %d:%s\n') % |
|
38 | 38 | (repo.changelog.rev(newheads[0]), short(newheads[0]))) |
|
39 |
err = hg.update(repo, newheads[0], allow=True, remind=False |
|
|
39 | err = hg.update(repo, newheads[0], allow=True, remind=False, | |
|
40 | wlock=wlock) | |
|
40 | 41 | if not err and len(newheads) > 1: |
|
41 | 42 | ui.status(_('not merging with %d other new heads ' |
|
42 | 43 | '(use "hg heads" and "hg merge" to merge them)') % |
|
43 | 44 | (len(newheads) - 1)) |
|
44 | 45 | if not err: |
|
45 | mod, add, rem = repo.status()[:3] | |
|
46 | mod, add, rem = repo.status(wlock=wlock)[:3] | |
|
46 | 47 | message = (commands.logmessage(opts) or |
|
47 | 48 | (_('Automated merge with %s') % other.url())) |
|
48 | 49 | n = repo.commit(mod + add + rem, message, |
|
49 | opts['user'], opts['date'], lock=lock, | |
|
50 | opts['user'], opts['date'], lock=lock, wlock=wlock, | |
|
50 | 51 | force_editor=opts.get('force_editor')) |
|
51 | 52 | ui.status(_('new changeset %d:%s merges remote changes ' |
|
52 | 53 | 'with local\n') % (repo.changelog.rev(n), |
@@ -55,7 +56,7 b" def fetch(ui, repo, source='default', **" | |||
|
55 | 56 | commands.setremoteconfig(ui, opts) |
|
56 | 57 | |
|
57 | 58 | other = hg.repository(ui, ui.expandpath(source)) |
|
58 | ui.status(_('pulling from %s\n') % source) | |
|
59 | ui.status(_('pulling from %s\n') % ui.expandpath(source)) | |
|
59 | 60 | revs = None |
|
60 | 61 | if opts['rev'] and not other.local(): |
|
61 | 62 | raise util.Abort(_("fetch -r doesn't work for remote repositories yet")) |
@@ -70,17 +71,19 b" def fetch(ui, repo, source='default', **" | |||
|
70 | 71 | '(use "hg update" to check out tip)')) |
|
71 | 72 | if p2 != nullid: |
|
72 | 73 | raise util.Abort(_('outstanding uncommitted merge')) |
|
73 | mod, add, rem = repo.status()[:3] | |
|
74 | if mod or add or rem: | |
|
75 | raise util.Abort(_('outstanding uncommitted changes')) | |
|
76 | if len(repo.heads()) > 1: | |
|
77 | raise util.Abort(_('multiple heads in this repository ' | |
|
78 | '(use "hg heads" and "hg merge" to merge them)')) | |
|
74 | wlock = repo.wlock() | |
|
79 | 75 | lock = repo.lock() |
|
80 | 76 | try: |
|
77 | mod, add, rem = repo.status(wlock=wlock)[:3] | |
|
78 | if mod or add or rem: | |
|
79 | raise util.Abort(_('outstanding uncommitted changes')) | |
|
80 | if len(repo.heads()) > 1: | |
|
81 | raise util.Abort(_('multiple heads in this repository ' | |
|
82 | '(use "hg heads" and "hg merge" to merge)')) | |
|
81 | 83 | return pull() |
|
82 | 84 | finally: |
|
83 | 85 | lock.release() |
|
86 | wlock.release() | |
|
84 | 87 | |
|
85 | 88 | cmdtable = { |
|
86 | 89 | 'fetch': |
@@ -1177,22 +1177,29 b' class localrepository(repo.repository):' | |||
|
1177 | 1177 | else: |
|
1178 | 1178 | return subset |
|
1179 | 1179 | |
|
1180 | def pull(self, remote, heads=None, force=False): | |
|
1181 | l = self.lock() | |
|
1180 | def pull(self, remote, heads=None, force=False, lock=None): | |
|
1181 | mylock = False | |
|
1182 | if not lock: | |
|
1183 | lock = self.lock() | |
|
1184 | mylock = True | |
|
1182 | 1185 | |
|
1183 | fetch = self.findincoming(remote, force=force) | |
|
1184 | if fetch == [nullid]: | |
|
1185 | self.ui.status(_("requesting all changes\n")) | |
|
1186 | try: | |
|
1187 | fetch = self.findincoming(remote, force=force) | |
|
1188 | if fetch == [nullid]: | |
|
1189 | self.ui.status(_("requesting all changes\n")) | |
|
1186 | 1190 | |
|
1187 | if not fetch: | |
|
1188 | self.ui.status(_("no changes found\n")) | |
|
1189 | return 0 | |
|
1191 | if not fetch: | |
|
1192 | self.ui.status(_("no changes found\n")) | |
|
1193 | return 0 | |
|
1190 | 1194 | |
|
1191 | if heads is None: | |
|
1192 | cg = remote.changegroup(fetch, 'pull') | |
|
1193 | else: | |
|
1194 | cg = remote.changegroupsubset(fetch, heads, 'pull') | |
|
1195 | return self.addchangegroup(cg, 'pull', remote.url()) | |
|
1195 | if heads is None: | |
|
1196 | cg = remote.changegroup(fetch, 'pull') | |
|
1197 | else: | |
|
1198 | cg = remote.changegroupsubset(fetch, heads, 'pull') | |
|
1199 | return self.addchangegroup(cg, 'pull', remote.url()) | |
|
1200 | finally: | |
|
1201 | if mylock: | |
|
1202 | lock.release() | |
|
1196 | 1203 | |
|
1197 | 1204 | def push(self, remote, force=False, revs=None): |
|
1198 | 1205 | # there are two ways to push to remote repo: |
General Comments 0
You need to be logged in to leave comments.
Login now