Show More
@@ -0,0 +1,51 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | # Environement setup for MQ | |||
|
4 | export HGRCPATH=./hgrc | |||
|
5 | echo "[extensions]" >> ./hgrc | |||
|
6 | echo "mq=" >> ./hgrc | |||
|
7 | ||||
|
8 | #Repo init | |||
|
9 | hg init | |||
|
10 | hg qinit | |||
|
11 | ||||
|
12 | hg qnew -m "First commit message" first-patch | |||
|
13 | echo aaaa > file | |||
|
14 | hg add file | |||
|
15 | hg qrefresh | |||
|
16 | echo ======================= | |||
|
17 | echo "Should display 'First commit message'" | |||
|
18 | hg log -l1 -v | sed -n '/description/,$p' | |||
|
19 | echo | |||
|
20 | ||||
|
21 | # Testing changing message with -m | |||
|
22 | echo bbbb > file | |||
|
23 | hg qrefresh -m "Second commit message" | |||
|
24 | echo ======================= | |||
|
25 | echo "Should display 'Second commit message'" | |||
|
26 | hg log -l1 -v | sed -n '/description/,$p' | |||
|
27 | echo | |||
|
28 | ||||
|
29 | ||||
|
30 | # Testing changing message with -l | |||
|
31 | echo "Third commit message" > logfile | |||
|
32 | echo " This is the 3rd log message" >> logfile | |||
|
33 | echo bbbb > file | |||
|
34 | hg qrefresh -l logfile | |||
|
35 | echo ======================= | |||
|
36 | echo "Should display 'Third commit message\n This is the 3rd log message'" | |||
|
37 | hg log -l1 -v | sed -n '/description/,$p' | |||
|
38 | echo | |||
|
39 | ||||
|
40 | # Testing changing message with -l- | |||
|
41 | hg qnew -m "First commit message" second-patch | |||
|
42 | echo aaaa > file2 | |||
|
43 | hg add file2 | |||
|
44 | echo bbbb > file2 | |||
|
45 | (echo "Fifth commit message" | |||
|
46 | echo " This is the 5th log message" >> logfile) |\ | |||
|
47 | hg qrefresh -l- | |||
|
48 | echo ======================= | |||
|
49 | echo "Should display 'Fifth commit message\n This is the 5th log message'" | |||
|
50 | hg log -l1 -v | sed -n '/description/,$p' | |||
|
51 | echo |
@@ -0,0 +1,29 b'' | |||||
|
1 | ======================= | |||
|
2 | Should display 'First commit message' | |||
|
3 | description: | |||
|
4 | First commit message | |||
|
5 | ||||
|
6 | ||||
|
7 | ||||
|
8 | ======================= | |||
|
9 | Should display 'Second commit message' | |||
|
10 | description: | |||
|
11 | Second commit message | |||
|
12 | ||||
|
13 | ||||
|
14 | ||||
|
15 | ======================= | |||
|
16 | Should display 'Third commit message\n This is the 3rd log message' | |||
|
17 | description: | |||
|
18 | Third commit message | |||
|
19 | This is the 3rd log message | |||
|
20 | ||||
|
21 | ||||
|
22 | ||||
|
23 | ======================= | |||
|
24 | Should display 'Fifth commit message\n This is the 5th log message' | |||
|
25 | description: | |||
|
26 | Fifth commit message | |||
|
27 | ||||
|
28 | ||||
|
29 |
@@ -442,7 +442,7 b' class queue:' | |||||
442 | r = self.qrepo() |
|
442 | r = self.qrepo() | |
443 | if r: r.add([patch]) |
|
443 | if r: r.add([patch]) | |
444 | if commitfiles: |
|
444 | if commitfiles: | |
445 | self.refresh(repo, short=True) |
|
445 | self.refresh(repo, msg=None, short=True) | |
446 |
|
446 | |||
447 | def strip(self, repo, rev, update=True, backup="all", wlock=None): |
|
447 | def strip(self, repo, rev, update=True, backup="all", wlock=None): | |
448 | def limitheads(chlog, stop): |
|
448 | def limitheads(chlog, stop): | |
@@ -739,7 +739,7 b' class queue:' | |||||
739 | qp = self.qparents(repo, top) |
|
739 | qp = self.qparents(repo, top) | |
740 | commands.dodiff(sys.stdout, self.ui, repo, qp, None, files) |
|
740 | commands.dodiff(sys.stdout, self.ui, repo, qp, None, files) | |
741 |
|
741 | |||
742 | def refresh(self, repo, short=False): |
|
742 | def refresh(self, repo, msg=None, short=False): | |
743 | if len(self.applied) == 0: |
|
743 | if len(self.applied) == 0: | |
744 | self.ui.write("No patches applied\n") |
|
744 | self.ui.write("No patches applied\n") | |
745 | return |
|
745 | return | |
@@ -822,10 +822,14 b' class queue:' | |||||
822 | repo.dirstate.update(c, 'n') |
|
822 | repo.dirstate.update(c, 'n') | |
823 | repo.dirstate.forget(forget) |
|
823 | repo.dirstate.forget(forget) | |
824 |
|
824 | |||
825 |
if not m |
|
825 | if not msg: | |
826 | message = "patch queue: %s\n" % patch |
|
826 | if not message: | |
|
827 | message = "patch queue: %s\n" % patch | |||
|
828 | else: | |||
|
829 | message = "\n".join(message) | |||
827 | else: |
|
830 | else: | |
828 |
message = |
|
831 | message = msg | |
|
832 | ||||
829 | self.strip(repo, top, update=False, backup='strip', wlock=wlock) |
|
833 | self.strip(repo, top, update=False, backup='strip', wlock=wlock) | |
830 | n = repo.commit(filelist, message, changes[1], force=1, wlock=wlock) |
|
834 | n = repo.commit(filelist, message, changes[1], force=1, wlock=wlock) | |
831 | self.applied[-1] = revlog.hex(n) + ':' + patch |
|
835 | self.applied[-1] = revlog.hex(n) + ':' + patch | |
@@ -1144,14 +1148,16 b' def prev(ui, repo, **opts):' | |||||
1144 | def new(ui, repo, patch, **opts): |
|
1148 | def new(ui, repo, patch, **opts): | |
1145 | """create a new patch""" |
|
1149 | """create a new patch""" | |
1146 | q = repomap[repo] |
|
1150 | q = repomap[repo] | |
1147 | q.new(repo, patch, msg=opts['message'], force=opts['force']) |
|
1151 | message=commands.logmessage(**opts) | |
|
1152 | q.new(repo, patch, msg=message, force=opts['force']) | |||
1148 | q.save_dirty() |
|
1153 | q.save_dirty() | |
1149 | return 0 |
|
1154 | return 0 | |
1150 |
|
1155 | |||
1151 | def refresh(ui, repo, **opts): |
|
1156 | def refresh(ui, repo, **opts): | |
1152 | """update the current patch""" |
|
1157 | """update the current patch""" | |
1153 | q = repomap[repo] |
|
1158 | q = repomap[repo] | |
1154 | q.refresh(repo, short=opts['short']) |
|
1159 | message=commands.logmessage(**opts) | |
|
1160 | q.refresh(repo, msg=message, short=opts['short']) | |||
1155 | q.save_dirty() |
|
1161 | q.save_dirty() | |
1156 | return 0 |
|
1162 | return 0 | |
1157 |
|
1163 | |||
@@ -1234,7 +1240,8 b' def restore(ui, repo, rev, **opts):' | |||||
1234 | def save(ui, repo, **opts): |
|
1240 | def save(ui, repo, **opts): | |
1235 | """save current queue state""" |
|
1241 | """save current queue state""" | |
1236 | q = repomap[repo] |
|
1242 | q = repomap[repo] | |
1237 | ret = q.save(repo, msg=opts['message']) |
|
1243 | message=commands.logmessage(**opts) | |
|
1244 | ret = q.save(repo, msg=message) | |||
1238 | if ret: |
|
1245 | if ret: | |
1239 | return ret |
|
1246 | return ret | |
1240 | q.save_dirty() |
|
1247 | q.save_dirty() | |
@@ -1325,9 +1332,10 b' cmdtable = {' | |||||
1325 | 'hg qinit [-c]'), |
|
1332 | 'hg qinit [-c]'), | |
1326 | "qnew": |
|
1333 | "qnew": | |
1327 | (new, |
|
1334 | (new, | |
1328 | [('m', 'message', '', 'commit message'), |
|
1335 | [('m', 'message', '', _('use <text> as commit message')), | |
|
1336 | ('l', 'logfile', '', _('read the commit message from <file>')), | |||
1329 | ('f', 'force', None, 'force')], |
|
1337 | ('f', 'force', None, 'force')], | |
1330 | 'hg qnew [-m TEXT] [-f] PATCH'), |
|
1338 | 'hg qnew [-m TEXT] [-l FILE] [-f] PATCH'), | |
1331 | "qnext": (next, [], 'hg qnext'), |
|
1339 | "qnext": (next, [], 'hg qnext'), | |
1332 | "qprev": (prev, [], 'hg qprev'), |
|
1340 | "qprev": (prev, [], 'hg qprev'), | |
1333 | "^qpop": |
|
1341 | "^qpop": | |
@@ -1346,8 +1354,10 b' cmdtable = {' | |||||
1346 | 'hg qpush [-f] [-l] [-a] [-m] [-n NAME] [PATCH | INDEX]'), |
|
1354 | 'hg qpush [-f] [-l] [-a] [-m] [-n NAME] [PATCH | INDEX]'), | |
1347 | "^qrefresh": |
|
1355 | "^qrefresh": | |
1348 | (refresh, |
|
1356 | (refresh, | |
1349 | [('s', 'short', None, 'short refresh')], |
|
1357 | [('m', 'message', '', _('change commit message with <text>')), | |
1350 | 'hg qrefresh [-s]'), |
|
1358 | ('l', 'logfile', '', _('change commit message with <file> content')), | |
|
1359 | ('s', 'short', None, 'short refresh')], | |||
|
1360 | 'hg qrefresh [-m TEXT] [-l FILE] [-s]'), | |||
1351 | "qrestore": |
|
1361 | "qrestore": | |
1352 | (restore, |
|
1362 | (restore, | |
1353 | [('d', 'delete', None, 'delete save entry'), |
|
1363 | [('d', 'delete', None, 'delete save entry'), | |
@@ -1355,12 +1365,13 b' cmdtable = {' | |||||
1355 | 'hg qrestore [-d] [-u] REV'), |
|
1365 | 'hg qrestore [-d] [-u] REV'), | |
1356 | "qsave": |
|
1366 | "qsave": | |
1357 | (save, |
|
1367 | (save, | |
1358 | [('m', 'message', '', 'commit message'), |
|
1368 | [('m', 'message', '', _('use <text> as commit message')), | |
|
1369 | ('l', 'logfile', '', _('read the commit message from <file>')), | |||
1359 | ('c', 'copy', None, 'copy patch directory'), |
|
1370 | ('c', 'copy', None, 'copy patch directory'), | |
1360 | ('n', 'name', '', 'copy directory name'), |
|
1371 | ('n', 'name', '', 'copy directory name'), | |
1361 | ('e', 'empty', None, 'clear queue status file'), |
|
1372 | ('e', 'empty', None, 'clear queue status file'), | |
1362 | ('f', 'force', None, 'force copy')], |
|
1373 | ('f', 'force', None, 'force copy')], | |
1363 | 'hg qsave [-m TEXT] [-c] [-n NAME] [-e] [-f]'), |
|
1374 | 'hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'), | |
1364 | "qseries": |
|
1375 | "qseries": | |
1365 | (series, |
|
1376 | (series, | |
1366 | [('m', 'missing', None, 'print patches not in series')], |
|
1377 | [('m', 'missing', None, 'print patches not in series')], |
@@ -40,6 +40,25 b' def relpath(repo, args):' | |||||
40 | return [util.normpath(os.path.join(cwd, x)) for x in args] |
|
40 | return [util.normpath(os.path.join(cwd, x)) for x in args] | |
41 | return args |
|
41 | return args | |
42 |
|
42 | |||
|
43 | def logmessage(**opts): | |||
|
44 | """ get the log message according to -m and -l option """ | |||
|
45 | message = opts['message'] | |||
|
46 | logfile = opts['logfile'] | |||
|
47 | ||||
|
48 | if message and logfile: | |||
|
49 | raise util.Abort(_('options --message and --logfile are mutually ' | |||
|
50 | 'exclusive')) | |||
|
51 | if not message and logfile: | |||
|
52 | try: | |||
|
53 | if logfile == '-': | |||
|
54 | message = sys.stdin.read() | |||
|
55 | else: | |||
|
56 | message = open(logfile).read() | |||
|
57 | except IOError, inst: | |||
|
58 | raise util.Abort(_("can't read commit message '%s': %s") % | |||
|
59 | (logfile, inst.strerror)) | |||
|
60 | return message | |||
|
61 | ||||
43 | def matchpats(repo, pats=[], opts={}, head=''): |
|
62 | def matchpats(repo, pats=[], opts={}, head=''): | |
44 | cwd = repo.getcwd() |
|
63 | cwd = repo.getcwd() | |
45 | if not pats and cwd: |
|
64 | if not pats and cwd: | |
@@ -989,21 +1008,7 b' def commit(ui, repo, *pats, **opts):' | |||||
989 | If no commit message is specified, the editor configured in your hgrc |
|
1008 | If no commit message is specified, the editor configured in your hgrc | |
990 | or in the EDITOR environment variable is started to enter a message. |
|
1009 | or in the EDITOR environment variable is started to enter a message. | |
991 | """ |
|
1010 | """ | |
992 |
message = opts |
|
1011 | message = logmessage(**opts) | |
993 | logfile = opts['logfile'] |
|
|||
994 |
|
||||
995 | if message and logfile: |
|
|||
996 | raise util.Abort(_('options --message and --logfile are mutually ' |
|
|||
997 | 'exclusive')) |
|
|||
998 | if not message and logfile: |
|
|||
999 | try: |
|
|||
1000 | if logfile == '-': |
|
|||
1001 | message = sys.stdin.read() |
|
|||
1002 | else: |
|
|||
1003 | message = open(logfile).read() |
|
|||
1004 | except IOError, inst: |
|
|||
1005 | raise util.Abort(_("can't read commit message '%s': %s") % |
|
|||
1006 | (logfile, inst.strerror)) |
|
|||
1007 |
|
1012 | |||
1008 | if opts['addremove']: |
|
1013 | if opts['addremove']: | |
1009 | addremove_lock(ui, repo, pats, opts) |
|
1014 | addremove_lock(ui, repo, pats, opts) |
General Comments 0
You need to be logged in to leave comments.
Login now