Commit Graph

120 Commits

Author SHA1 Message Date
Jordi Gutiérrez Hermoso
a3f845b50e record: update comment to match code
Commit 9bcdffd81aaf changed how newfiles get passed to commitfunc, but
did not change the corresponding comment that explains this. This
commit also updates this comment.
2014-06-26 11:10:28 -04:00
Gregory Szorc
6000635fc2 record: define inferrepo in command decorator 2014-05-04 22:36:07 -07:00
Gregory Szorc
5785fc1837 record: declare commands using decorator 2014-05-04 22:35:37 -07:00
Pierre-Yves David
0d013e32a2 record: use absolute path instead of os.chdir
Record was changing the current directory to `repo.root` in order to be able to
feed `command.commit` file name relative to this `repo.root`. This is a bit
overkill and prevent an incoming fix to rebase. This would also break
multi-threaded usage.

Instead we just feed `command.commit` with absolute path name. works as well as
before but without chdir.
2014-01-31 14:52:53 -08:00
Jordi Gutiérrez Hermoso
aeb19f9922 record: re-enable whitespace-ignoring options
It looks like somewhere down the line, patch.diffopts changed the
names of the options that it recognises, but record.recordfunc wasn't
updated to the new names. Instead of trying to write down names at
all, we now use whatever names are provided in commands.diffwsopts and
pass that along to patch.diffopts, along with a couple of custom
options
2014-01-16 15:05:03 -05:00
Jordi Gutiérrez Hermoso
ccf7869bdf record: use commands.diffwsopts instead of ad-hoc diffopts
The record extension is writing its own version of commands.diffwsopts
which is identical to commands.diffwsopts. Based on the principle that
code duplication increases maintenance burden, this patch removes
record's ad-hoc diffopts in favour of commands.diffwsopts
2014-01-16 14:57:52 -05:00
FUJIWARA Katsunori
c2ab815c76 record: use "ui.extractchoices()" to get the list of available responses
Before this patch, record extension gets the list of available
responses from online help document of "hg record" in the tricky way,
even though the value passed to "ui.promptchoice()" has enough (maybe
i18n-ed) information.

This patch uses "ui.extractchoices()" to get the list of available
responses.
2013-12-02 00:50:30 +09:00
Prasoon Shukla
7c782e5502 record: --user/-u now works with record when ui.username not set (issue3857)
The -u flag didn't work when ui.username was not set and resulted in an
abort message. This was fixed by checking for the 'user' key in the opts
dictionary. If the key is present, the step causing the exception is not
executed.
2013-12-12 12:25:56 +05:30
Matt Mackall
d177c8d161 record: add checkunfinished support (issue3955) 2013-07-25 02:34:09 -05:00
Matt Mackall
13d2a13ea6 ui: merge prompt text components into a singe string
This will help avoid problems with partial or mismatched translation
of the components.
2013-05-22 17:31:43 -05:00
Mads Kiilerich
886d6922c4 record: ignore trailing content when parsing patches - introduce 'other' lines
This makes record work more like import which ignores for instance mail footers
in a patch file.

This also makes it possible for TortoiseHg to preview unapplied patches
containing such footers.
2012-06-13 23:06:34 +02:00
Mads Kiilerich
dbfffc0abf record: abort on malformed patches instead of crashing 2013-04-11 19:03:33 +02:00
Idan Kamara
ba14804c98 record: remove unused import 2013-01-09 21:13:52 +02:00
Denis Laxalde
b706c87e50 record: use patch.diffopts to account for user diffopts
This allows user defined diff options (e.g. showfunc) to be accounted for
when using record. A test has been updated accordingly.
2013-01-08 21:16:39 +01:00
Siddharth Agarwal
a5e71891bd commands: don't infer repo for commands like update (issue2748)
Maintain a whitelist of commands to infer the repo for instead. The whitelist
contains those commands that take file(s) in the working dir as arguments.
2012-10-16 11:43:15 -07:00
Nikolaj Sjujskij
88edfbe265 record: fix display of non-ASCII names in chunk selection
46cdcb89086f fixed display of non-ASCII names in file-selecting prompt, but
display in chunk selection remained broken. The reason is that using '%r' in
string formatting results in calling `repr` on file names, thus mangling
non-ASCII ones.
2012-09-15 00:06:08 +04:00
Sumeet
de52249a43 record: checks for valid username before starting recording process (issue3456) 2012-08-27 12:41:10 -07:00
Mads Kiilerich
2372d51b68 fix wording and not-completely-trivial spelling errors and bad docstrings 2012-08-15 22:39:18 +02:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Matt Mackall
f52103b924 merge with stable 2012-07-01 21:20:30 -05:00
Matt Mackall
921065f3f8 record: fix display of non-ASCII names
spotted by Nikolaj Sjujskij
2012-07-01 13:10:54 -05:00
Augie Fackler
96d44b39f7 hgext: mark all first-party extensions as such 2012-05-15 14:37:49 -05:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Matt Mackall
58dccf8b84 record: fix up test issues
sed on BSD requires an arg to -i
sed failing exposed an uninitialized variable issue
2012-03-31 14:04:39 -05:00
A. S. Budden
285680e0f0 record: allow splitting of hunks by manually editing patches
It is possible that unrelated changes in a file are on sequential lines.  The
current record extension does not allow these to be committed independently.

An example use case for this is in software development for deeply embedded
real-time systems.  In these environments, it is not always possible to use a
debugger (due to time-constraints) and hence inline UART-based printing is
often used.  When fixing a bug in a module, it is often convenient to add a
large number of 'printf's (linked to the UART via a custom fputc) to the module
in order to work out what is going wrong.  printf is a very slow function (and
also variadic so somewhat frowned upon by the MISRA standard) and hence it is
highly undesirable to commit these lines to the repository.  If only a partial
fix is implemented, however, it is desirable to commit the fix without deleting
all of the printf lines.  This is also simplifies removal of the printf lines
as once the final fix is committed, 'hg revert' does the rest.  It is likely
that the printf lines will be very near the actual fix, so being able to split
the hunk is very useful in this case.

There were two alternatives I considered for the user interface.  One was to
manually edit the patch, the other to allow a hunk to be split into individual
lines for consideration.  The latter option would require a significant
refactor of the record module and is less flexible.  While the former is
potentially more complicated to use, this is a feature that is likely to only
be used in certain exceptional cases (such as the use case proposed above) and
hence I felt that the complexity would not be a considerable issue.

I've also written a follow-up patch that refactors the 'prompt' code to base
everything on the choices variable.  This tidies up and clarifies the code a
bit (removes constructs like 'if ret == 7' and removes the 'e' option from the
file scope options as it's not relevant there.  It's not really a necessity, so
I've excluded it from this submission for now, but I can send it separately if
there's a desire and it's on bitbucket (see below) in the meantime.

Possible future improvements include:

* Tidying up the 'prompt' code to base everything on the choices variable.
  This would allow entries to be removed from the prompt as currently 'e' is
  offered even for entire file patches, which is currently unsupported.
* Allowing the entire file (or even multi-file) patch to be edited manually:
  this would require quite a large refactor without much benefit, so I decided
  to exclude it from the initial submission.
* Allow the option to retry if a patch fails to apply (this is what Git does).
  This would require quite a bit of refactoring given the current 'hg record'
  implementation, so it's debatable whether it's worth it.

Output is similar to existing record user interface except that an additional
option ('e') exists to allow manual editing of the patch.  This opens the
user's configured editor with the patch.  A comment is added to the bottom of
the patch explaining what to do (based on Git's one).

A large proportion of the changeset is test-case changes to update the options
reported by record (Ynesfdaq? instead of Ynsfdaq?).  Functional changes are in
record.py and there are some new test cases in test-record.t.
2012-03-30 22:08:46 +01:00
Matt Mackall
4dc5f821e2 record: use command wrapper properly for qnew/qrefresh (issue3001) 2011-10-01 15:47:03 -05:00
Ingo Proetel
bef424c7fa record: add white space diff options 2011-06-10 10:58:10 +02:00
Idan Kamara
a7eca9ebe7 record: fix options placeholder 2011-05-26 19:00:47 +03:00
Idan Kamara
67e075c860 record: alias qrecord to qnew -i/--interactive 2011-05-24 19:17:22 +03:00
Idan Kamara
dcebc5aaa6 record: add qrefresh -i/--interactive
interactively select changes to refresh
2011-05-24 19:17:19 +03:00
Idan Kamara
d4250f0ae0 record: add an option to backup all wc modifications
Also, don't create a backup dir if we have no files to backup.

This is essential for qrefresh --interactive. Since we can't
select individual files to qrefresh without eliminating already
present changes, we have to backup all changes in the working
copy to avoid refreshing unaccepted hunks.

(thanks to Patrick for the idea)
2011-05-24 19:17:04 +03:00
Idan Kamara
91b788592f record: check patch name is valid before prompting in qrecord 2011-05-24 19:17:02 +03:00
Idan Kamara
1e15ba1cc3 record: use cmdutil.command decorator 2011-05-22 16:10:03 +03:00
Idan Kamara
9966d26707 record: suggest the right command when running non interactively 2011-05-22 16:10:02 +03:00
Patrick Mezard
2bda8cbde2 patch: add a workingbackend dirstate layer on top of fsbackend
_updatedir() is no longer used by internalpatch()

The change in test-mq-missingfiles.t comes from workingbackend not considering
the missing 'b' file as changed, thus not calling addremove() on it.
2011-05-18 23:48:17 +02:00
Patrick Mezard
e0378ee5bd patch: make patch()/internalpatch() always update the dirstate 2011-05-08 17:48:31 +02:00
Patrick Mezard
88e958194e patch: move updatedir() from cmdutil into patch
Also, create an artificial wdutil.py to avoid import cycles between patch.py
and cmdutil.py.
2011-05-08 17:48:30 +02:00
Patrick Mezard
f63ca22ee0 record: unconditionally update the working dir after patching 2011-05-08 17:48:29 +02:00
timeless
ccf3a292e9 qrecord: provide help when mq is not enabled 2011-04-14 10:00:15 +02:00
Matt Mackall
a8dd64dcb0 misc: replace .parents()[0] with p1() 2011-04-04 16:21:59 -05:00
Martin Geisler
b69ebeba05 record: replace poor man's if-statement with real if-statement 2011-03-27 12:41:55 +02:00
Patrick Mezard
4554668a40 record: do not include files into changes count
This turns the prompt sequence from something like:

  $ examine changes to foo?
  $ record change 1/4 to foo?
  $ record change 2/4 to foo?
  $ examine changes to bar?
  $ record change 4/4 to bar?

into:

  $ examine changes to foo?
  $ record change 1/3 to foo?
  $ record change 2/3 to foo?
  $ examine change to bar?
  $ record change 3/3 to bar?
2011-01-24 23:25:46 +01:00
Patrick Mezard
1854f5716d record: simplify header methods with util.any 2011-01-23 15:21:56 +01:00
Patrick Mezard
5cca40e708 record: refactor the prompt loop
The previous loop was iterating over a mixed header/hunk stream. It may have
been more generic in the sense every item in the stream could trigger a prompt
but it required more work to skip items properly. It can be rewritten in a more
intuitive way by looping on files then looping on hunks.
2011-01-23 15:21:37 +01:00
Patrick Mezard
fc1575c195 record: turn prompt() into a pure function 2011-01-23 13:01:17 +01:00
Patrick Mezard
52f4fcb07c record: turn consumefile() into a pure function 2011-01-23 12:44:05 +01:00
Kevin Bullock
4655fb606c record: clean up command table
The --force option to qnew has become a no-op, so qrecord doesn't need
to use it. This allows record's command table to be simplified; in the
process of doing so, this patch also cleans up the cmdtable visually.
2010-12-21 15:27:58 -06:00
Kevin Bullock
709bd128af record: clean up comments and docstrings
Rewrap comments and docstrings to a width of 72 chars and copy-edit.
2010-12-21 15:23:48 -06:00
Steve Borho
6796ac95d5 record: teach parsepatch() about non-git style headers
These changes are not useful to record itself, since it is hard coded
to always generate git style diffs.  But it makes parsepatch() more
generally useful for parsing normal patch files.
2010-12-08 22:14:18 -06:00
Brodie Rao
1d9f172d6c record: move copystat() hack out of util.copyfile() and into record
226847bf9cab updated copyfile to also copy over atimes and
mtimes. That behavior is specifically to trick editors into thinking
files that hg record has modified haven't changed. We don't really
care about preserving times in the general case.
2010-12-07 20:03:05 +11:00