Show More
@@ -67,7 +67,7 b' class queue:' | |||||
67 |
|
67 | |||
68 | if os.path.exists(os.path.join(self.path, self.series_path)): |
|
68 | if os.path.exists(os.path.join(self.path, self.series_path)): | |
69 | self.full_series = self.opener(self.series_path).read().splitlines() |
|
69 | self.full_series = self.opener(self.series_path).read().splitlines() | |
70 |
self.re |
|
70 | self.parse_series() | |
71 |
|
71 | |||
72 | if os.path.exists(os.path.join(self.path, self.status_path)): |
|
72 | if os.path.exists(os.path.join(self.path, self.status_path)): | |
73 | self.applied = [StatusEntry(l) |
|
73 | self.applied = [StatusEntry(l) | |
@@ -86,34 +86,21 b' class queue:' | |||||
86 | index += 1 |
|
86 | index += 1 | |
87 | return None |
|
87 | return None | |
88 |
|
88 | |||
89 |
def re |
|
89 | def parse_series(self): | |
90 | def matcher(list): |
|
|||
91 | pre = re.compile("(\s*)([^#]+)") |
|
|||
92 | for l in list: |
|
|||
93 | m = pre.match(l) |
|
|||
94 | if m: |
|
|||
95 | s = m.group(2) |
|
|||
96 | s = s.rstrip() |
|
|||
97 | if len(s) > 0: |
|
|||
98 | yield s |
|
|||
99 | self.series = [] |
|
90 | self.series = [] | |
100 | self.series = [ x for x in matcher(list) ] |
|
91 | for l in self.full_series: | |
|
92 | s = l.split('#', 1)[0].strip() | |||
|
93 | if s: | |||
|
94 | self.series.append(s) | |||
101 |
|
95 | |||
102 | def save_dirty(self): |
|
96 | def save_dirty(self): | |
103 | if self.applied_dirty: |
|
97 | def write_list(items, path): | |
104 | if len(self.applied) > 0: |
|
98 | fp = self.opener(path, 'w') | |
105 | nl = "\n" |
|
99 | for i in items: | |
106 | else: |
|
100 | print >> fp, i | |
107 | nl = "" |
|
101 | fp.close() | |
108 | f = self.opener(self.status_path, "w") |
|
102 | if self.applied_dirty: write_list(map(str, self.applied), self.status_path) | |
109 | f.write("\n".join([str(x) for x in self.applied]) + nl) |
|
103 | if self.series_dirty: write_list(self.full_series, self.series_path) | |
110 | if self.series_dirty: |
|
|||
111 | if len(self.full_series) > 0: |
|
|||
112 | nl = "\n" |
|
|||
113 | else: |
|
|||
114 | nl = "" |
|
|||
115 | f = self.opener(self.series_path, "w") |
|
|||
116 | f.write("\n".join(self.full_series) + nl) |
|
|||
117 |
|
104 | |||
118 | def readheaders(self, patch): |
|
105 | def readheaders(self, patch): | |
119 | def eatdiff(lines): |
|
106 | def eatdiff(lines): | |
@@ -406,7 +393,7 b' class queue:' | |||||
406 | os.unlink(os.path.join(self.path, patch)) |
|
393 | os.unlink(os.path.join(self.path, patch)) | |
407 | i = self.find_series(patch) |
|
394 | i = self.find_series(patch) | |
408 | del self.full_series[i] |
|
395 | del self.full_series[i] | |
409 |
self.re |
|
396 | self.parse_series() | |
410 | self.series_dirty = 1 |
|
397 | self.series_dirty = 1 | |
411 |
|
398 | |||
412 | def check_toppatch(self, repo): |
|
399 | def check_toppatch(self, repo): | |
@@ -443,7 +430,7 b' class queue:' | |||||
443 | raise util.Abort(_("repo commit failed")) |
|
430 | raise util.Abort(_("repo commit failed")) | |
444 | self.full_series[insert:insert] = [patch] |
|
431 | self.full_series[insert:insert] = [patch] | |
445 | self.applied.append(StatusEntry(revlog.hex(n), patch)) |
|
432 | self.applied.append(StatusEntry(revlog.hex(n), patch)) | |
446 |
self.re |
|
433 | self.parse_series() | |
447 | self.series_dirty = 1 |
|
434 | self.series_dirty = 1 | |
448 | self.applied_dirty = 1 |
|
435 | self.applied_dirty = 1 | |
449 | p = self.opener(patch, "w") |
|
436 | p = self.opener(patch, "w") | |
@@ -941,10 +928,7 b' class queue:' | |||||
941 | start = self.series_end() |
|
928 | start = self.series_end() | |
942 | else: |
|
929 | else: | |
943 | start = self.series.index(patch) + 1 |
|
930 | start = self.series.index(patch) + 1 | |
944 | for p in self.series[start:]: |
|
931 | return [(i, self.series[i]) for i in xrange(start, len(self.series))] | |
945 | if self.ui.verbose: |
|
|||
946 | self.ui.write("%d " % self.series.index(p)) |
|
|||
947 | self.ui.write("%s\n" % p) |
|
|||
948 |
|
932 | |||
949 | def qseries(self, repo, missing=None, summary=False): |
|
933 | def qseries(self, repo, missing=None, summary=False): | |
950 | start = self.series_end() |
|
934 | start = self.series_end() | |
@@ -1019,7 +1003,7 b' class queue:' | |||||
1019 | self.ui.warn("restoring status: %s\n" % lines[0]) |
|
1003 | self.ui.warn("restoring status: %s\n" % lines[0]) | |
1020 | self.full_series = series |
|
1004 | self.full_series = series | |
1021 | self.applied = applied |
|
1005 | self.applied = applied | |
1022 |
self.re |
|
1006 | self.parse_series() | |
1023 | self.series_dirty = 1 |
|
1007 | self.series_dirty = 1 | |
1024 | self.applied_dirty = 1 |
|
1008 | self.applied_dirty = 1 | |
1025 | heads = repo.changelog.heads() |
|
1009 | heads = repo.changelog.heads() | |
@@ -1165,7 +1149,7 b' class queue:' | |||||
1165 | % patch) |
|
1149 | % patch) | |
1166 | index = self.full_series_end() + i |
|
1150 | index = self.full_series_end() + i | |
1167 | self.full_series[index:index] = [patch] |
|
1151 | self.full_series[index:index] = [patch] | |
1168 |
self.re |
|
1152 | self.parse_series() | |
1169 | self.ui.warn("adding %s to series file\n" % patch) |
|
1153 | self.ui.warn("adding %s to series file\n" % patch) | |
1170 | i += 1 |
|
1154 | i += 1 | |
1171 | added.append(patch) |
|
1155 | added.append(patch) | |
@@ -1192,8 +1176,10 b' def applied(ui, repo, patch=None, **opts' | |||||
1192 |
|
1176 | |||
1193 | def unapplied(ui, repo, patch=None, **opts): |
|
1177 | def unapplied(ui, repo, patch=None, **opts): | |
1194 | """print the patches not yet applied""" |
|
1178 | """print the patches not yet applied""" | |
1195 | repo.mq.unapplied(repo, patch) |
|
1179 | for i, p in repo.mq.unapplied(repo, patch): | |
1196 | return 0 |
|
1180 | if ui.verbose: | |
|
1181 | ui.write("%d " % i) | |||
|
1182 | ui.write("%s\n" % p) | |||
1197 |
|
1183 | |||
1198 | def qimport(ui, repo, *filename, **opts): |
|
1184 | def qimport(ui, repo, *filename, **opts): | |
1199 | """import a patch""" |
|
1185 | """import a patch""" | |
@@ -1234,7 +1220,7 b' def clone(ui, source, dest=None, **opts)' | |||||
1234 | Source patch repository is looked for in <src>/.hg/patches by |
|
1220 | Source patch repository is looked for in <src>/.hg/patches by | |
1235 | default. Use -p <url> to change. |
|
1221 | default. Use -p <url> to change. | |
1236 | ''' |
|
1222 | ''' | |
1237 |
commands.setremoteconfig( |
|
1223 | commands.setremoteconfig(ui, opts) | |
1238 | if dest is None: |
|
1224 | if dest is None: | |
1239 | dest = hg.defaultdest(source) |
|
1225 | dest = hg.defaultdest(source) | |
1240 | sr = hg.repository(ui, ui.expandpath(source)) |
|
1226 | sr = hg.repository(ui, ui.expandpath(source)) | |
@@ -1303,10 +1289,7 b' def new(ui, repo, patch, **opts):' | |||||
1303 |
|
1289 | |||
1304 | -m or -l set the patch header as well as the commit message. |
|
1290 | -m or -l set the patch header as well as the commit message. | |
1305 | If neither is specified, the patch header is empty and the |
|
1291 | If neither is specified, the patch header is empty and the | |
1306 | commit message is 'New patch: PATCH' |
|
1292 | commit message is 'New patch: PATCH'""" | |
1307 |
|
||||
1308 | If -f is specified, the patch will be initialized with any |
|
|||
1309 | uncommitted changes. Otherwise, if there outsta""" |
|
|||
1310 | q = repo.mq |
|
1293 | q = repo.mq | |
1311 | message=commands.logmessage(**opts) |
|
1294 | message=commands.logmessage(**opts) | |
1312 | q.new(repo, patch, msg=message, force=opts['force']) |
|
1295 | q.new(repo, patch, msg=message, force=opts['force']) | |
@@ -1336,7 +1319,13 b' def diff(ui, repo, *files, **opts):' | |||||
1336 | def fold(ui, repo, *files, **opts): |
|
1319 | def fold(ui, repo, *files, **opts): | |
1337 | """fold the named patches into the current patch |
|
1320 | """fold the named patches into the current patch | |
1338 |
|
1321 | |||
1339 | Patches must not yet be applied. |
|
1322 | Patches must not yet be applied. Each patch will be successively | |
|
1323 | applied to the current patch in the order given. If all the | |||
|
1324 | patches apply successfully, the current patch will be refreshed | |||
|
1325 | with the new cumulative patch, and the folded patches will | |||
|
1326 | be deleted. With -f/--force, the folded patch files will | |||
|
1327 | be removed afterwards. | |||
|
1328 | ||||
1340 | The header for each folded patch will be concatenated with |
|
1329 | The header for each folded patch will be concatenated with | |
1341 | the current patch header, separated by a line of '* * *'.""" |
|
1330 | the current patch header, separated by a line of '* * *'.""" | |
1342 |
|
1331 | |||
@@ -1384,7 +1373,7 b' def fold(ui, repo, *files, **opts):' | |||||
1384 | q.refresh(repo, msg=message) |
|
1373 | q.refresh(repo, msg=message) | |
1385 |
|
1374 | |||
1386 | for patch in patches: |
|
1375 | for patch in patches: | |
1387 | q.delete(repo, patch) |
|
1376 | q.delete(repo, patch, force=opts['force']) | |
1388 |
|
1377 | |||
1389 | q.save_dirty() |
|
1378 | q.save_dirty() | |
1390 |
|
1379 | |||
@@ -1493,7 +1482,7 b' def rename(ui, repo, patch, name=None, *' | |||||
1493 | ui.write('Renaming %s to %s\n' % (patch, name)) |
|
1482 | ui.write('Renaming %s to %s\n' % (patch, name)) | |
1494 | i = q.find_series(patch) |
|
1483 | i = q.find_series(patch) | |
1495 | q.full_series[i] = name |
|
1484 | q.full_series[i] = name | |
1496 |
q.re |
|
1485 | q.parse_series() | |
1497 | q.series_dirty = 1 |
|
1486 | q.series_dirty = 1 | |
1498 |
|
1487 | |||
1499 | info = q.isapplied(patch) |
|
1488 | info = q.isapplied(patch) | |
@@ -1617,6 +1606,7 b' cmdtable = {' | |||||
1617 | 'qfold': |
|
1606 | 'qfold': | |
1618 | (fold, |
|
1607 | (fold, | |
1619 | [('e', 'edit', None, _('edit patch header')), |
|
1608 | [('e', 'edit', None, _('edit patch header')), | |
|
1609 | ('f', 'force', None, _('delete folded patch files')), | |||
1620 | ('m', 'message', '', _('set patch header to <text>')), |
|
1610 | ('m', 'message', '', _('set patch header to <text>')), | |
1621 | ('l', 'logfile', '', _('set patch header to contents of <file>'))], |
|
1611 | ('l', 'logfile', '', _('set patch header to contents of <file>'))], | |
1622 | 'hg qfold [-e] [-m <text>] [-l <file] PATCH...'), |
|
1612 | 'hg qfold [-e] [-m <text>] [-l <file] PATCH...'), |
@@ -13,7 +13,8 b' demandload(globals(), "localrepo bundler' | |||||
13 | demandload(globals(), "errno lock os shutil util") |
|
13 | demandload(globals(), "errno lock os shutil util") | |
14 |
|
14 | |||
15 | def _local(path): |
|
15 | def _local(path): | |
16 |
return os.path.isfile(util.drop_scheme('file', path)) and |
|
16 | return (os.path.isfile(path and util.drop_scheme('file', path)) and | |
|
17 | bundlerepo or localrepo) | |||
17 |
|
18 | |||
18 | schemes = { |
|
19 | schemes = { | |
19 | 'bundle': bundlerepo, |
|
20 | 'bundle': bundlerepo, |
@@ -27,7 +27,7 b' adding b' | |||||
27 | reverting a |
|
27 | reverting a | |
28 | changeset 3:4cbb1e70196a backs out changeset 1:22bca4c721e5 |
|
28 | changeset 3:4cbb1e70196a backs out changeset 1:22bca4c721e5 | |
29 | the backout changeset is a new head - do not forget to merge |
|
29 | the backout changeset is a new head - do not forget to merge | |
30 | (use "backout -m" if you want to auto-merge) |
|
30 | (use "backout --merge" if you want to auto-merge) | |
31 | b: No such file or directory |
|
31 | b: No such file or directory | |
32 | adding a |
|
32 | adding a | |
33 | adding b |
|
33 | adding b |
@@ -1,7 +1,10 b'' | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 |
|
2 | |||
3 | hg init a |
|
3 | hg init a | |
|
4 | mkdir a/d1 | |||
|
5 | mkdir a/d1/d2 | |||
4 | echo line 1 > a/a |
|
6 | echo line 1 > a/a | |
|
7 | echo line 1 > a/d1/d2/a | |||
5 | hg --cwd a ci -d '0 0' -Ama |
|
8 | hg --cwd a ci -d '0 0' -Ama | |
6 |
|
9 | |||
7 | echo line 2 >> a/a |
|
10 | echo line 2 >> a/a | |
@@ -79,3 +82,19 b' python mkmsg.py | hg --cwd b import -' | |||||
79 | hg --cwd b tip | grep second |
|
82 | hg --cwd b tip | grep second | |
80 | rm -rf b |
|
83 | rm -rf b | |
81 |
|
84 | |||
|
85 | # bug non regression test | |||
|
86 | # importing a patch in a subdirectory failed at the commit stage | |||
|
87 | echo line 2 >> a/d1/d2/a | |||
|
88 | hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change' | |||
|
89 | echo % hg import in a subdirectory | |||
|
90 | hg clone -r0 a b | |||
|
91 | hg --cwd a export tip | sed -e 's/d1\/d2\///' > tip.patch | |||
|
92 | pushd b/d1/d2 2>&1 > /dev/null | |||
|
93 | hg import ../../../tip.patch | |||
|
94 | popd 2>&1 > /dev/null | |||
|
95 | echo "% message should be 'subdir change'" | |||
|
96 | hg --cwd b tip | grep 'subdir change' | |||
|
97 | echo "% committer should be 'someoneelse'" | |||
|
98 | hg --cwd b tip | grep someoneelse | |||
|
99 | echo "% should be empty" | |||
|
100 | hg --cwd b status |
@@ -1,11 +1,12 b'' | |||||
1 | adding a |
|
1 | adding a | |
|
2 | adding d1/d2/a | |||
2 | % import exported patch |
|
3 | % import exported patch | |
3 | requesting all changes |
|
4 | requesting all changes | |
4 | adding changesets |
|
5 | adding changesets | |
5 | adding manifests |
|
6 | adding manifests | |
6 | adding file changes |
|
7 | adding file changes | |
7 |
added 1 changesets with |
|
8 | added 1 changesets with 2 changes to 2 files | |
8 |
|
|
9 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
9 | applying ../tip.patch |
|
10 | applying ../tip.patch | |
10 | patching file a |
|
11 | patching file a | |
11 | % message should be same |
|
12 | % message should be same | |
@@ -17,8 +18,8 b' requesting all changes' | |||||
17 | adding changesets |
|
18 | adding changesets | |
18 | adding manifests |
|
19 | adding manifests | |
19 | adding file changes |
|
20 | adding file changes | |
20 |
added 1 changesets with |
|
21 | added 1 changesets with 2 changes to 2 files | |
21 |
|
|
22 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
22 | applying ../tip.patch |
|
23 | applying ../tip.patch | |
23 | patching file a |
|
24 | patching file a | |
24 | transaction abort! |
|
25 | transaction abort! | |
@@ -28,8 +29,8 b' requesting all changes' | |||||
28 | adding changesets |
|
29 | adding changesets | |
29 | adding manifests |
|
30 | adding manifests | |
30 | adding file changes |
|
31 | adding file changes | |
31 |
added 1 changesets with |
|
32 | added 1 changesets with 2 changes to 2 files | |
32 |
|
|
33 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
33 | applying ../tip.patch |
|
34 | applying ../tip.patch | |
34 | patching file a |
|
35 | patching file a | |
35 | % import from stdin |
|
36 | % import from stdin | |
@@ -37,8 +38,8 b' requesting all changes' | |||||
37 | adding changesets |
|
38 | adding changesets | |
38 | adding manifests |
|
39 | adding manifests | |
39 | adding file changes |
|
40 | adding file changes | |
40 |
added 1 changesets with |
|
41 | added 1 changesets with 2 changes to 2 files | |
41 |
|
|
42 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
42 | applying patch from stdin |
|
43 | applying patch from stdin | |
43 | patching file a |
|
44 | patching file a | |
44 | % override commit message |
|
45 | % override commit message | |
@@ -46,8 +47,8 b' requesting all changes' | |||||
46 | adding changesets |
|
47 | adding changesets | |
47 | adding manifests |
|
48 | adding manifests | |
48 | adding file changes |
|
49 | adding file changes | |
49 |
added 1 changesets with |
|
50 | added 1 changesets with 2 changes to 2 files | |
50 |
|
|
51 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
51 | applying patch from stdin |
|
52 | applying patch from stdin | |
52 | patching file a |
|
53 | patching file a | |
53 | summary: override |
|
54 | summary: override | |
@@ -56,8 +57,8 b' requesting all changes' | |||||
56 | adding changesets |
|
57 | adding changesets | |
57 | adding manifests |
|
58 | adding manifests | |
58 | adding file changes |
|
59 | adding file changes | |
59 |
added 1 changesets with |
|
60 | added 1 changesets with 2 changes to 2 files | |
60 |
|
|
61 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
61 | applying ../msg.patch |
|
62 | applying ../msg.patch | |
62 | patching file a |
|
63 | patching file a | |
63 | user: email patcher |
|
64 | user: email patcher | |
@@ -67,8 +68,8 b' requesting all changes' | |||||
67 | adding changesets |
|
68 | adding changesets | |
68 | adding manifests |
|
69 | adding manifests | |
69 | adding file changes |
|
70 | adding file changes | |
70 |
added 1 changesets with |
|
71 | added 1 changesets with 2 changes to 2 files | |
71 |
|
|
72 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
72 | applying patch from stdin |
|
73 | applying patch from stdin | |
73 | patching file a |
|
74 | patching file a | |
74 | % plain diff in email, subject, no message body |
|
75 | % plain diff in email, subject, no message body | |
@@ -76,8 +77,8 b' requesting all changes' | |||||
76 | adding changesets |
|
77 | adding changesets | |
77 | adding manifests |
|
78 | adding manifests | |
78 | adding file changes |
|
79 | adding file changes | |
79 |
added 1 changesets with |
|
80 | added 1 changesets with 2 changes to 2 files | |
80 |
|
|
81 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
81 | applying patch from stdin |
|
82 | applying patch from stdin | |
82 | patching file a |
|
83 | patching file a | |
83 | % plain diff in email, no subject, no message body, should fail |
|
84 | % plain diff in email, no subject, no message body, should fail | |
@@ -85,8 +86,8 b' requesting all changes' | |||||
85 | adding changesets |
|
86 | adding changesets | |
86 | adding manifests |
|
87 | adding manifests | |
87 | adding file changes |
|
88 | adding file changes | |
88 |
added 1 changesets with |
|
89 | added 1 changesets with 2 changes to 2 files | |
89 |
|
|
90 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
90 | applying patch from stdin |
|
91 | applying patch from stdin | |
91 | patching file a |
|
92 | patching file a | |
92 | transaction abort! |
|
93 | transaction abort! | |
@@ -96,8 +97,22 b' requesting all changes' | |||||
96 | adding changesets |
|
97 | adding changesets | |
97 | adding manifests |
|
98 | adding manifests | |
98 | adding file changes |
|
99 | adding file changes | |
99 |
added 1 changesets with |
|
100 | added 1 changesets with 2 changes to 2 files | |
100 |
|
|
101 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
101 | applying patch from stdin |
|
102 | applying patch from stdin | |
102 | patching file a |
|
103 | patching file a | |
103 | summary: second change |
|
104 | summary: second change | |
|
105 | % hg import in a subdirectory | |||
|
106 | requesting all changes | |||
|
107 | adding changesets | |||
|
108 | adding manifests | |||
|
109 | adding file changes | |||
|
110 | added 1 changesets with 2 changes to 2 files | |||
|
111 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
112 | applying ../../../tip.patch | |||
|
113 | patching file a | |||
|
114 | % message should be 'subdir change' | |||
|
115 | summary: subdir change | |||
|
116 | % committer should be 'someoneelse' | |||
|
117 | user: someoneelse | |||
|
118 | % should be empty |
General Comments 0
You need to be logged in to leave comments.
Login now