Show More
@@ -28,17 +28,58 b" def fetch(ui, repo, source='default', **" | |||||
28 | See 'hg help dates' for a list of formats valid for -d/--date. |
|
28 | See 'hg help dates' for a list of formats valid for -d/--date. | |
29 | ''' |
|
29 | ''' | |
30 |
|
30 | |||
31 | def postincoming(other, modheads): |
|
31 | date = opts.get('date') | |
|
32 | if date: | |||
|
33 | opts['date'] = util.parsedate(date) | |||
|
34 | ||||
|
35 | parent, p2 = repo.dirstate.parents() | |||
|
36 | if parent != repo.changelog.tip(): | |||
|
37 | raise util.Abort(_('working dir not at tip ' | |||
|
38 | '(use "hg update" to check out tip)')) | |||
|
39 | ||||
|
40 | if p2 != nullid: | |||
|
41 | raise util.Abort(_('outstanding uncommitted merge')) | |||
|
42 | ||||
|
43 | wlock = lock = None | |||
|
44 | try: | |||
|
45 | wlock = repo.wlock() | |||
|
46 | lock = repo.lock() | |||
|
47 | mod, add, rem, del_ = repo.status()[:4] | |||
|
48 | ||||
|
49 | if mod or add or rem: | |||
|
50 | raise util.Abort(_('outstanding uncommitted changes')) | |||
|
51 | if del_: | |||
|
52 | raise util.Abort(_('working directory is missing some files')) | |||
|
53 | if len(repo.heads()) > 1: | |||
|
54 | raise util.Abort(_('multiple heads in this repository ' | |||
|
55 | '(use "hg heads" and "hg merge" to merge)')) | |||
|
56 | ||||
|
57 | cmdutil.setremoteconfig(ui, opts) | |||
|
58 | ||||
|
59 | other = hg.repository(ui, ui.expandpath(source)) | |||
|
60 | ui.status(_('pulling from %s\n') % | |||
|
61 | util.hidepassword(ui.expandpath(source))) | |||
|
62 | revs = None | |||
|
63 | if opts['rev']: | |||
|
64 | if not other.local(): | |||
|
65 | raise util.Abort(_("fetch -r doesn't work for remote " | |||
|
66 | "repositories yet")) | |||
|
67 | else: | |||
|
68 | revs = [other.lookup(rev) for rev in opts['rev']] | |||
|
69 | ||||
|
70 | modheads = repo.pull(other, heads=revs) | |||
32 | if modheads == 0: |
|
71 | if modheads == 0: | |
33 | return 0 |
|
72 | return 0 | |
34 | if modheads == 1: |
|
73 | if modheads == 1: | |
35 | return hg.clean(repo, repo.changelog.tip()) |
|
74 | return hg.clean(repo, repo.changelog.tip()) | |
|
75 | ||||
36 | newheads = repo.heads(parent) |
|
76 | newheads = repo.heads(parent) | |
37 | newchildren = [n for n in repo.heads(parent) if n != parent] |
|
77 | newchildren = [n for n in repo.heads(parent) if n != parent] | |
38 | newparent = parent |
|
78 | newparent = parent | |
39 | if newchildren: |
|
79 | if newchildren: | |
40 | newparent = newchildren[0] |
|
80 | newparent = newchildren[0] | |
41 | hg.clean(repo, newparent) |
|
81 | hg.clean(repo, newparent) | |
|
82 | ||||
42 | newheads = [n for n in repo.heads() if n != newparent] |
|
83 | newheads = [n for n in repo.heads() if n != newparent] | |
43 | if len(newheads) > 1: |
|
84 | if len(newheads) > 1: | |
44 | ui.status(_('not merging with %d other new heads ' |
|
85 | ui.status(_('not merging with %d other new heads ' | |
@@ -46,6 +87,7 b" def fetch(ui, repo, source='default', **" | |||||
46 | (len(newheads) - 1)) |
|
87 | (len(newheads) - 1)) | |
47 | return |
|
88 | return | |
48 | err = False |
|
89 | err = False | |
|
90 | ||||
49 | if newheads: |
|
91 | if newheads: | |
50 | # By default, we consider the repository we're pulling |
|
92 | # By default, we consider the repository we're pulling | |
51 | # *from* as authoritative, so we merge our changes into |
|
93 | # *from* as authoritative, so we merge our changes into | |
@@ -61,6 +103,7 b" def fetch(ui, repo, source='default', **" | |||||
61 | ui.status(_('merging with %d:%s\n') % |
|
103 | ui.status(_('merging with %d:%s\n') % | |
62 | (repo.changelog.rev(secondparent), short(secondparent))) |
|
104 | (repo.changelog.rev(secondparent), short(secondparent))) | |
63 | err = hg.merge(repo, secondparent, remind=False) |
|
105 | err = hg.merge(repo, secondparent, remind=False) | |
|
106 | ||||
64 | if not err: |
|
107 | if not err: | |
65 | mod, add, rem = repo.status()[:3] |
|
108 | mod, add, rem = repo.status()[:3] | |
66 | message = (cmdutil.logmessage(opts) or |
|
109 | message = (cmdutil.logmessage(opts) or | |
@@ -74,45 +117,6 b" def fetch(ui, repo, source='default', **" | |||||
74 | 'with local\n') % (repo.changelog.rev(n), |
|
117 | 'with local\n') % (repo.changelog.rev(n), | |
75 | short(n))) |
|
118 | short(n))) | |
76 |
|
119 | |||
77 | def pull(): |
|
|||
78 | cmdutil.setremoteconfig(ui, opts) |
|
|||
79 |
|
||||
80 | other = hg.repository(ui, ui.expandpath(source)) |
|
|||
81 | ui.status(_('pulling from %s\n') % |
|
|||
82 | util.hidepassword(ui.expandpath(source))) |
|
|||
83 | revs = None |
|
|||
84 | if opts['rev']: |
|
|||
85 | if not other.local(): |
|
|||
86 | raise util.Abort(_("fetch -r doesn't work for remote " |
|
|||
87 | "repositories yet")) |
|
|||
88 | else: |
|
|||
89 | revs = [other.lookup(rev) for rev in opts['rev']] |
|
|||
90 | modheads = repo.pull(other, heads=revs) |
|
|||
91 | return postincoming(other, modheads) |
|
|||
92 |
|
||||
93 | date = opts.get('date') |
|
|||
94 | if date: |
|
|||
95 | opts['date'] = util.parsedate(date) |
|
|||
96 |
|
||||
97 | parent, p2 = repo.dirstate.parents() |
|
|||
98 | if parent != repo.changelog.tip(): |
|
|||
99 | raise util.Abort(_('working dir not at tip ' |
|
|||
100 | '(use "hg update" to check out tip)')) |
|
|||
101 | if p2 != nullid: |
|
|||
102 | raise util.Abort(_('outstanding uncommitted merge')) |
|
|||
103 | wlock = lock = None |
|
|||
104 | try: |
|
|||
105 | wlock = repo.wlock() |
|
|||
106 | lock = repo.lock() |
|
|||
107 | mod, add, rem, del_ = repo.status()[:4] |
|
|||
108 | if mod or add or rem: |
|
|||
109 | raise util.Abort(_('outstanding uncommitted changes')) |
|
|||
110 | if del_: |
|
|||
111 | raise util.Abort(_('working directory is missing some files')) |
|
|||
112 | if len(repo.heads()) > 1: |
|
|||
113 | raise util.Abort(_('multiple heads in this repository ' |
|
|||
114 | '(use "hg heads" and "hg merge" to merge)')) |
|
|||
115 | return pull() |
|
|||
116 | finally: |
|
120 | finally: | |
117 | del lock, wlock |
|
121 | del lock, wlock | |
118 |
|
122 |
General Comments 0
You need to be logged in to leave comments.
Login now