##// END OF EJS Templates
merge with stable
Matt Mackall -
r15513:64675914 merge default
parent child Browse files
Show More
@@ -0,0 +1,114 b''
1 $ echo "[extensions]" >> $HGRCPATH
2 $ echo "mq=" >> $HGRCPATH
3
4 $ tipparents() {
5 > hg parents --template "{rev}:{node|short} {desc|firstline}\n" -r tip
6 > }
7
8 Test import and merge diffs
9
10 $ hg init repo
11 $ cd repo
12 $ echo a > a
13 $ hg ci -Am adda
14 adding a
15 $ echo a >> a
16 $ hg ci -m changea
17 $ echo c > c
18 $ hg ci -Am addc
19 adding c
20 $ hg up 0
21 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
22 $ echo b > b
23 $ hg ci -Am addb
24 adding b
25 created new head
26 $ hg up 1
27 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
28 $ hg merge 3
29 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
30 (branch merge, don't forget to commit)
31 $ hg ci -m merge
32 $ hg export . > ../merge.diff
33 $ cd ..
34 $ hg clone -r2 repo repo2
35 adding changesets
36 adding manifests
37 adding file changes
38 added 3 changesets with 3 changes to 2 files
39 updating to branch default
40 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
41 $ cd repo2
42 $ hg pull -r3 ../repo
43 pulling from ../repo
44 searching for changes
45 adding changesets
46 adding manifests
47 adding file changes
48 added 1 changesets with 1 changes to 1 files (+1 heads)
49 (run 'hg heads' to see heads, 'hg merge' to merge)
50
51 Test without --exact and diff.p1 == workingdir.p1
52
53 $ hg up 1
54 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
55 $ hg import ../merge.diff
56 applying ../merge.diff
57 $ tipparents
58 1:540395c44225 changea
59 3:102a90ea7b4a addb
60 $ hg strip --no-backup tip
61 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
62
63 Test without --exact and diff.p1 != workingdir.p1
64
65 $ hg up 2
66 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
67 $ hg import ../merge.diff
68 applying ../merge.diff
69 $ tipparents
70 2:890ecaa90481 addc
71 $ hg strip --no-backup tip
72 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
73
74 Test with --exact
75
76 $ hg import --exact ../merge.diff
77 applying ../merge.diff
78 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
79 $ tipparents
80 1:540395c44225 changea
81 3:102a90ea7b4a addb
82 $ hg strip --no-backup tip
83 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
84
85 Test with --bypass and diff.p1 == workingdir.p1
86
87 $ hg up 1
88 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
89 $ hg import --bypass ../merge.diff
90 applying ../merge.diff
91 $ tipparents
92 1:540395c44225 changea
93 3:102a90ea7b4a addb
94 $ hg strip --no-backup tip
95
96 Test with --bypass and diff.p1 != workingdir.p1
97
98 $ hg up 2
99 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 $ hg import --bypass ../merge.diff
101 applying ../merge.diff
102 $ tipparents
103 2:890ecaa90481 addc
104 $ hg strip --no-backup tip
105
106 Test with --bypass and --exact
107
108 $ hg import --bypass --exact ../merge.diff
109 applying ../merge.diff
110 $ tipparents
111 1:540395c44225 changea
112 3:102a90ea7b4a addb
113 $ hg strip --no-backup tip
114
@@ -2570,15 +2570,32 b' def graft(ui, repo, *revs, **opts):'
2570 if not revs:
2570 if not revs:
2571 return -1
2571 return -1
2572
2572
2573 # analyze revs for earlier grafts
2574 ids = {}
2575 for ctx in repo.set("%ld", revs):
2576 ids[ctx.hex()] = ctx.rev()
2577 n = ctx.extra().get('source')
2578 if n:
2579 ids[n] = ctx.rev()
2580
2573 # check ancestors for earlier grafts
2581 # check ancestors for earlier grafts
2574 ui.debug('scanning for duplicate grafts\n')
2582 ui.debug('scanning for duplicate grafts\n')
2575 for ctx in repo.set("::. - ::%ld", revs):
2583 for ctx in repo.set("::. - ::%ld", revs):
2576 n = ctx.extra().get('source')
2584 n = ctx.extra().get('source')
2577 if n and n in repo:
2585 if n in ids:
2578 r = repo[n].rev()
2586 r = repo[n].rev()
2579 if r in revs:
2587 if r in revs:
2580 ui.warn(_('skipping already grafted revision %s\n') % r)
2588 ui.warn(_('skipping already grafted revision %s\n') % r)
2581 revs.remove(r)
2589 revs.remove(r)
2590 elif ids[n] in revs:
2591 ui.warn(_('skipping already grafted revision %s '
2592 '(same origin %d)\n') % (ids[n], r))
2593 revs.remove(ids[n])
2594 elif ctx.hex() in ids:
2595 r = ids[ctx.hex()]
2596 ui.warn(_('skipping already grafted revision %s '
2597 '(was grafted from %d)\n') % (r, ctx.rev()))
2598 revs.remove(r)
2582 if not revs:
2599 if not revs:
2583 return -1
2600 return -1
2584
2601
@@ -2613,7 +2630,10 b' def graft(ui, repo, *revs, **opts):'
2613 cont = False
2630 cont = False
2614
2631
2615 # commit
2632 # commit
2616 extra = {'source': ctx.hex()}
2633 source = ctx.extra().get('source')
2634 if not source:
2635 source = ctx.hex()
2636 extra = {'source': source}
2617 user = ctx.user()
2637 user = ctx.user()
2618 if opts.get('user'):
2638 if opts.get('user'):
2619 user = opts['user']
2639 user = opts['user']
@@ -3513,6 +3533,12 b' def import_(ui, repo, patch1=None, *patc'
3513 try:
3533 try:
3514 p1 = repo[p1]
3534 p1 = repo[p1]
3515 p2 = repo[p2]
3535 p2 = repo[p2]
3536 # Without any options, consider p2 only if the
3537 # patch is being applied on top of the recorded
3538 # first parent.
3539 if p1 != parents[0]:
3540 p1 = parents[0]
3541 p2 = repo[nullid]
3516 except error.RepoError:
3542 except error.RepoError:
3517 p1, p2 = parents
3543 p1, p2 = parents
3518 else:
3544 else:
@@ -3520,9 +3546,9 b' def import_(ui, repo, patch1=None, *patc'
3520
3546
3521 n = None
3547 n = None
3522 if update:
3548 if update:
3523 if opts.get('exact') and p1 != parents[0]:
3549 if p1 != parents[0]:
3524 hg.clean(repo, p1.node())
3550 hg.clean(repo, p1.node())
3525 if p1 != parents[0] and p2 != parents[1]:
3551 if p2 != parents[1]:
3526 repo.dirstate.setparents(p1.node(), p2.node())
3552 repo.dirstate.setparents(p1.node(), p2.node())
3527
3553
3528 if opts.get('exact') or opts.get('import_branch'):
3554 if opts.get('exact') or opts.get('import_branch'):
@@ -3536,7 +3562,10 b' def import_(ui, repo, patch1=None, *patc'
3536 if message:
3562 if message:
3537 msgs.append(message)
3563 msgs.append(message)
3538 else:
3564 else:
3539 if opts.get('exact'):
3565 if opts.get('exact') or p2:
3566 # If you got here, you either use --force and know what
3567 # you are doing or used --exact or a merge patch while
3568 # being updated to its first parent.
3540 m = None
3569 m = None
3541 else:
3570 else:
3542 m = scmutil.matchfiles(repo, files or [])
3571 m = scmutil.matchfiles(repo, files or [])
@@ -178,9 +178,9 b' def prepush(repo, remote, force, revs, n'
178 hint = _("did you forget to merge? "
178 hint = _("did you forget to merge? "
179 "use push -f to force")
179 "use push -f to force")
180 if branch is not None:
180 if branch is not None:
181 repo.ui.note("new remote heads on branch '%s'\n" % branch)
181 repo.ui.note(_("new remote heads on branch '%s'\n") % branch)
182 for h in dhs:
182 for h in dhs:
183 repo.ui.note("new remote head %s\n" % short(h))
183 repo.ui.note(_("new remote head %s\n") % short(h))
184 if error:
184 if error:
185 raise util.Abort(error, hint=hint)
185 raise util.Abort(error, hint=hint)
186
186
@@ -124,7 +124,7 b' def _runcatch(req):'
124 ui.warn(_("hg: %s\n") % inst.args[1])
124 ui.warn(_("hg: %s\n") % inst.args[1])
125 commands.help_(ui, 'shortlist')
125 commands.help_(ui, 'shortlist')
126 except error.OutOfBandError, inst:
126 except error.OutOfBandError, inst:
127 ui.warn("abort: remote error:\n")
127 ui.warn(_("abort: remote error:\n"))
128 ui.warn(''.join(inst.args))
128 ui.warn(''.join(inst.args))
129 except error.RepoError, inst:
129 except error.RepoError, inst:
130 ui.warn(_("abort: %s!\n") % inst)
130 ui.warn(_("abort: %s!\n") % inst)
@@ -1,7 +1,7 b''
1 Valid URLs are of the form::
1 Valid URLs are of the form::
2
2
3 local/filesystem/path[#revision]
3 local/filesystem/path[#revision]
4 file://local/filesystem/path[#revision]
4 file://localhost/filesystem/path[#revision]
5 http://[user[:pass]@]host[:port]/[path][#revision]
5 http://[user[:pass]@]host[:port]/[path][#revision]
6 https://[user[:pass]@]host[:port]/[path][#revision]
6 https://[user[:pass]@]host[:port]/[path][#revision]
7 ssh://[user@]host[:port]/[path][#revision]
7 ssh://[user@]host[:port]/[path][#revision]
@@ -139,6 +139,7 b' def hook(ui, repo, name, throw=False, **'
139 stderrno = sys.__stderr__.fileno()
139 stderrno = sys.__stderr__.fileno()
140 # temporarily redirect stdout to stderr, if possible
140 # temporarily redirect stdout to stderr, if possible
141 if stdoutno >= 0 and stderrno >= 0:
141 if stdoutno >= 0 and stderrno >= 0:
142 sys.__stdout__.flush()
142 oldstdout = os.dup(stdoutno)
143 oldstdout = os.dup(stdoutno)
143 os.dup2(stderrno, stdoutno)
144 os.dup2(stderrno, stdoutno)
144 except AttributeError:
145 except AttributeError:
@@ -72,7 +72,7 b' def wsclean(opts, text, blank=True):'
72 text = re.sub('[ \t\r]+', ' ', text)
72 text = re.sub('[ \t\r]+', ' ', text)
73 text = text.replace(' \n', '\n')
73 text = text.replace(' \n', '\n')
74 if blank and opts.ignoreblanklines:
74 if blank and opts.ignoreblanklines:
75 text = re.sub('\n+', '', text)
75 text = re.sub('\n+', '\n', text).strip('\n')
76 return text
76 return text
77
77
78 def diffline(revs, a, b, opts):
78 def diffline(revs, a, b, opts):
@@ -128,7 +128,7 b' def findcommonheads(ui, local, remote,'
128 return (srvheadhashes, False, srvheadhashes,)
128 return (srvheadhashes, False, srvheadhashes,)
129
129
130 if sample and util.all(yesno):
130 if sample and util.all(yesno):
131 ui.note("all local heads known remotely\n")
131 ui.note(_("all local heads known remotely\n"))
132 ownheadhashes = dag.externalizeall(ownheads)
132 ownheadhashes = dag.externalizeall(ownheads)
133 return (ownheadhashes, True, srvheadhashes,)
133 return (ownheadhashes, True, srvheadhashes,)
134
134
@@ -158,7 +158,7 b' def findcommonheads(ui, local, remote,'
158 break
158 break
159
159
160 if full:
160 if full:
161 ui.note("sampling from both directions\n")
161 ui.note(_("sampling from both directions\n"))
162 sample = _takefullsample(dag, undecided, size=fullsamplesize)
162 sample = _takefullsample(dag, undecided, size=fullsamplesize)
163 elif common:
163 elif common:
164 # use cheapish initial sample
164 # use cheapish initial sample
@@ -223,7 +223,7 b' def _abssource(repo, push=False, abort=T'
223 source.path = posixpath.normpath(source.path)
223 source.path = posixpath.normpath(source.path)
224 parent = _abssource(repo._subparent, push, abort=False)
224 parent = _abssource(repo._subparent, push, abort=False)
225 if parent:
225 if parent:
226 parent = util.url(parent)
226 parent = util.url(util.pconvert(parent))
227 parent.path = posixpath.join(parent.path or '', source.path)
227 parent.path = posixpath.join(parent.path or '', source.path)
228 parent.path = posixpath.normpath(parent.path)
228 parent.path = posixpath.normpath(parent.path)
229 return str(parent)
229 return str(parent)
@@ -16,7 +16,7 b' hide platform-specific details from the '
16 from i18n import _
16 from i18n import _
17 import error, osutil, encoding
17 import error, osutil, encoding
18 import errno, re, shutil, sys, tempfile, traceback
18 import errno, re, shutil, sys, tempfile, traceback
19 import os, time, calendar, textwrap, signal
19 import os, time, datetime, calendar, textwrap, signal
20 import imp, socket, urllib
20 import imp, socket, urllib
21
21
22 if os.name == 'nt':
22 if os.name == 'nt':
@@ -900,16 +900,14 b' def filechunkiter(f, size=65536, limit=N'
900 yield s
900 yield s
901
901
902 def makedate():
902 def makedate():
903 lt = time.localtime()
903 ct = time.time()
904 if lt[8] == 1 and time.daylight:
904 if ct < 0:
905 tz = time.altzone
906 else:
907 tz = time.timezone
908 t = time.mktime(lt)
909 if t < 0:
910 hint = _("check your clock")
905 hint = _("check your clock")
911 raise Abort(_("negative timestamp: %d") % t, hint=hint)
906 raise Abort(_("negative timestamp: %d") % ct, hint=hint)
912 return t, tz
907 delta = (datetime.datetime.utcfromtimestamp(ct) -
908 datetime.datetime.fromtimestamp(ct))
909 tz = delta.days * 86400 + delta.seconds
910 return ct, tz
913
911
914 def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'):
912 def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'):
915 """represent a (unixtime, offset) tuple as a localized time.
913 """represent a (unixtime, offset) tuple as a localized time.
@@ -1708,7 +1706,8 b' class url(object):'
1708 # letters to paths with drive letters.
1706 # letters to paths with drive letters.
1709 if hasdriveletter(self._hostport):
1707 if hasdriveletter(self._hostport):
1710 path = self._hostport + '/' + self.path
1708 path = self._hostport + '/' + self.path
1711 elif self.host is not None and self.path:
1709 elif (self.host is not None and self.path
1710 and not hasdriveletter(path)):
1712 path = '/' + path
1711 path = '/' + path
1713 return path
1712 return path
1714 return self._origpath
1713 return self._origpath
@@ -442,3 +442,16 b' Only new line noticed:'
442 New line not noticed when space change ignored:
442 New line not noticed when space change ignored:
443
443
444 $ hg ndiff --ignore-blank-lines --ignore-all-space
444 $ hg ndiff --ignore-blank-lines --ignore-all-space
445
446 Do not ignore all newlines, only blank lines
447
448 $ printf 'hello \nworld\ngoodbye world\n' > foo
449 $ hg ndiff --ignore-blank-lines
450 diff -r 540c40a65b78 foo
451 --- a/foo
452 +++ b/foo
453 @@ -1,2 +1,3 @@
454 -hello world
455 +hello
456 +world
457 goodbye world
@@ -200,28 +200,80 b' Compare with original:'
200
200
201 View graph:
201 View graph:
202
202
203 $ hg --config extensions.graphlog= log -G --template '{author}@rev: {desc}\n'
203 $ hg --config extensions.graphlog= log -G --template '{author}@{rev}: {desc}\n'
204 @ test@rev: 3
204 @ test@11: 3
205 |
205 |
206 o test@rev: 4
206 o test@10: 4
207 |
207 |
208 o test@rev: 5
208 o test@9: 5
209 |
209 |
210 o bar@rev: 1
210 o bar@8: 1
211 |
211 |
212 o foo@rev: 2
212 o foo@7: 2
213 |
213 |
214 | o test@rev: 6
214 | o test@6: 6
215 | |\
215 | |\
216 | | o test@rev: 5
216 | | o test@5: 5
217 | | |
217 | | |
218 | o | test@rev: 4
218 | o | test@4: 4
219 | |/
219 | |/
220 | o baz@rev: 3
220 | o baz@3: 3
221 | |
222 | o test@2: 2
221 | |
223 | |
222 | o test@rev: 2
224 | o bar@1: 1
223 | |
224 | o bar@rev: 1
225 |/
225 |/
226 o test@rev: 0
226 o test@0: 0
227
227
228 Graft again onto another branch should preserve the original source
229 $ hg up -q 0
230 $ echo 'g'>g
231 $ hg add g
232 $ hg ci -m 7
233 created new head
234 $ hg graft 7
235 grafting revision 7
236
237 $ hg log -r 7 --template '{rev}:{node}\n'
238 7:d2e44c99fd3f31c176ea4efb9eca9f6306c81756
239 $ hg log -r 2 --template '{rev}:{node}\n'
240 2:5c095ad7e90f871700f02dd1fa5012cb4498a2d4
241
242 $ hg log --debug -r tip
243 changeset: 13:39bb1d13572759bd1e6fc874fed1b12ece047a18
244 tag: tip
245 parent: 12:b592ea63bb0c19a6c5c44685ee29a2284f9f1b8f
246 parent: -1:0000000000000000000000000000000000000000
247 manifest: 13:0780e055d8f4cd12eadd5a2719481648f336f7a9
248 user: foo
249 date: Thu Jan 01 00:00:00 1970 +0000
250 files+: b
251 files-: a
252 extra: branch=default
253 extra: source=5c095ad7e90f871700f02dd1fa5012cb4498a2d4
254 description:
255 2
256
257
258 Disallow grafting an already grafted cset onto its original branch
259 $ hg up -q 6
260 $ hg graft 7
261 skipping already grafted revision 7 (was grafted from 2)
262 [255]
263
264 Disallow grafting already grafted csets with the same origin onto each other
265 $ hg up -q 13
266 $ hg graft 2
267 skipping already grafted revision 2
268 [255]
269 $ hg graft 7
270 skipping already grafted revision 7 (same origin 2)
271 [255]
272
273 $ hg up -q 7
274 $ hg graft 2
275 skipping already grafted revision 2
276 [255]
277 $ hg graft tip
278 skipping already grafted revision 13 (same origin 2)
279 [255]
@@ -223,6 +223,14 b' def test_url():'
223 >>> u.localpath()
223 >>> u.localpath()
224 'f:oo/bar/baz'
224 'f:oo/bar/baz'
225
225
226 >>> u = url('file://localhost/f:oo/bar/baz')
227 >>> u
228 <url scheme: 'file', host: 'localhost', path: 'f:oo/bar/baz'>
229 >>> str(u)
230 'file://localhost/f:oo/bar/baz'
231 >>> u.localpath()
232 'f:oo/bar/baz'
233
226 >>> u = url('file:foo/bar/baz')
234 >>> u = url('file:foo/bar/baz')
227 >>> u
235 >>> u
228 <url scheme: 'file', path: 'foo/bar/baz'>
236 <url scheme: 'file', path: 'foo/bar/baz'>
General Comments 0
You need to be logged in to leave comments. Login now