Commit Graph

628 Commits

Author SHA1 Message Date
Yuya Nishihara
126b1dc317 py3: use bytes IO to write sample hgrc
Unicode sucks. Stop using Text IO and manually convert line endings.
2017-08-03 00:45:02 +09:00
Pulkit Goyal
c281f33299 py3: check for bytes instead of str in isinstance 2017-06-22 03:20:11 +05:30
Pulkit Goyal
d05173a0a0 py3: replace str with bytes in isinstance()
We were using str because on Python 2, str were bytes but now we have to use
bytes. Otherwise the if conditions fails and we have weird results from commands
on Python 3.
2017-06-20 23:46:18 +05:30
Pierre-Yves David
35e577df8a local-clone: also copy tags related caches
This caches provide a large speedup for some repositories. Keeping it around is
valuable.
2017-05-25 12:09:09 +02:00
Pierre-Yves David
540a8c90f4 local-clone: also copy revs-branch-cache files
This cache provides a large speedup for some repositories. Keeping it around is
valuable.
2017-05-25 12:05:33 +02:00
Pierre-Yves David
2fbd792e60 local-clone: extract the listing of caches to copy
Right now, the clone only copies the branchmap caches. There are multiple
other valuable caches that we should copy and extensions might add their own.
So we add a function to list the cache files to copy from the repository. The
repository argument is unused but extensions will want it.
2017-05-25 11:59:07 +02:00
Pierre-Yves David
d09b0ef1ef local-clone: extract the closure copying caches
Closures often get on the way. They are not much value in having that as a
closure so I'm extracting it at the module level.
2017-05-25 11:55:00 +02:00
Jun Wu
cf441f3e42 dispatch: make request accept additional reposetups
chg needs special logic around repo object creation (like, collecting and
reporting repo path to the master server). Adding "reposetup" to
dispatch.request seems to be an easy and reasonably clean way to allow that.
2017-04-29 21:39:47 -07:00
Martin von Zweigbergk
612215ff94 outgoing: run on filtered repo
outgoing has been using an unfiltered repo since 07f64d64baf7 (discovery:
outgoing pass unfiltered repo to findcommonincoming (issue3776),
2013-01-28). If I'm reading code and history correctly, it should be
safe to run _outgoing() on a filtered repo since daf83ddd4afd
(discovery: run discovery on filtered repository, 2015-01-07). By
running _outgoing() on a filtered repo, we can also remove the
workaround there for ignoring filtered revisions.
2017-05-05 10:08:36 -07:00
Pulkit Goyal
04352e4321 py3: replace str() with bytes() 2017-04-07 13:46:35 +05:30
Jun Wu
e7394336ca clone: get rid of ui.backupconfig 2017-03-16 14:18:50 -07:00
Pierre-Yves David
de20776881 hg-mod: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:53:24 -08:00
Mads Kiilerich
975c19c195 vfs: use repo.vfs.unlinkpath 2017-03-11 11:02:25 -08:00
Pierre-Yves David
151773bf84 vfs: use 'vfs' module directly in 'mercurial.hg'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:27:42 +01:00
Martin von Zweigbergk
066bf0dbb3 update: allow setting default update check to "noconflict"
The new value allows update (linear or not) as long as they don't
result in file merges.

I'm hoping that this value can some day become the default.
2017-02-13 00:05:55 -08:00
Martin von Zweigbergk
f4acb206be update: add experimental config for default way of handling dirty wdir
This allows the user to set e.g. experimental.updatecheck=abort to
abort update if the working directory is dirty, but still be able to
override the behavior with e.g. --merge when needed.

I considered adding a --mergelinear option to get back the old
behavior even when experimental.updatecheck=abort is set, but I
couldn't see why anyone would prefer that over --merge.

The default is read in hg.updatetotally(), which means it also applies
to "hg pull -u" and "hg unbundle -u".
2017-02-13 16:03:05 -08:00
Martin von Zweigbergk
5b3eb48725 update: accept --merge to allow merging across topo branches (issue5125) 2017-02-13 12:58:37 -08:00
Dan Villiom Podlaski Christiansen
66c3976319 share: add --relative flag to store a relative path to the source
Storing a relative path the source repository is useful when exporting
repositories over the network or when they're located on external
drives where the mountpoint isn't always fixed.

Currently, Mercurial interprets paths in `.hg/shared` relative to
$PWD. I suspect this is very much unintentional, and you have to
manually edit `.hg/shared` in order to trigger this behaviour.

However, on the off chance that someone might rely on it, I added a
new capability called 'relshared'. In addition, this makes earlier
versions of Mercurial fail with a graceful error.

I should note that I haven't tested this patch on Windows.
2017-02-13 14:05:24 +01:00
Augie Fackler
dfa0dfc344 outgoing: avoid running pager until we're actually showing changes
Consistent with the new behavior of incoming in the previous patch.
2017-02-21 11:06:02 -05:00
Augie Fackler
4aaf8fb8de incoming: delay pager activation until right before printing changes
This prevents authentication and other brief status messages from
being paged.
2017-02-21 10:53:13 -05:00
Martin von Zweigbergk
645fe27a5b update: move check for dirty wdir into hg.updatetotally()
The function has a "check" parameter that's currently unused, and it
makes sense to me to have it honor it. That way other callers than
commands.update() could set it if they needed.
2017-02-13 11:58:02 -08:00
Martin von Zweigbergk
7ddb655b81 destutil: drop now-unused "check" parameter from destupdate() 2017-02-13 11:32:09 -08:00
Simon Farnsworth
3622717b76 merge: add conflict labels to merge command
Now that we present the conflict labels in prompts, it's useful to have
better names than "local" and "other" for every command.
2016-10-07 08:51:50 -07:00
Gregory Szorc
f91c7e8491 hg: set default path correctly when doing a clone+share (issue5378)
Before, if performing a clone+share from a repo that was itself
using shared storage, the share code would copy paths.default from
the underlying repo being shared, not from the source given by
the user.

This patch teaches hg.clonewithshare to resolve paths.default
and pass it to share so it can be written to the hgrc accordingly.
2016-10-02 22:34:40 -07:00
Pierre-Yves David
5a534157a8 update: label bookmark name in message
We label bookmark name as such in various messages. This will help them to
standout (or at least give the user the option to make them stand out). We use a
distinct label for the 'active' bookmark, this can help users to catch bookmark
operation affecting their working copy.
2016-08-22 14:44:14 +02:00
Pierre-Yves David
085167ea88 shared: take wlock for writting the 'shared' file
I do not see a reason why this should not be covered by the wlock.
2016-08-07 17:10:47 +02:00
FUJIWARA Katsunori
5f8eaa537b doc: omit useless _() invocation
In this case, column positioning isn't needed for i18n, too.

Maybe, check-code warning "missing _() in ui message" caused this
useless _() invocation in 6477dd5eeedf.
2016-08-01 06:08:26 +09:00
Gregory Szorc
7c2f430ebc hg: copy [hostsecurity] options to remote ui instances (issue5305)
TIL that ui instances for remote/peer repos don't automagically inherit
config options from .hg/hgrc files.

This patch makes remote ui instances inherit options from the
[hostsecurity] section. We were already inheriting options
from [hostfingerprints] and [auth]. So adding [hostsecurity] to the
list seems appropriate.
2016-07-19 19:57:34 -07:00
Yuya Nishihara
8c375bbdaa ssl: remove special case of web.cacerts=! from remoteui()
It was introduced by 2c5b8ab51da0, which is no longer necessary thanks to
recent refactoring of sslutil including 3e53509a6020.
2016-06-05 12:18:20 +09:00
Martijn Pieters
a8afdea978 share: move magic string to a constant 2016-06-24 10:32:38 +01:00
liscju
c7ec9d159e i18n: translate abort messages
I found a few places where message given to abort is
not translated, I don't find any reason to not translate
them.
2016-06-14 11:53:55 +02:00
Augie Fackler
ad67b99d20 cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
All versions of Python we support or hope to support make the hash
functions available in the same way under the same name, so we may as
well drop the util forwards.
2016-06-10 00:12:33 -04:00
Matt Harbison
3036220cae verify: don't init subrepo when missing one is referenced (issue5128) (API)
Initializing a subrepo when one doesn't exist is the right thing to do when the
parent is being updated, but in few other cases.  Unfortunately, there isn't
enough context in the subrepo module to distinguish this case.  This same issue
can be caused with other subrepo aware commands, so there is a general issue
here beyond the scope of this fix.

A simpler attempt I tried was to add an '_updating' boolean to localrepo, and
set/clear it around the call to mergemod.update() in hg.updaterepo().  That
mostly worked, but doesn't handle the case where archive will clone the subrepo
if it is missing.  (I vaguely recall that there may be other commands that will
clone if needed like this, but certainly not all do.  It seems both handy, and a
bit surprising for what should be a read only operation.  It might be nice if
all commands did this consistently, but we probably need Angel's subrepo caching
first, to not make a mess of the working directory.)

I originally handled 'Exception' in order to pick up the Aborts raised in
subrepo.state(), but this turns out to be unnecessary because that is called
once and cached by ctx.sub() when iterating the subrepos.

It was suggested in the bug discussion to skip looking at the subrepo links
unless -S is specified.  I don't really like that idea because missing a subrepo
or (less likely, but worse) a corrupt .hgsubstate is a problem of the parent
repo when checking out a revision.  The -S option seems like a better fit for
functionality that would recurse into each subrepo and do a full verification.

Ultimately, the default value for 'allowcreate' should probably be flipped, but
since the default behavior was to allow creation, this is less risky for now.
2016-04-27 22:45:52 -04:00
FUJIWARA Katsunori
df40fdeec8 hg: acquire wlock while updating the working directory via updatetotally
updatetotally() might be invoked outside wlock scope (e.g. invocation
via postincoming() at "hg unbundle" or "hg pull").

In such case, acquisition of wlock is needed for consistent view,
because parallel "hg update" and/or "hg bookmarks" might change
working directory status while executing updatetotally().

Strictly speaking, truly consistent updating should acquire also store
lock, because active bookmark might be moved to another one outside
wlock scope (e.g. pulling from other repository causes updating
current active one).

Acquisition of wlock in this patch ensures consistency in as same
level as past "hg update".
2016-03-12 04:35:42 +09:00
FUJIWARA Katsunori
323523ef12 commands: centralize code to update with extra care for non-file components
This patch centralizes similar code paths to update the working
directory with extra care for non-file components (e.g. bookmark) into
newly added function updatetotally().

'if True' at the beginning of updatetotally() is redundant at this
patch, but useful to reduce amount of changes in subsequent patch.
2016-03-12 04:35:42 +09:00
Matt Mackall
2f932b7682 merge with stable 2016-03-02 16:44:56 -06:00
Gregory Szorc
5b47f5a7bd hg: obtain lock when creating share from pooled repo (issue5104)
There are race conditions between clients performing a shared clone
to pooled storage:

1) Clients race to create the new shared repo in the pool directory
2) 1 client is seeding the repo in the pool directory and another goes
   to share it before it is fully cloned

We prevent these race conditions by obtaining a lock in the pool
directory that is derived from the name of the repo we will be
accessing.

To test this, a simple generic "lockdelay" extension has been added.
The extension inserts an optional, configurable delay before or after
lock acquisition. In the test, we delay 2 seconds after lock acquisition
in the first process and 1 second before lock acquisition in the 2nd
process. This means the first process has 1s to obtain the lock. There
is a race condition here. If we encounter it in the wild, we could
change the dummy extension to wait on the lock file to appear instead
of relying on timing. But that's more complicated. Let's see what
happens first.
2016-02-27 18:22:49 -08:00
timeless
ebb1d48658 cleanup: remove superfluous space after space after equals (python) 2015-12-31 08:16:59 +00:00
timeless
44748f7f11 update: add quietempty flag to _showstats
if called with quietempty=True, suppress:
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
2015-12-14 23:14:06 +00:00
timeless
0853af047a histedit: omit useless message from abort
specifically:
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
2015-12-14 22:08:14 +00:00
timeless
31ad01fbf1 hg: add quietempty flag to _showstats
if called with quietempty=True, suppress:
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
2015-12-14 23:13:25 +00:00
Gregory Szorc
cb39f6e0e6 hg: establish function for performing post-share actions
As part of writing an extension that wished to share an arbitrary piece
of data among shared repos, I had to reimplement a significant part of
hg.share in order to obtain localrepository instances for the source
and destination.

This patch establishes a function in hg.py that will be called after a
share is performed. It is passed localrepository instances so extensions
can easily perform additional actions at share time. We move hgrc and
shared file writing there because this function is a logical place for
it.

A side effect of the refactor is writing of the shared file now occurs
before updating. This seems more appropriate and shouldn't have any
impact on real world behavior.
2015-12-12 22:20:29 -05:00
Augie Fackler
0a19647501 merge: have merge.update use a matcher instead of partial fn
This is relatively rarely used functionality, but migrating this to a
matcher will make future work on narrow clones more feasible.
2015-12-14 18:54:03 -05:00
Augie Fackler
4e03270f68 localrepo: remove clone method by hoisting into hg.py
hg.py was the only remaining caller of localrepo.clone(), so it's time
to move some more behavior out of localrepo.
2015-11-11 19:47:49 -05:00
Gregory Szorc
ac64f94152 hg: perform update after pulling during clone with share (issue5103)
When pooled storage is enabled, `hg clone` will initialize a repo
from a local repo using the store sharing mechanism then pull from
the originally requested repo.

Before this patch, the working directory update occurred between
these steps. This meant that we would only update to revisions that
were already present in the local pooled storage.

This patch moves the update to after we pull from the originally
requested repository so we may check out a revision that didn't yet
exist locally. In other words, it makes the behavior like normal
`hg clone`.
2016-02-20 17:44:29 -08:00
Gregory Szorc
d44d8e3845 hg: extract post share update logic into own function
A future patch will introduce a new caller that needs to perform
an update. Extract the code so we don't duplicate it.
2016-02-20 17:41:59 -08:00
FUJIWARA Katsunori
7164ed4e18 hg: make cachedlocalrepo cache appropriate repoview object
Before this patch, 'cachedlocalrepo' always caches "visible" repoview
object, because 'cachedlocalrepo' uses "visible" repoview returned by
'hg.repository()' without any additional processing.

If the client of 'cachedlocalrepo' wants "served" repoview, some
objects to be cached are discarded unintentionally.

    1. 'cachedlocalrepo' newly caches "visible" repoview object
       (call it VIEW1)

    2. 'cachedlocalrepo' returns VIEW1 to the client of it at 'fetch()'

    3. the client gets "served" repoview object by 'filtered("served")'
       on VIEW1 (call this "served" repoview VIEW2)

    4. accessing to 'repo.changelog' implies:
       - instantiation of changelog via 'localrepository.changelog'
       - instantiation of "filtered changelog" via 'repoview.changelog'

    5. "filtered changelog" above is cached in VIEW2

    6. VIEW2 is discarded after processing, because there is no
       reference to it

    7. 'cachedlocalrepo' returns VIEW1 cached at (1) above to the
       client at next 'fetch()'

    8. 'filtered("served")' on VIEW1 at the client side creates new
       "served" repoview again, because VIEW1 is "visible"
       (call this new "served" repoview VIEW3)

    9. accessing to 'repo.changelog' implies instantiation of filtered
       changelog again, because "filtered changelog" is cached in
       VIEW2 at (5), but not in VIEW3 currently used

    10. (go to (7) above)

As described above, "served" repoview object and "filtered changelog"
cached in it are discarded always, even if the repository itself
hasn't been changed since last access.

For example, in the case of 'hgweb_mod.hgweb', "newly caching" occurs,
when:

  - all cached objects are already assigned to another threads
    (in this case, repoview is created in 'cachedlocalrepo.copy()')

  - or, stat of '00changelog.i' is changed from last access
    (in this case, repoview is created in 'cachedlocalrepo.fetch()')

    once changes are pushed via HTTP, this always occurs.

The root cause of this inefficiency is that 'cachedlocalrepo' always
caches "visible" repoview object, even if the client of it wants
another view.

To make 'cachedlocalrepo' cache appropriate repoview object, this
patch adds additional filtering on the repo object returned by
'hg.repository()'. It is assumed that initial repoview object should
be already filtered by expected view.

After this patch:

  - 'filtered("served")' on VIEW1 at (3)/(7) above returns VIEW1
    itself, because VIEW1 is now "served", and

  - VIEW2 and VIEW3 equal VIEW1

  - therefore, "filtered changelog" is cached in VIEW1, and reused
    intentionally
2016-02-14 01:33:55 +09:00
Siddharth Agarwal
803f564a2a merge: tell _checkunknownfiles about whether this was merge --force
In an upcoming patch we'll have different behavior here for when 'merge
--force' is used as opposed to when other kinds of force operations are
performed, like rebases.
2016-02-01 20:28:32 -08:00
Mads Kiilerich
09567db49a spelling: trivial spell checking 2015-10-17 00:58:46 +02:00
Matt Mackall
d893847a13 mq: use cmdutil.revert instead of hg.revert
It's the last user.
2015-10-12 03:37:09 -05:00