Show More
@@ -65,6 +65,10 b" def fetch(ui, repo, source='default', **" | |||
|
65 | 65 | modheads = repo.pull(other, heads=revs) |
|
66 | 66 | return postincoming(other, modheads) |
|
67 | 67 | |
|
68 | date = opts.get('date') | |
|
69 | if date: | |
|
70 | opts['date'] = util.parsedate(date) | |
|
71 | ||
|
68 | 72 | parent, p2 = repo.dirstate.parents() |
|
69 | 73 | if parent != repo.changelog.tip(): |
|
70 | 74 | raise util.Abort(_('working dir not at tip ' |
@@ -203,6 +203,11 b' def sign(ui, repo, *revs, **opts):' | |||
|
203 | 203 | mygpg = newgpg(ui, **opts) |
|
204 | 204 | sigver = "0" |
|
205 | 205 | sigmessage = "" |
|
206 | ||
|
207 | date = opts.get('date') | |
|
208 | if date: | |
|
209 | opts['date'] = util.parsedate(date) | |
|
210 | ||
|
206 | 211 | if revs: |
|
207 | 212 | nodes = [repo.lookup(n) for n in revs] |
|
208 | 213 | else: |
@@ -612,6 +612,8 b' class queue:' | |||
|
612 | 612 | force = opts.get('force') |
|
613 | 613 | user = opts.get('user') |
|
614 | 614 | date = opts.get('date') |
|
615 | if date: | |
|
616 | date = util.parsedate(date) | |
|
615 | 617 | self.check_reserved_name(patch) |
|
616 | 618 | if os.path.exists(self.join(patch)): |
|
617 | 619 | raise util.Abort(_('patch "%s" already exists') % patch) |
@@ -640,7 +642,7 b' class queue:' | |||
|
640 | 642 | p.write("# HG changeset patch\n") |
|
641 | 643 | if user: |
|
642 | 644 | p.write("# User " + user + "\n") |
|
643 |
p.write("# Date " |
|
|
645 | p.write("# Date %d %d\n" % date) | |
|
644 | 646 | p.write("\n") |
|
645 | 647 | elif user: |
|
646 | 648 | p.write("From: " + user + "\n") |
@@ -935,6 +937,9 b' class queue:' | |||
|
935 | 937 | if len(self.applied) == 0: |
|
936 | 938 | self.ui.write("No patches applied\n") |
|
937 | 939 | return 1 |
|
940 | newdate = opts.get('date') | |
|
941 | if newdate: | |
|
942 | newdate = '%d %d' % util.parsedate(newdate) | |
|
938 | 943 | wlock = repo.wlock() |
|
939 | 944 | try: |
|
940 | 945 | self.check_toppatch(repo) |
@@ -995,7 +1000,6 b' class queue:' | |||
|
995 | 1000 | comments = ['From: ' + newuser, ''] + comments |
|
996 | 1001 | user = newuser |
|
997 | 1002 | |
|
998 | newdate = opts.get('date') | |
|
999 | 1003 | if newdate: |
|
1000 | 1004 | if setheaderfield(comments, ['# Date '], newdate): |
|
1001 | 1005 | date = newdate |
@@ -1115,6 +1115,9 b' def walkchangerevs(ui, repo, pats, chang' | |||
|
1115 | 1115 | |
|
1116 | 1116 | def commit(ui, repo, commitfunc, pats, opts): |
|
1117 | 1117 | '''commit the specified files or all outstanding changes''' |
|
1118 | date = opts.get('date') | |
|
1119 | if date: | |
|
1120 | opts['date'] = util.parsedate(date) | |
|
1118 | 1121 | message = logmessage(opts) |
|
1119 | 1122 | |
|
1120 | 1123 | # extract addremove carefully -- this function can be called from a command |
@@ -196,6 +196,10 b' def backout(ui, repo, node=None, rev=Non' | |||
|
196 | 196 | if not rev: |
|
197 | 197 | raise util.Abort(_("please specify a revision to backout")) |
|
198 | 198 | |
|
199 | date = opts.get('date') | |
|
200 | if date: | |
|
201 | opts['date'] = util.parsedate(date) | |
|
202 | ||
|
199 | 203 | cmdutil.bail_if_changed(repo) |
|
200 | 204 | node = repo.lookup(rev) |
|
201 | 205 | |
@@ -1440,6 +1444,10 b' def import_(ui, repo, patch1, *patches, ' | |||
|
1440 | 1444 | """ |
|
1441 | 1445 | patches = (patch1,) + patches |
|
1442 | 1446 | |
|
1447 | date = opts.get('date') | |
|
1448 | if date: | |
|
1449 | opts['date'] = util.parsedate(date) | |
|
1450 | ||
|
1443 | 1451 | if opts.get('exact') or not opts['force']: |
|
1444 | 1452 | cmdutil.bail_if_changed(repo) |
|
1445 | 1453 |
@@ -202,6 +202,7 b' class localrepository(repo.repository):' | |||
|
202 | 202 | |
|
203 | 203 | date: date tuple to use if committing''' |
|
204 | 204 | |
|
205 | date = util.parsedate(date) | |
|
205 | 206 | for x in self.status()[:5]: |
|
206 | 207 | if '.hgtags' in x: |
|
207 | 208 | raise util.Abort(_('working copy of .hgtags is changed ' |
@@ -1572,17 +1572,21 b' def strdate(string, format, defaults=[])' | |||
|
1572 | 1572 | unixtime = localunixtime + offset |
|
1573 | 1573 | return unixtime, offset |
|
1574 | 1574 | |
|
1575 |
def parsedate( |
|
|
1576 | """parse a localized time string and return a (unixtime, offset) tuple. | |
|
1575 | def parsedate(date, formats=None, defaults=None): | |
|
1576 | """parse a localized date/time string and return a (unixtime, offset) tuple. | |
|
1577 | ||
|
1577 | 1578 | The date may be a "unixtime offset" string or in one of the specified |
|
1578 | formats.""" | |
|
1579 | if not string: | |
|
1579 | formats. If the date already is a (unixtime, offset) tuple, it is returned. | |
|
1580 | """ | |
|
1581 | if not date: | |
|
1580 | 1582 | return 0, 0 |
|
1583 | if type(date) is type((0, 0)) and len(date) == 2: | |
|
1584 | return date | |
|
1581 | 1585 | if not formats: |
|
1582 | 1586 | formats = defaultdateformats |
|
1583 |
|
|
|
1587 | date = date.strip() | |
|
1584 | 1588 | try: |
|
1585 |
when, offset = map(int, |
|
|
1589 | when, offset = map(int, date.split(' ')) | |
|
1586 | 1590 | except ValueError: |
|
1587 | 1591 | # fill out defaults |
|
1588 | 1592 | if not defaults: |
@@ -1599,13 +1603,13 b' def parsedate(string, formats=None, defa' | |||
|
1599 | 1603 | |
|
1600 | 1604 | for format in formats: |
|
1601 | 1605 | try: |
|
1602 |
when, offset = strdate( |
|
|
1606 | when, offset = strdate(date, format, defaults) | |
|
1603 | 1607 | except (ValueError, OverflowError): |
|
1604 | 1608 | pass |
|
1605 | 1609 | else: |
|
1606 | 1610 | break |
|
1607 | 1611 | else: |
|
1608 |
raise Abort(_('invalid date: %r ') % |
|
|
1612 | raise Abort(_('invalid date: %r ') % date) | |
|
1609 | 1613 | # validate explicit (probably user-specified) date and |
|
1610 | 1614 | # time zone offset. values must fit in signed 32 bits for |
|
1611 | 1615 | # current 32-bit linux runtimes. timezones go from UTC-12 |
@@ -2,16 +2,10 b'' | |||
|
2 | 2 | transaction abort! |
|
3 | 3 | rollback completed |
|
4 | 4 | abort: empty commit message |
|
5 | transaction abort! | |
|
6 | rollback completed | |
|
7 | 5 | abort: impossible time zone offset: 4444444 |
|
8 | transaction abort! | |
|
9 | rollback completed | |
|
10 | 6 | abort: invalid date: '1\t15.1' |
|
11 | transaction abort! | |
|
12 | rollback completed | |
|
13 | 7 | abort: invalid date: 'foo bar' |
|
14 | nothing changed | |
|
8 | abort: date exceeds 32 bits: 111111111111 | |
|
15 | 9 | % commit added file that has been deleted |
|
16 | 10 | nothing changed |
|
17 | 11 | abort: file bar not found! |
@@ -3,14 +3,8 b' changeset 3:107ce1ee2b43 backs out chang' | |||
|
3 | 3 | merging with changeset 2:e6c3abc120e7 |
|
4 | 4 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
5 | 5 | (branch merge, don't forget to commit) |
|
6 | transaction abort! | |
|
7 | rollback completed | |
|
8 | 6 | abort: invalid date: 'should fail' |
|
9 | transaction abort! | |
|
10 | rollback completed | |
|
11 | 7 | abort: date exceeds 32 bits: 100000000000000000 |
|
12 | transaction abort! | |
|
13 | rollback completed | |
|
14 | 8 | abort: impossible time zone offset: 1400000 |
|
15 | 9 | Sun Jan 15 13:30:00 2006 +0500 |
|
16 | 10 | Sun Jan 15 13:30:00 2006 -0800 |
General Comments 0
You need to be logged in to leave comments.
Login now