Mercurial > public > mercurial-scm > python-hglib
comparison hglib/client.py @ 136:dc63978871ed
client: add support for 'hg commit --amend'
author | David Douard <david.douard@logilab.fr> |
---|---|
date | Thu, 23 Oct 2014 10:50:09 +0200 |
parents | 1b47146a4a2c |
children | fe74d5599539 |
comparison
equal
deleted
inserted
replaced
135:f6b6e16531f8 | 136:dc63978871ed |
---|---|
531 u=updaterev, r=revrange) | 531 u=updaterev, r=revrange) |
532 self.rawcommand(args) | 532 self.rawcommand(args) |
533 | 533 |
534 def commit(self, message=None, logfile=None, addremove=False, | 534 def commit(self, message=None, logfile=None, addremove=False, |
535 closebranch=False, date=None, user=None, include=None, | 535 closebranch=False, date=None, user=None, include=None, |
536 exclude=None): | 536 exclude=None, amend=False): |
537 """ | 537 """ |
538 Commit changes reported by status into the repository. | 538 Commit changes reported by status into the repository. |
539 | 539 |
540 message - the commit message | 540 message - the commit message |
541 logfile - read commit message from file | 541 logfile - read commit message from file |
543 closebranch - mark a branch as closed, hiding it from the branch list | 543 closebranch - mark a branch as closed, hiding it from the branch list |
544 date - record the specified date as commit date | 544 date - record the specified date as commit date |
545 user - record the specified user as committer | 545 user - record the specified user as committer |
546 include - include names matching the given patterns | 546 include - include names matching the given patterns |
547 exclude - exclude names matching the given patterns | 547 exclude - exclude names matching the given patterns |
548 """ | 548 amend - amend the parent of the working dir |
549 if message is None and logfile is None: | 549 """ |
550 if amend and message is None and logfile is None: | |
551 # retrieve current commit message | |
552 message = self.log('.')[0][5] | |
553 if message is None and logfile is None and not amend: | |
550 raise ValueError("must provide at least a message or a logfile") | 554 raise ValueError("must provide at least a message or a logfile") |
551 elif message and logfile: | 555 elif message and logfile: |
552 raise ValueError("cannot specify both a message and a logfile") | 556 raise ValueError("cannot specify both a message and a logfile") |
553 | 557 |
554 # --debug will print the committed cset | 558 # --debug will print the committed cset |
555 args = cmdbuilder('commit', debug=True, m=message, A=addremove, | 559 args = cmdbuilder('commit', debug=True, m=message, A=addremove, |
556 close_branch=closebranch, d=date, u=user, l=logfile, | 560 close_branch=closebranch, d=date, u=user, l=logfile, |
557 I=include, X=exclude) | 561 I=include, X=exclude, amend=amend) |
558 | |
559 out = self.rawcommand(args) | 562 out = self.rawcommand(args) |
560 rev, node = out.splitlines()[-1].rsplit(':') | 563 rev, node = out.splitlines()[-1].rsplit(':') |
561 return int(rev.split()[-1]), node | 564 return int(rev.split()[-1]), node |
562 | 565 |
563 def config(self, names=[], untrusted=False, showsource=False): | 566 def config(self, names=[], untrusted=False, showsource=False): |